OfferRetrieverTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class OfferRetrieverTest extends PHPUnit_Framework_TestCase
  3. {
  4. private $testObj;
  5. private $persistence;
  6. public function setUp()
  7. {
  8. $this->persistence = $this->getMockBuilder('Persistence')
  9. ->disableOriginalConstructor()
  10. ->getMock();
  11. $this->testObj = new OfferRetriever($this->persistence);
  12. }
  13. public function tearDown()
  14. {
  15. }
  16. public function testGetPageDataReturnsTemplateNotFoundWhenInvalidId()
  17. {
  18. $offerId = TestUtils::getRandomInteger();
  19. $page = TestUtils::getRandomInteger();
  20. $this->persistence->expects($this->once())
  21. ->method('getOfferPathPage')
  22. ->with($this->anything(), $this->anything())
  23. ->willReturn(null);
  24. $defaultData = array('filename' => "templateDoesNotExist.html");
  25. $actual = $this->testObj->getPageData($offerId, $page);
  26. $this->assertEquals($defaultData, $actual);
  27. }
  28. public function testGetPageDataReturnPageData()
  29. {
  30. $data = array('filename' => TestUtils::getRandomString(20));
  31. $offerId = TestUtils::getRandomInteger();
  32. $page = TestUtils::getRandomInteger();
  33. $this->persistence->expects($this->once())
  34. ->method('getOfferPathPage')
  35. ->with($offerId, $page)
  36. ->willReturn($data);
  37. $actual = $this->testObj->getPageData($offerId, $page);
  38. $this->assertEquals($data, $actual);
  39. }
  40. }