|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Knp\RadBundle\Twig; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
|
|
7
|
|
|
class LinkAttributesExtensionSpec extends ObjectBehavior |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @param Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface $csrfProvider |
|
11
|
|
|
*/ |
|
12
|
|
|
function let($csrfProvider) |
|
13
|
|
|
{ |
|
14
|
|
|
$csrfProvider->generateCsrfToken('link')->willReturn('some token'); |
|
15
|
|
|
|
|
16
|
|
|
$this->beConstructedWith($csrfProvider); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
function it_should_be_a_twig_extension() |
|
|
|
|
|
|
20
|
|
|
{ |
|
21
|
|
|
$this->shouldHaveType('Twig_Extension'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function it_should_have_a_name() |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
$this->getName()->shouldReturn('link_attributes'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function it_should_have_the_csrf_attribute_function() |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$this->getFunctions()->shouldHaveCount(2); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_delete_method_with_default_confirmation_message() |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
$this->getLinkAttributes('delete')->shouldReturn('data-method="delete" data-confirm="Are you sure?" data-csrf-token="some token"'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_delete_method_with_a_specified_confirmation_message() |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
$this->getLinkAttributes('delete', 'a confirmation message')->shouldReturn('data-method="delete" data-confirm="a confirmation message" data-csrf-token="some token"'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_delete_method_with_no_confirmation_attribute() |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
$this->getLinkAttributes('delete', false)->shouldReturn('data-method="delete" data-no-confirm data-csrf-token="some token"'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_post_method() |
|
|
|
|
|
|
50
|
|
|
{ |
|
51
|
|
|
$this->getLinkAttributes('post')->shouldReturn('data-method="post" data-confirm="Are you sure?" data-csrf-token="some token"'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_post_method_with_a_specified_confirmation_message() |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
$this->getLinkAttributes('post', 'Please confirm')->shouldReturn('data-method="post" data-confirm="Please confirm" data-csrf-token="some token"'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_put_method() |
|
|
|
|
|
|
60
|
|
|
{ |
|
61
|
|
|
$this->getLinkAttributes('put')->shouldReturn('data-method="put" data-confirm="Are you sure?" data-csrf-token="some token"'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_put_method_with_a_specified_confirmation_message() |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
$this->getLinkAttributes('put', 'Please confirm')->shouldReturn('data-method="put" data-confirm="Please confirm" data-csrf-token="some token"'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_patch_method() |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
$this->getLinkAttributes('patch')->shouldReturn('data-method="patch" data-confirm="Are you sure?" data-csrf-token="some token"'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_patch_method_with_a_specified_confirmation_message() |
|
|
|
|
|
|
75
|
|
|
{ |
|
76
|
|
|
$this->getLinkAttributes('patch', 'Please confirm')->shouldReturn('data-method="patch" data-confirm="Please confirm" data-csrf-token="some token"'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
function its_getLinkAttributes_should_return_html_attributes_for_specified_method_even_if_it_is_fancy() |
|
|
|
|
|
|
80
|
|
|
{ |
|
81
|
|
|
$this->getLinkAttributes('fancy', 'Please confirm')->shouldReturn('data-method="fancy" data-confirm="Please confirm" data-csrf-token="some token"'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|