ArrayRecipientIteratorTest.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. require_once 'Swift/Tests/SwiftUnitTestCase.php';
  3. require_once 'Swift/Mailer/ArrayRecipientIterator.php';
  4. class Swift_Mailer_ArrayRecipientIteratorTest
  5. extends Swift_Tests_SwiftUnitTestCase
  6. {
  7. public function testHasNextReturnsFalseForEmptyArray()
  8. {
  9. $it = new Swift_Mailer_ArrayRecipientIterator(array());
  10. $this->assertFalse($it->hasNext());
  11. }
  12. public function testHasNextReturnsTrueIfItemsLeft()
  13. {
  14. $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo'));
  15. $this->assertTrue($it->hasNext());
  16. }
  17. public function testReadingToEndOfListCausesHasNextToReturnFalse()
  18. {
  19. $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo'));
  20. $this->assertTrue($it->hasNext());
  21. $it->nextRecipient();
  22. $this->assertFalse($it->hasNext());
  23. }
  24. public function testReturnedValueHasPreservedKeyValuePair()
  25. {
  26. $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo'));
  27. $this->assertEqual(array('foo@bar' => 'Foo'), $it->nextRecipient());
  28. }
  29. public function testIteratorMovesNextAfterEachIteration()
  30. {
  31. $it = new Swift_Mailer_ArrayRecipientIterator(array(
  32. 'foo@bar' => 'Foo',
  33. 'zip@button' => 'Zip thing',
  34. 'test@test' => null
  35. ));
  36. $this->assertEqual(array('foo@bar' => 'Foo'), $it->nextRecipient());
  37. $this->assertEqual(array('zip@button' => 'Zip thing'), $it->nextRecipient());
  38. $this->assertEqual(array('test@test' => null), $it->nextRecipient());
  39. }
  40. }