Nav apraksta

BundledComponentCollectionTest.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of PharIo\Manifest.
  4. *
  5. * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace PharIo\Manifest;
  11. use PharIo\Version\Version;
  12. use PHPUnit\Framework\TestCase;
  13. /**
  14. * @covers \PharIo\Manifest\BundledComponentCollection
  15. * @covers \PharIo\Manifest\BundledComponentCollectionIterator
  16. *
  17. * @uses \PharIo\Manifest\BundledComponent
  18. * @uses \PharIo\Version\Version
  19. */
  20. class BundledComponentCollectionTest extends TestCase {
  21. /**
  22. * @var BundledComponentCollection
  23. */
  24. private $collection;
  25. /**
  26. * @var BundledComponent
  27. */
  28. private $item;
  29. protected function setUp() {
  30. $this->collection = new BundledComponentCollection;
  31. $this->item = new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2'));
  32. }
  33. public function testCanBeCreated() {
  34. $this->assertInstanceOf(BundledComponentCollection::class, $this->collection);
  35. }
  36. public function testCanBeCounted() {
  37. $this->collection->add($this->item);
  38. $this->assertCount(1, $this->collection);
  39. }
  40. public function testCanBeIterated() {
  41. $this->collection->add($this->createMock(BundledComponent::class));
  42. $this->collection->add($this->item);
  43. $this->assertContains($this->item, $this->collection);
  44. }
  45. public function testKeyPositionCanBeRetreived() {
  46. $this->collection->add($this->item);
  47. foreach($this->collection as $key => $item) {
  48. $this->assertEquals(0, $key);
  49. }
  50. }
  51. }