| @@ 81-123 (lines=43) @@ | ||
| 78 | /** |
|
| 79 | * @dataProvider renderProvider |
|
| 80 | */ |
|
| 81 | public function testRender($gridTemplate = null, $rendererTemplate = null) |
|
| 82 | { |
|
| 83 | $template = 'grid'; |
|
| 84 | ||
| 85 | if ($rendererTemplate !== null) { |
|
| 86 | $this->renderer = new Renderer( |
|
| 87 | $this->twig, |
|
| 88 | $this->actionRenderer, |
|
| 89 | $this->columnRenderer, |
|
| 90 | $this->sorterRenderer, |
|
| 91 | [$template => $rendererTemplate] |
|
| 92 | ); |
|
| 93 | } |
|
| 94 | ||
| 95 | $view = $this->createGridViewMock(); |
|
| 96 | $view |
|
| 97 | ->expects($this->once()) |
|
| 98 | ->method('getDefinition') |
|
| 99 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
| 100 | ||
| 101 | $grid |
|
| 102 | ->expects($this->once()) |
|
| 103 | ->method('hasOption') |
|
| 104 | ->with($this->identicalTo($option = $template.'_template')) |
|
| 105 | ->will($this->returnValue($gridTemplate !== null)); |
|
| 106 | ||
| 107 | $grid |
|
| 108 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
| 109 | ->method('getOption') |
|
| 110 | ->with($this->identicalTo($option)) |
|
| 111 | ->will($this->returnValue($gridTemplate)); |
|
| 112 | ||
| 113 | $this->twig |
|
| 114 | ->expects($this->once()) |
|
| 115 | ->method('render') |
|
| 116 | ->with( |
|
| 117 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
| 118 | $this->identicalTo(['grid' => $view]) |
|
| 119 | ) |
|
| 120 | ->will($this->returnValue($result = 'result')); |
|
| 121 | ||
| 122 | $this->assertSame($result, $this->renderer->render($view)); |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * @dataProvider renderProvider |
|
| @@ 128-170 (lines=43) @@ | ||
| 125 | /** |
|
| 126 | * @dataProvider renderProvider |
|
| 127 | */ |
|
| 128 | public function testRenderFilters($gridTemplate = null, $rendererTemplate = null) |
|
| 129 | { |
|
| 130 | $template = 'filters'; |
|
| 131 | ||
| 132 | if ($rendererTemplate !== null) { |
|
| 133 | $this->renderer = new Renderer( |
|
| 134 | $this->twig, |
|
| 135 | $this->actionRenderer, |
|
| 136 | $this->columnRenderer, |
|
| 137 | $this->sorterRenderer, |
|
| 138 | [$template => $rendererTemplate] |
|
| 139 | ); |
|
| 140 | } |
|
| 141 | ||
| 142 | $view = $this->createGridViewMock(); |
|
| 143 | $view |
|
| 144 | ->expects($this->once()) |
|
| 145 | ->method('getDefinition') |
|
| 146 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
| 147 | ||
| 148 | $grid |
|
| 149 | ->expects($this->once()) |
|
| 150 | ->method('hasOption') |
|
| 151 | ->with($this->identicalTo($option = $template.'_template')) |
|
| 152 | ->will($this->returnValue($gridTemplate !== null)); |
|
| 153 | ||
| 154 | $grid |
|
| 155 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
| 156 | ->method('getOption') |
|
| 157 | ->with($this->identicalTo($option)) |
|
| 158 | ->will($this->returnValue($gridTemplate)); |
|
| 159 | ||
| 160 | $this->twig |
|
| 161 | ->expects($this->once()) |
|
| 162 | ->method('render') |
|
| 163 | ->with( |
|
| 164 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
| 165 | $this->identicalTo(['grid' => $view]) |
|
| 166 | ) |
|
| 167 | ->will($this->returnValue($result = 'result')); |
|
| 168 | ||
| 169 | $this->assertSame($result, $this->renderer->renderFilters($view)); |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * @dataProvider renderProvider |
|
| @@ 175-217 (lines=43) @@ | ||
| 172 | /** |
|
| 173 | * @dataProvider renderProvider |
|
| 174 | */ |
|
| 175 | public function testRenderGrid($gridTemplate = null, $rendererTemplate = null) |
|
| 176 | { |
|
| 177 | $template = 'body'; |
|
| 178 | ||
| 179 | if ($rendererTemplate !== null) { |
|
| 180 | $this->renderer = new Renderer( |
|
| 181 | $this->twig, |
|
| 182 | $this->actionRenderer, |
|
| 183 | $this->columnRenderer, |
|
| 184 | $this->sorterRenderer, |
|
| 185 | [$template => $rendererTemplate] |
|
| 186 | ); |
|
| 187 | } |
|
| 188 | ||
| 189 | $view = $this->createGridViewMock(); |
|
| 190 | $view |
|
| 191 | ->expects($this->once()) |
|
| 192 | ->method('getDefinition') |
|
| 193 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
| 194 | ||
| 195 | $grid |
|
| 196 | ->expects($this->once()) |
|
| 197 | ->method('hasOption') |
|
| 198 | ->with($this->identicalTo($option = $template.'_template')) |
|
| 199 | ->will($this->returnValue($gridTemplate !== null)); |
|
| 200 | ||
| 201 | $grid |
|
| 202 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
| 203 | ->method('getOption') |
|
| 204 | ->with($this->identicalTo($option)) |
|
| 205 | ->will($this->returnValue($gridTemplate)); |
|
| 206 | ||
| 207 | $this->twig |
|
| 208 | ->expects($this->once()) |
|
| 209 | ->method('render') |
|
| 210 | ->with( |
|
| 211 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
| 212 | $this->identicalTo(['grid' => $view]) |
|
| 213 | ) |
|
| 214 | ->will($this->returnValue($result = 'result')); |
|
| 215 | ||
| 216 | $this->assertSame($result, $this->renderer->renderGrid($view)); |
|
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * @dataProvider renderProvider |
|
| @@ 284-329 (lines=46) @@ | ||
| 281 | /** |
|
| 282 | * @dataProvider renderProvider |
|
| 283 | */ |
|
| 284 | public function testRenderColumnSortings($gridTemplate = null, $rendererTemplate = null) |
|
| 285 | { |
|
| 286 | $template = 'column_sortings'; |
|
| 287 | ||
| 288 | if ($rendererTemplate !== null) { |
|
| 289 | $this->renderer = new Renderer( |
|
| 290 | $this->twig, |
|
| 291 | $this->actionRenderer, |
|
| 292 | $this->columnRenderer, |
|
| 293 | $this->sorterRenderer, |
|
| 294 | [$template => $rendererTemplate] |
|
| 295 | ); |
|
| 296 | } |
|
| 297 | ||
| 298 | $view = $this->createGridViewMock(); |
|
| 299 | $view |
|
| 300 | ->expects($this->once()) |
|
| 301 | ->method('getDefinition') |
|
| 302 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
| 303 | ||
| 304 | $grid |
|
| 305 | ->expects($this->once()) |
|
| 306 | ->method('hasOption') |
|
| 307 | ->with($this->identicalTo($option = $template.'_template')) |
|
| 308 | ->will($this->returnValue($gridTemplate !== null)); |
|
| 309 | ||
| 310 | $grid |
|
| 311 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
| 312 | ->method('getOption') |
|
| 313 | ->with($this->identicalTo($option)) |
|
| 314 | ->will($this->returnValue($gridTemplate)); |
|
| 315 | ||
| 316 | $this->twig |
|
| 317 | ->expects($this->once()) |
|
| 318 | ->method('render') |
|
| 319 | ->with( |
|
| 320 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
| 321 | $this->identicalTo([ |
|
| 322 | 'column' => $column = $this->createColumnMock(), |
|
| 323 | 'grid' => $view, |
|
| 324 | ]) |
|
| 325 | ) |
|
| 326 | ->will($this->returnValue($result = 'result')); |
|
| 327 | ||
| 328 | $this->assertSame($result, $this->renderer->renderColumnSortings($view, $column)); |
|
| 329 | } |
|
| 330 | ||
| 331 | /** |
|
| 332 | * @dataProvider renderProvider |
|
| @@ 397-442 (lines=46) @@ | ||
| 394 | /** |
|
| 395 | * @dataProvider renderProvider |
|
| 396 | */ |
|
| 397 | public function testRenderColumnActions($gridTemplate = null, $rendererTemplate = null) |
|
| 398 | { |
|
| 399 | $template = 'column_actions'; |
|
| 400 | ||
| 401 | if ($rendererTemplate !== null) { |
|
| 402 | $this->renderer = new Renderer( |
|
| 403 | $this->twig, |
|
| 404 | $this->actionRenderer, |
|
| 405 | $this->columnRenderer, |
|
| 406 | $this->sorterRenderer, |
|
| 407 | [$template => $rendererTemplate] |
|
| 408 | ); |
|
| 409 | } |
|
| 410 | ||
| 411 | $view = $this->createGridViewMock(); |
|
| 412 | $view |
|
| 413 | ->expects($this->once()) |
|
| 414 | ->method('getDefinition') |
|
| 415 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
| 416 | ||
| 417 | $grid |
|
| 418 | ->expects($this->once()) |
|
| 419 | ->method('hasOption') |
|
| 420 | ->with($this->identicalTo($option = $template.'_template')) |
|
| 421 | ->will($this->returnValue($gridTemplate !== null)); |
|
| 422 | ||
| 423 | $grid |
|
| 424 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
| 425 | ->method('getOption') |
|
| 426 | ->with($this->identicalTo($option)) |
|
| 427 | ->will($this->returnValue($gridTemplate)); |
|
| 428 | ||
| 429 | $this->twig |
|
| 430 | ->expects($this->once()) |
|
| 431 | ->method('render') |
|
| 432 | ->with( |
|
| 433 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
| 434 | $this->identicalTo([ |
|
| 435 | 'data' => $data = new \stdClass(), |
|
| 436 | 'grid' => $view, |
|
| 437 | ]) |
|
| 438 | ) |
|
| 439 | ->will($this->returnValue($result = 'result')); |
|
| 440 | ||
| 441 | $this->assertSame($result, $this->renderer->renderColumnActions($view, $data)); |
|
| 442 | } |
|
| 443 | ||
| 444 | /** |
|
| 445 | * @dataProvider renderProvider |
|
| @@ 509-551 (lines=43) @@ | ||
| 506 | /** |
|
| 507 | * @dataProvider renderProvider |
|
| 508 | */ |
|
| 509 | public function testRenderGlobalActions($gridTemplate = null, $rendererTemplate = null) |
|
| 510 | { |
|
| 511 | $template = 'global_actions'; |
|
| 512 | ||
| 513 | if ($rendererTemplate !== null) { |
|
| 514 | $this->renderer = new Renderer( |
|
| 515 | $this->twig, |
|
| 516 | $this->actionRenderer, |
|
| 517 | $this->columnRenderer, |
|
| 518 | $this->sorterRenderer, |
|
| 519 | [$template => $rendererTemplate] |
|
| 520 | ); |
|
| 521 | } |
|
| 522 | ||
| 523 | $view = $this->createGridViewMock(); |
|
| 524 | $view |
|
| 525 | ->expects($this->once()) |
|
| 526 | ->method('getDefinition') |
|
| 527 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
| 528 | ||
| 529 | $grid |
|
| 530 | ->expects($this->once()) |
|
| 531 | ->method('hasOption') |
|
| 532 | ->with($this->identicalTo($option = $template.'_template')) |
|
| 533 | ->will($this->returnValue($gridTemplate !== null)); |
|
| 534 | ||
| 535 | $grid |
|
| 536 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
| 537 | ->method('getOption') |
|
| 538 | ->with($this->identicalTo($option)) |
|
| 539 | ->will($this->returnValue($gridTemplate)); |
|
| 540 | ||
| 541 | $this->twig |
|
| 542 | ->expects($this->once()) |
|
| 543 | ->method('render') |
|
| 544 | ->with( |
|
| 545 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
| 546 | $this->identicalTo(['grid' => $view]) |
|
| 547 | ) |
|
| 548 | ->will($this->returnValue($result = 'result')); |
|
| 549 | ||
| 550 | $this->assertSame($result, $this->renderer->renderGlobalActions($view)); |
|
| 551 | } |
|
| 552 | ||
| 553 | /** |
|
| 554 | * @dataProvider renderProvider |
|