Code Duplication    Length = 17-34 lines in 4 locations

eZ/Bundle/EzPublishRestBundle/Tests/Functional/ContentTypeTest.php 1 location

@@ 378-411 (lines=34) @@
375
     *
376
     * @return string The content type draft field definition href
377
     */
378
    public function testAddContentTypeDraftFieldDefinition($contentTypeDraftHref)
379
    {
380
        $body = <<< XML
381
<?xml version="1.0" encoding="UTF-8"?>
382
<FieldDefinition>
383
      <identifier>secondtext</identifier>
384
      <fieldType>ezstring</fieldType>
385
      <fieldGroup>content</fieldGroup>
386
      <position>1</position>
387
      <isTranslatable>true</isTranslatable>
388
      <isRequired>true</isRequired>
389
      <isInfoCollector>false</isInfoCollector>
390
      <defaultValue>Second text</defaultValue>
391
      <isSearchable>true</isSearchable>
392
      <names>
393
        <value languageCode="eng-GB">Second text</value>
394
      </names>
395
    </FieldDefinition>
396
XML;
397
398
        $request = $this->createHttpRequest(
399
            'POST',
400
            "$contentTypeDraftHref/fieldDefinitions",
401
            'FieldDefinitionCreate+xml',
402
            'FieldDefinition+json',
403
            $body
404
        );
405
        $response = $this->sendHttpRequest($request);
406
407
        self::assertHttpResponseCodeEquals($response, 201);
408
        self::assertHttpResponseHasHeader($response, 'Location');
409
410
        return $response->getHeader('Location')[0];
411
    }
412
413
    /**
414
     * @depends testCreateContentType

eZ/Bundle/EzPublishRestBundle/Tests/Functional/TrashTest.php 2 locations

@@ 83-99 (lines=17) @@
80
    /**
81
     * Covers MOVE /content/trash/{trashItemId} Destination:/content/locations/{locationPath}.
82
     */
83
    public function testRestoreTrashItemWithDestination()
84
    {
85
        $trashItemHref = $this->createTrashItem('testRestoreTrashItemWithDestination');
86
87
        $request = $this->createHttpRequest(
88
            'MOVE',
89
            $trashItemHref,
90
            '',
91
            '',
92
            '',
93
            ['Destination' => '/api/ezp/v2/content/locations/1/2']
94
        );
95
        $response = $this->sendHttpRequest($request);
96
97
        self::assertHttpResponseCodeEquals($response, 201);
98
        self::assertHttpResponseHasHeader($response, 'Location');
99
    }
100
101
    /**
102
     * Covers DELETE /content/trash.
@@ 153-170 (lines=18) @@
150
     *
151
     * @return string
152
     */
153
    private function sendLocationToTrash(string $contentHref): string
154
    {
155
        $trashRequest = $this->createHttpRequest(
156
            'MOVE',
157
            $contentHref,
158
            '',
159
            '',
160
            '',
161
            ['Destination' => '/api/ezp/v2/content/trash']
162
        );
163
        $response = $this->sendHttpRequest($trashRequest);
164
165
        self::assertHttpResponseCodeEquals($response, 201);
166
167
        $trashHref = $response->getHeader('Location')[0];
168
169
        return $trashHref;
170
    }
171
}
172

eZ/Bundle/EzPublishRestBundle/Tests/Functional/LocationTest.php 1 location

@@ 118-134 (lines=17) @@
115
     *
116
     * @return string the created location's href
117
     */
118
    public function testCopySubtree($locationHref)
119
    {
120
        $request = $this->createHttpRequest(
121
            'COPY',
122
            $locationHref,
123
            '',
124
            '',
125
            '',
126
            ['Destination' => '/api/ezp/v2/content/locations/1/43']
127
        );
128
        $response = $this->sendHttpRequest($request);
129
130
        self::assertHttpResponseCodeEquals($response, 201);
131
        self::assertHttpResponseHasHeader($response, 'Location');
132
133
        return $response->getHeader('Location')[0];
134
    }
135
136
    /**
137
     * Covers MOVE /content/locations/{locationPath}.