@@ 13-113 (lines=101) @@ | ||
10 | use Netgen\Bundle\OpenGraphBundle\Handler\FieldType\TextBlock; |
|
11 | use Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface; |
|
12 | ||
13 | class TextBlockTest extends HandlerBaseTest |
|
14 | { |
|
15 | /** |
|
16 | * @var TextBlock |
|
17 | */ |
|
18 | protected $textBlock; |
|
19 | ||
20 | public function setUp() |
|
21 | { |
|
22 | $this->fieldHelper = $this->getMockBuilder(FieldHelper::class) |
|
23 | ->disableOriginalConstructor() |
|
24 | ->setMethods(array('isFieldEmpty')) |
|
25 | ->getMock(); |
|
26 | ||
27 | $this->translationHelper = $this->getMockBuilder(TranslationHelper::class) |
|
28 | ->disableOriginalConstructor() |
|
29 | ->setMethods(array('getTranslatedField')) |
|
30 | ->getMock(); |
|
31 | ||
32 | $this->content = $this->getMockBuilder(Content::class) |
|
33 | ->disableOriginalConstructor() |
|
34 | ->setMethods(array()) |
|
35 | ->getMock(); |
|
36 | ||
37 | $this->textBlock = new TextBlock($this->fieldHelper, $this->translationHelper); |
|
38 | $this->textBlock->setContent($this->content); |
|
39 | ||
40 | $this->field = new Field(array('value' => new Value())); |
|
41 | } |
|
42 | ||
43 | public function testInstanceOfHandlerInterface() |
|
44 | { |
|
45 | $this->assertInstanceOf(HandlerInterface::class, $this->textBlock); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
50 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Field type handlers require at least a field identifier. |
|
51 | */ |
|
52 | public function testGettingTagsWithoutFieldIdentifier() |
|
53 | { |
|
54 | $this->textBlock->getMetaTags('some_tag', array()); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
59 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Field 'some_value' does not exist in content. |
|
60 | */ |
|
61 | public function testGettingTagsWithNonExistentField() |
|
62 | { |
|
63 | $this->translationHelper->expects($this->once()) |
|
64 | ->method('getTranslatedField') |
|
65 | ->willReturn(null); |
|
66 | ||
67 | $this->textBlock->getMetaTags('some_tag', array('some_value')); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
72 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Netgen\Bundle\OpenGraphBundle\Handler\FieldType\TextBlock field type handler does not support field with identifier ''. |
|
73 | */ |
|
74 | public function testGettingTagsWithUnsupportedField() |
|
75 | { |
|
76 | $this->translationHelper->expects($this->once()) |
|
77 | ->method('getTranslatedField') |
|
78 | ->willReturn(new Field()); |
|
79 | ||
80 | $this->textBlock->getMetaTags('some_tag', array('some_value')); |
|
81 | } |
|
82 | ||
83 | public function testGettingTagsWithEmptyField() |
|
84 | { |
|
85 | $this->translationHelper->expects($this->once()) |
|
86 | ->method('getTranslatedField') |
|
87 | ->willReturn($this->field); |
|
88 | ||
89 | $this->fieldHelper->expects($this->once()) |
|
90 | ->method('isFieldEmpty') |
|
91 | ->willReturn(true); |
|
92 | ||
93 | $this->textBlock->getMetaTags('some_tag', array('some_value')); |
|
94 | } |
|
95 | ||
96 | public function testGettingTags() |
|
97 | { |
|
98 | $this->translationHelper->expects($this->once()) |
|
99 | ->method('getTranslatedField') |
|
100 | ->willReturn($this->field); |
|
101 | ||
102 | $this->textBlock->getMetaTags('some_tag', array('some_value')); |
|
103 | } |
|
104 | ||
105 | public function testGettingTagsWithMultipleArgumentsInArray() |
|
106 | { |
|
107 | $this->translationHelper->expects($this->once()) |
|
108 | ->method('getTranslatedField') |
|
109 | ->willReturn($this->field); |
|
110 | ||
111 | $this->textBlock->getMetaTags('some_tag', array('some_value', 'some_value_2')); |
|
112 | } |
|
113 | } |
|
114 |
@@ 13-113 (lines=101) @@ | ||
10 | use Netgen\Bundle\OpenGraphBundle\Handler\FieldType\TextLine; |
|
11 | use Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface; |
|
12 | ||
13 | class TextLineTest extends HandlerBaseTest |
|
14 | { |
|
15 | /** |
|
16 | * @var TextLine |
|
17 | */ |
|
18 | protected $textLine; |
|
19 | ||
20 | public function setUp() |
|
21 | { |
|
22 | $this->fieldHelper = $this->getMockBuilder(FieldHelper::class) |
|
23 | ->disableOriginalConstructor() |
|
24 | ->setMethods(array('isFieldEmpty')) |
|
25 | ->getMock(); |
|
26 | ||
27 | $this->translationHelper = $this->getMockBuilder(TranslationHelper::class) |
|
28 | ->disableOriginalConstructor() |
|
29 | ->setMethods(array('getTranslatedField')) |
|
30 | ->getMock(); |
|
31 | ||
32 | $this->content = $this->getMockBuilder(Content::class) |
|
33 | ->disableOriginalConstructor() |
|
34 | ->setMethods(array()) |
|
35 | ->getMock(); |
|
36 | ||
37 | $this->textLine = new TextLine($this->fieldHelper, $this->translationHelper); |
|
38 | $this->textLine->setContent($this->content); |
|
39 | ||
40 | $this->field = new Field(array('value' => new Value())); |
|
41 | } |
|
42 | ||
43 | public function testInstanceOfHandlerInterface() |
|
44 | { |
|
45 | $this->assertInstanceOf(HandlerInterface::class, $this->textLine); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
50 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Field type handlers require at least a field identifier. |
|
51 | */ |
|
52 | public function testGettingTagsWithoutFieldIdentifier() |
|
53 | { |
|
54 | $this->textLine->getMetaTags('some_tag', array()); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
59 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Field 'some_value' does not exist in content. |
|
60 | */ |
|
61 | public function testGettingTagsWithNonExistentField() |
|
62 | { |
|
63 | $this->translationHelper->expects($this->once()) |
|
64 | ->method('getTranslatedField') |
|
65 | ->willReturn(null); |
|
66 | ||
67 | $this->textLine->getMetaTags('some_tag', array('some_value')); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
72 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Netgen\Bundle\OpenGraphBundle\Handler\FieldType\TextLine field type handler does not support field with identifier ''. |
|
73 | */ |
|
74 | public function testGettingTagsWithUnsupportedField() |
|
75 | { |
|
76 | $this->translationHelper->expects($this->once()) |
|
77 | ->method('getTranslatedField') |
|
78 | ->willReturn(new Field()); |
|
79 | ||
80 | $this->textLine->getMetaTags('some_tag', array('some_value')); |
|
81 | } |
|
82 | ||
83 | public function testGettingTagsWithEmptyField() |
|
84 | { |
|
85 | $this->translationHelper->expects($this->once()) |
|
86 | ->method('getTranslatedField') |
|
87 | ->willReturn($this->field); |
|
88 | ||
89 | $this->fieldHelper->expects($this->once()) |
|
90 | ->method('isFieldEmpty') |
|
91 | ->willReturn(true); |
|
92 | ||
93 | $this->textLine->getMetaTags('some_tag', array('some_value')); |
|
94 | } |
|
95 | ||
96 | public function testGettingTags() |
|
97 | { |
|
98 | $this->translationHelper->expects($this->once()) |
|
99 | ->method('getTranslatedField') |
|
100 | ->willReturn($this->field); |
|
101 | ||
102 | $this->textLine->getMetaTags('some_tag', array('some_value')); |
|
103 | } |
|
104 | ||
105 | public function testGettingTagsWithMultipleArgumentsInArray() |
|
106 | { |
|
107 | $this->translationHelper->expects($this->once()) |
|
108 | ->method('getTranslatedField') |
|
109 | ->willReturn($this->field); |
|
110 | ||
111 | $this->textLine->getMetaTags('some_tag', array('some_value', 'some_value_2')); |
|
112 | } |
|
113 | } |
|
114 |
@@ 13-113 (lines=101) @@ | ||
10 | use Netgen\Bundle\OpenGraphBundle\Handler\FieldType\XmlText; |
|
11 | use Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface; |
|
12 | ||
13 | class XmlTextTest extends HandlerBaseTest |
|
14 | { |
|
15 | /** |
|
16 | * @var XmlText |
|
17 | */ |
|
18 | protected $xmlText; |
|
19 | ||
20 | public function setUp() |
|
21 | { |
|
22 | $this->fieldHelper = $this->getMockBuilder(FieldHelper::class) |
|
23 | ->disableOriginalConstructor() |
|
24 | ->setMethods(array('isFieldEmpty')) |
|
25 | ->getMock(); |
|
26 | ||
27 | $this->translationHelper = $this->getMockBuilder(TranslationHelper::class) |
|
28 | ->disableOriginalConstructor() |
|
29 | ->setMethods(array('getTranslatedField')) |
|
30 | ->getMock(); |
|
31 | ||
32 | $this->content = $this->getMockBuilder(Content::class) |
|
33 | ->disableOriginalConstructor() |
|
34 | ->setMethods(array()) |
|
35 | ->getMock(); |
|
36 | ||
37 | $this->xmlText = new XmlText($this->fieldHelper, $this->translationHelper); |
|
38 | $this->xmlText->setContent($this->content); |
|
39 | ||
40 | $this->field = new Field(array('value' => new Value())); |
|
41 | } |
|
42 | ||
43 | public function testInstanceOfHandlerInterface() |
|
44 | { |
|
45 | $this->assertInstanceOf(HandlerInterface::class, $this->xmlText); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
50 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Field type handlers require at least a field identifier. |
|
51 | */ |
|
52 | public function testGettingTagsWithoutFieldIdentifier() |
|
53 | { |
|
54 | $this->xmlText->getMetaTags('some_tag', array()); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
59 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Field 'some_value' does not exist in content. |
|
60 | */ |
|
61 | public function testGettingTagsWithNonExistentField() |
|
62 | { |
|
63 | $this->translationHelper->expects($this->once()) |
|
64 | ->method('getTranslatedField') |
|
65 | ->willReturn(null); |
|
66 | ||
67 | $this->xmlText->getMetaTags('some_tag', array('some_value')); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
72 | * @expectedExceptionMessage Argument '$params[0]' is invalid: Netgen\Bundle\OpenGraphBundle\Handler\FieldType\XmlText field type handler does not support field with identifier ''. |
|
73 | */ |
|
74 | public function testGettingTagsWithUnsupportedField() |
|
75 | { |
|
76 | $this->translationHelper->expects($this->once()) |
|
77 | ->method('getTranslatedField') |
|
78 | ->willReturn(new Field()); |
|
79 | ||
80 | $this->xmlText->getMetaTags('some_tag', array('some_value')); |
|
81 | } |
|
82 | ||
83 | public function testGettingTagsWithEmptyField() |
|
84 | { |
|
85 | $this->translationHelper->expects($this->once()) |
|
86 | ->method('getTranslatedField') |
|
87 | ->willReturn($this->field); |
|
88 | ||
89 | $this->fieldHelper->expects($this->once()) |
|
90 | ->method('isFieldEmpty') |
|
91 | ->willReturn(true); |
|
92 | ||
93 | $this->xmlText->getMetaTags('some_tag', array('some_value')); |
|
94 | } |
|
95 | ||
96 | public function testGettingTags() |
|
97 | { |
|
98 | $this->translationHelper->expects($this->once()) |
|
99 | ->method('getTranslatedField') |
|
100 | ->willReturn($this->field); |
|
101 | ||
102 | $this->xmlText->getMetaTags('some_tag', array('some_value')); |
|
103 | } |
|
104 | ||
105 | public function testGettingTagsWithMultipleArgumentsInArray() |
|
106 | { |
|
107 | $this->translationHelper->expects($this->once()) |
|
108 | ->method('getTranslatedField') |
|
109 | ->willReturn($this->field); |
|
110 | ||
111 | $this->xmlText->getMetaTags('some_tag', array('some_value', 'some_value_2')); |
|
112 | } |
|
113 | } |
|
114 |