GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#9)
by Mario
01:45
created

TextLineTest::testInstanceOfHandlerInterface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Netgen\Bundle\OpenGraphBundle\Tests\Handler\FieldType;
4
5
use eZ\Publish\API\Repository\Values\Content\Field;
6
use eZ\Publish\Core\FieldType\TextLine\Value;
7
use eZ\Publish\Core\Helper\FieldHelper;
8
use eZ\Publish\Core\Helper\TranslationHelper;
9
use eZ\Publish\Core\Repository\Values\Content\Content;
10
use Netgen\Bundle\OpenGraphBundle\Handler\FieldType\TextLine;
11
use Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface;
12
13 View Code Duplication
class TextLineTest extends HandlerBaseTest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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);
0 ignored issues
show
Documentation introduced by
$this->fieldHelper is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<eZ\Publish\Core\Helper\FieldHelper>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$this->translationHelper is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<eZ\Publish\Core\Helper\TranslationHelper>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
        $this->textLine->setContent($this->content);
0 ignored issues
show
Documentation introduced by
$this->content is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<eZ\Publish\API\Re...Values\Content\Content>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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