|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\GridBundle\Templating\Helper; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Component\Grid\Definition\Action; |
|
18
|
|
|
use Sylius\Component\Grid\Definition\Field; |
|
19
|
|
|
use Sylius\Component\Grid\Renderer\GridRendererInterface; |
|
20
|
|
|
use Sylius\Component\Grid\View\GridView; |
|
21
|
|
|
use Symfony\Component\Templating\Helper\Helper; |
|
22
|
|
|
use Symfony\Component\Templating\Helper\HelperInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
final class GridHelperSpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function let(GridRendererInterface $gridRenderer): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->beConstructedWith($gridRenderer); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_is_a_templating_helper(): void |
|
35
|
|
|
{ |
|
36
|
|
|
$this->shouldImplement(HelperInterface::class); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function it_extends_base_templating_helper(): void |
|
40
|
|
|
{ |
|
41
|
|
|
$this->shouldHaveType(Helper::class); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
function it_uses_grid_renderer_to_render_grid(GridRendererInterface $gridRenderer, GridView $gridView): void |
|
45
|
|
|
{ |
|
46
|
|
|
$gridRenderer->render($gridView, null)->willReturn('<html>Grid!</html>'); |
|
47
|
|
|
$this->renderGrid($gridView, null)->shouldReturn('<html>Grid!</html>'); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
function it_uses_grid_renderer_to_render_field(GridRendererInterface $gridRenderer, GridView $gridView, Field $field): void |
|
51
|
|
|
{ |
|
52
|
|
|
$gridRenderer->renderField($gridView, $field, 'foo')->willReturn('Value'); |
|
53
|
|
|
$this->renderField($gridView, $field, 'foo')->shouldReturn('Value'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
function it_uses_grid_renderer_to_render_action(GridRendererInterface $gridRenderer, GridView $gridView, Action $action): void |
|
57
|
|
|
{ |
|
58
|
|
|
$gridRenderer->renderAction($gridView, $action, null)->willReturn('<a href="#">Go go Gadget arms!</a>'); |
|
59
|
|
|
$this->renderAction($gridView, $action)->shouldReturn('<a href="#">Go go Gadget arms!</a>'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
function it_has_name(): void |
|
63
|
|
|
{ |
|
64
|
|
|
$this->getName()->shouldReturn('sylius_grid'); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|