AuthorCollectionTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers \PharIo\Manifest\AuthorCollection
  14. * @covers \PharIo\Manifest\AuthorCollectionIterator
  15. *
  16. * @uses \PharIo\Manifest\Author
  17. * @uses \PharIo\Manifest\Email
  18. */
  19. class AuthorCollectionTest extends TestCase {
  20. /**
  21. * @var AuthorCollection
  22. */
  23. private $collection;
  24. /**
  25. * @var Author
  26. */
  27. private $item;
  28. protected function setUp() {
  29. $this->collection = new AuthorCollection;
  30. $this->item = new Author('Joe Developer', new Email('user@example.com'));
  31. }
  32. public function testCanBeCreated() {
  33. $this->assertInstanceOf(AuthorCollection::class, $this->collection);
  34. }
  35. public function testCanBeCounted() {
  36. $this->collection->add($this->item);
  37. $this->assertCount(1, $this->collection);
  38. }
  39. public function testCanBeIterated() {
  40. $this->collection->add(
  41. new Author('Dummy First', new Email('dummy@example.com'))
  42. );
  43. $this->collection->add($this->item);
  44. $this->assertContains($this->item, $this->collection);
  45. }
  46. public function testKeyPositionCanBeRetreived() {
  47. $this->collection->add($this->item);
  48. foreach($this->collection as $key => $item) {
  49. $this->assertEquals(0, $key);
  50. }
  51. }
  52. }