1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- class OfferRetrieverTest extends PHPUnit_Framework_TestCase
- {
- private $testObj;
- private $persistence;
- public function setUp()
- {
- $this->persistence = $this->getMockBuilder('Persistence')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->testObj = new OfferRetriever($this->persistence);
- }
- public function tearDown()
- {
- }
- public function testGetPageDataReturnsTemplateNotFoundWhenInvalidId()
- {
- $offerId = TestUtils::getRandomInteger();
- $page = TestUtils::getRandomInteger();
-
- $this->persistence->expects($this->once())
- ->method('getOfferPathPage')
- ->with($this->anything(), $this->anything())
- ->willReturn(null);
-
- $defaultData = array('filename' => "templateDoesNotExist.html");
- $actual = $this->testObj->getPageData($offerId, $page);
- $this->assertEquals($defaultData, $actual);
- }
- public function testGetPageDataReturnPageData()
- {
- $data = array('filename' => TestUtils::getRandomString(20));
- $offerId = TestUtils::getRandomInteger();
- $page = TestUtils::getRandomInteger();
-
- $this->persistence->expects($this->once())
- ->method('getOfferPathPage')
- ->with($offerId, $page)
- ->willReturn($data);
-
- $actual = $this->testObj->getPageData($offerId, $page);
- $this->assertEquals($data, $actual);
- }
- }
|