| 1 | <?php |
||
| 20 | class ApiHelperTest extends \PHPUnit_Framework_TestCase |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var ApiHelper |
||
| 24 | */ |
||
| 25 | private $apiHelper; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var BaseApiHelper|\PHPUnit_Framework_MockObject_MockObject |
||
| 29 | */ |
||
| 30 | private $innerApiHelper; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritdoc} |
||
| 34 | */ |
||
| 35 | protected function setUp() |
||
| 36 | { |
||
| 37 | $this->innerApiHelper = $this->createApiHelperMock(); |
||
| 38 | $this->apiHelper = new ApiHelper($this->innerApiHelper); |
||
| 39 | } |
||
| 40 | |||
| 41 | public function testRender() |
||
| 42 | { |
||
| 43 | $this->innerApiHelper |
||
| 44 | ->expects($this->once()) |
||
| 45 | ->method('render') |
||
| 46 | ->with($this->identicalTo($objects = [new \stdClass()])) |
||
| 47 | ->will($this->returnValue($result = 'result')); |
||
| 48 | |||
| 49 | $this->assertSame($result, $this->apiHelper->render($objects)); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function testName() |
||
| 53 | { |
||
| 54 | $this->assertSame('ivory_google_api', $this->apiHelper->getName()); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return \PHPUnit_Framework_MockObject_MockObject|BaseApiHelper |
||
| 59 | */ |
||
| 60 | private function createApiHelperMock() |
||
| 61 | { |
||
| 62 | return $this->createMock(BaseApiHelper::class); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |