Code Duplication    Length = 12-14 lines in 4 locations

eZ/Publish/Core/REST/Server/Tests/Input/Parser/ContentObjectStatesTest.php 1 location

@@ 75-88 (lines=14) @@
72
     * @expectedException \eZ\Publish\Core\REST\Common\Exceptions\Parser
73
     * @expectedExceptionMessage Missing '_href' attribute for ObjectState.
74
     */
75
    public function testParseExceptionOnMissingHref()
76
    {
77
        $inputArray = array(
78
            'ObjectState' => array(
79
                array(
80
                    '_href' => '/content/objectstategroups/42/objectstates/21',
81
                ),
82
                array(),
83
            ),
84
        );
85
86
        $objectState = $this->getParser();
87
        $objectState->parse($inputArray, $this->getParsingDispatcherMock());
88
    }
89
90
    public function getParseHrefExpectationsMap()
91
    {

eZ/Publish/Core/REST/Server/Tests/Input/Parser/Criterion/UserMetadataTest.php 3 locations

@@ 76-87 (lines=12) @@
73
     * @expectedException \eZ\Publish\Core\REST\Common\Exceptions\Parser
74
     * @expectedExceptionMessage Invalid <Target> format
75
     */
76
    public function testParseExceptionOnInvalidTargetFormat()
77
    {
78
        $inputArray = [
79
            'UserMetadataCriterion' => [
80
                'foo' => 'Mock around the clock',
81
                'Value' => 42,
82
            ],
83
        ];
84
85
        $dataKeyValueObjectClass = $this->getParser();
86
        $dataKeyValueObjectClass->parse($inputArray, $this->getParsingDispatcherMock());
87
    }
88
89
    /**
90
     * Test UserMetadata parser throwing exception on invalid value format.
@@ 95-106 (lines=12) @@
92
     * @expectedException \eZ\Publish\Core\REST\Common\Exceptions\Parser
93
     * @expectedExceptionMessage Invalid <Value> format
94
     */
95
    public function testParseExceptionOnInvalidValueFormat()
96
    {
97
        $inputArray = [
98
            'UserMetadataCriterion' => [
99
                'Target' => 'Moxette',
100
                'foo' => 42,
101
            ],
102
        ];
103
104
        $dataKeyValueObjectClass = $this->getParser();
105
        $dataKeyValueObjectClass->parse($inputArray, $this->getParsingDispatcherMock());
106
    }
107
108
    /**
109
     * Test UserMetadata parser throwing exception on wrong type of value format.
@@ 114-125 (lines=12) @@
111
     * @expectedException \eZ\Publish\Core\REST\Common\Exceptions\Parser
112
     * @expectedExceptionMessage Invalid <Value> format
113
     */
114
    public function testParseExceptionOnWrongValueType()
115
    {
116
        $inputArray = [
117
            'UserMetadataCriterion' => [
118
                'Target' => 'We will mock you',
119
                'Value' => new \stdClass(),
120
            ],
121
        ];
122
123
        $dataKeyValueObjectClass = $this->getParser();
124
        $dataKeyValueObjectClass->parse($inputArray, $this->getParsingDispatcherMock());
125
    }
126
127
    /**
128
     * Returns the UserMetadata criterion parser.