| @@ 126-155 (lines=30) @@ | ||
| 123 | $this->subscriber->onApi($event); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testApiWithPagerfanta() |
|
| 127 | { |
|
| 128 | $this->parameterResolver |
|
| 129 | ->expects($this->once()) |
|
| 130 | ->method('resolveApi') |
|
| 131 | ->will($this->returnValue(true)); |
|
| 132 | ||
| 133 | $event = $this->createViewEventMock(); |
|
| 134 | $event |
|
| 135 | ->expects($this->once()) |
|
| 136 | ->method('getView') |
|
| 137 | ->will($this->returnValue($view = $this->createViewMock())); |
|
| 138 | ||
| 139 | $view |
|
| 140 | ->expects($this->once()) |
|
| 141 | ->method('getData') |
|
| 142 | ->will($this->returnValue($pagerfanta = $this->createPagerfantaMock())); |
|
| 143 | ||
| 144 | $pagerfanta |
|
| 145 | ->expects($this->once()) |
|
| 146 | ->method('getIterator') |
|
| 147 | ->will($this->returnValue(new \ArrayIterator($values = ['value']))); |
|
| 148 | ||
| 149 | $view |
|
| 150 | ->expects($this->once()) |
|
| 151 | ->method('setData') |
|
| 152 | ->with($this->identicalTo($values)); |
|
| 153 | ||
| 154 | $this->subscriber->onApi($event); |
|
| 155 | } |
|
| 156 | ||
| 157 | public function testApiWithHateoas() |
|
| 158 | { |
|
| @@ 121-150 (lines=30) @@ | ||
| 118 | $this->subscriber->onApi($event); |
|
| 119 | } |
|
| 120 | ||
| 121 | public function testApiWithGrid() |
|
| 122 | { |
|
| 123 | $this->parameterResolver |
|
| 124 | ->expects($this->once()) |
|
| 125 | ->method('resolveApi') |
|
| 126 | ->will($this->returnValue(true)); |
|
| 127 | ||
| 128 | $event = $this->createViewEventMock(); |
|
| 129 | $event |
|
| 130 | ->expects($this->once()) |
|
| 131 | ->method('getView') |
|
| 132 | ->will($this->returnValue($view = $this->createViewMock())); |
|
| 133 | ||
| 134 | $view |
|
| 135 | ->expects($this->once()) |
|
| 136 | ->method('getData') |
|
| 137 | ->will($this->returnValue(['grid' => $gridView = $this->createGridViewMock()])); |
|
| 138 | ||
| 139 | $gridView |
|
| 140 | ->expects($this->once()) |
|
| 141 | ->method('getDataSource') |
|
| 142 | ->will($this->returnValue($dataSource = 'data_source')); |
|
| 143 | ||
| 144 | $view |
|
| 145 | ->expects($this->once()) |
|
| 146 | ->method('setData') |
|
| 147 | ->with($this->identicalTo($dataSource)); |
|
| 148 | ||
| 149 | $this->subscriber->onApi($event); |
|
| 150 | } |
|
| 151 | ||
| 152 | public function testViewWithApi() |
|
| 153 | { |
|