Skip to content

Commit

Permalink
[7.1] EZP-29048: Added follow-up fixes for new code (ezsystems#2303)
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Apr 6, 2018
1 parent 8f3aafb commit 05523c1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
Expand Up @@ -30,10 +30,10 @@ public function testHttpOptions(string $route, array $expectedMethods): void
);

self::assertHttpResponseCodeEquals($response, 200);
self::assertEquals(0, (int)($response->getHeader('Content-Length')));
self::assertEquals(0, (int)($response->getHeader('Content-Length')[0]));

self::assertHttpResponseHasHeader($response, 'Allow');
$actualMethods = explode(',', $response->getHeader('Allow'));
$actualMethods = explode(',', $response->getHeader('Allow')[0]);
self::assertEquals($expectedMethods, $actualMethods);
}

Expand Down
Expand Up @@ -248,12 +248,13 @@ private function createUrlAlias(string $locationHref, string $urlAlias): string
'POST',
'/api/ezp/v2/content/urlaliases',
'UrlAliasCreate+xml',
'UrlAlias+json'
'UrlAlias+json',
$xml
);
$request->setContent($xml);

$response = $this->sendHttpRequest($request);
$href = $response->getHeader('Location');

self::assertHttpResponseHasHeader($response, 'Location');
$href = $response->getHeader('Location')[0];
$this->addCreatedElement($href);

return $href;
Expand Down
39 changes: 27 additions & 12 deletions eZ/Bundle/EzPublishRestBundle/Tests/Functional/SearchViewTest.php
Expand Up @@ -44,10 +44,12 @@ protected function tearDown()
/**
* @dataProvider xmlProvider
* Covers POST with ContentQuery Logic on /api/ezp/v2/views.
*
* @param string $xmlQueryBody
* @param int $expectedCount
*/
public function testSimpleContentQuery(string $xmlQueryBody, int $expectedCount)
{
$request = $this->createHttpRequest('POST', '/api/ezp/v2/views', 'ViewInput+xml; version=1.1', 'ContentInfo+json');
$body = <<< XML
<?xml version="1.0" encoding="UTF-8"?>
<ViewInput>
Expand All @@ -62,12 +64,17 @@ public function testSimpleContentQuery(string $xmlQueryBody, int $expectedCount)
</ContentQuery>
</ViewInput>
XML;

$request->setContent($body);

$request = $this->createHttpRequest(
'POST',
'/api/ezp/v2/views',
'ViewInput+xml; version=1.1',
'ContentInfo+json',
$body
);
$response = $this->sendHttpRequest($request);

self::assertHttpResponseCodeEquals($response, 200);
$jsonResponse = json_decode($response->getContent());
$jsonResponse = json_decode($response->getBody());
self::assertEquals($expectedCount, $jsonResponse->View->Result->count);
}

Expand Down Expand Up @@ -130,17 +137,18 @@ private function createTestContentType(): string
'POST',
'/api/ezp/v2/content/typegroups/1/types?publish=true',
'ContentTypeCreate+xml',
'ContentType+json'
'ContentType+json',
$body
);
$request->setContent($body);
$response = $this->sendHttpRequest($request);

return $response->getHeader('Location');
self::assertHttpResponseHasHeader($response, 'Location');

return $response->getHeader('Location')[0];
}

private function createTestContentWithTags(string $name, array $tags): string
{
$request = $this->createHttpRequest('POST', '/api/ezp/v2/content/objects', 'ContentCreate+xml', 'ContentInfo+json');
$tagsString = implode(',', $tags);
$body = <<< XML
<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -173,10 +181,17 @@ private function createTestContentWithTags(string $name, array $tags): string
</fields>
</ContentCreate>
XML;
$request->setContent($body);

$request = $this->createHttpRequest(
'POST',
'/api/ezp/v2/content/objects',
'ContentCreate+xml',
'ContentInfo+json',
$body
);
$response = $this->sendHttpRequest($request);
$href = $response->getHeader('Location');

self::assertHttpResponseHasHeader($response, 'Location');
$href = $response->getHeader('Location')[0];
$this->sendHttpRequest(
$this->createHttpRequest('PUBLISH', "$href/versions/1")
);
Expand Down

0 comments on commit 05523c1

Please sign in to comment.