Skip to content

Commit

Permalink
Update test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Aug 8, 2024
1 parent d03c5dd commit ff93ad6
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 56 deletions.
4 changes: 4 additions & 0 deletions Tests/Application/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ framework:
messenger:
transports:
routing:

twig:
paths:
- '%kernel.project_dir%/templates'
2 changes: 1 addition & 1 deletion Tests/Application/config/templates/articles/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<key>article</key>

<view>templates/articles/article</view>
<view>views/articles/article</view>
<controller>Sulu\Bundle\ContentBundle\Content\UserInterface\Controller\Website\ContentController::indexAction</controller>
<cacheLifetime>604800</cacheLifetime>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% block content %}
<h1>{{ content.title }}</h1>

{{ content.article|raw }}
{{ content.description|raw }}
{% endblock %}
29 changes: 15 additions & 14 deletions Tests/Functional/Integration/ArticleControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function setUp(): void
);
}

public function testPostPublish(): int
public function testPostPublish(): string
{
self::purgeDatabase();
self::initPhpcr();
Expand All @@ -49,7 +49,8 @@ public function testPostPublish(): int
'title' => 'Test Article',
'url' => '/my-article',
'published' => '2020-05-08T00:00:00+00:00', // Should be ignored
'images' => null,
'description' => null,
'image' => null,
'seoTitle' => 'Seo Title',
'seoDescription' => 'Seo Description',
'seoCanonicalUrl' => 'https://sulu.io/',
Expand All @@ -71,7 +72,7 @@ public function testPostPublish(): int

$response = $this->client->getResponse();
$content = \json_decode((string) $response->getContent(), true);
/** @var int $id */
/** @var string $id */
$id = $content['id'] ?? null; // @phpstan-ignore-line

$this->assertResponseSnapshot('article_post_publish.json', $response, 201);
Expand All @@ -86,15 +87,15 @@ public function testPostPublish(): int
$this->assertHttpStatusCode(200, $response);
$content = $response->getContent();
$this->assertIsString($content);
$this->assertStringContainsString('EXAMPLE 2 TEMPLATE', $content);
$this->assertStringContainsString('Test Article', $content);

return $id;
}

/**
* @depends testPostPublish
*/
public function testPostTriggerUnpublish(int $id): void
public function testPostTriggerUnpublish(string $id): void
{
$this->client->request('POST', '/admin/api/articles/' . $id . '?locale=en&action=unpublish');

Expand All @@ -111,7 +112,7 @@ public function testPostTriggerUnpublish(int $id): void
$this->assertHttpStatusCode(404, $response);
}

public function testPost(): int
public function testPost(): string
{
self::purgeDatabase();

Expand Down Expand Up @@ -145,7 +146,7 @@ public function testPost(): int
$routeRepository = $this->getContainer()->get('sulu.repository.route');
$this->assertCount(0, $routeRepository->findAll());

/** @var int $id */
/** @var string $id */
$id = \json_decode((string) $response->getContent(), true)['id'] ?? null; // @phpstan-ignore-line

return $id;
Expand All @@ -154,7 +155,7 @@ public function testPost(): int
/**
* @depends testPost
*/
public function testGet(int $id): void
public function testGet(string $id): void
{
$this->client->request('GET', '/admin/api/articles/' . $id . '?locale=en');
$response = $this->client->getResponse();
Expand All @@ -172,7 +173,7 @@ public function testGet(int $id): void
/**
* @depends testPost
*/
public function testGetGhostLocale(int $id): void
public function testGetGhostLocale(string $id): void
{
$this->client->request('GET', '/admin/api/articles/' . $id . '?locale=de');
$response = $this->client->getResponse();
Expand All @@ -190,7 +191,7 @@ public function testGetGhostLocale(int $id): void
/**
* @depends testPost
*/
public function testPostTriggerCopyLocale(int $id): void
public function testPostTriggerCopyLocale(string $id): void
{
$this->client->request('POST', '/admin/api/articles/' . $id . '?locale=de&action=copy-locale&src=en&dest=de');

Expand All @@ -203,13 +204,13 @@ public function testPostTriggerCopyLocale(int $id): void
* @depends testPost
* @depends testGet
*/
public function testPut(int $id): void
public function testPut(string $id): void
{
$this->client->request('PUT', '/admin/api/articles/' . $id . '?locale=en', [], [], [], \json_encode([
'template' => 'article',
'title' => 'Test Article 2',
'url' => '/my-article-2',
'article' => '<p>Test Article 2</p>',
'description' => '<p>Test Article 2</p>',
'seoTitle' => 'Seo Title 2',
'seoDescription' => 'Seo Description 2',
'seoCanonicalUrl' => 'https://sulu.io/2',
Expand All @@ -225,7 +226,7 @@ public function testPut(int $id): void
'excerptIcon' => null,
'excerptMedia' => null,
'authored' => '2020-06-09T00:00:00+00:00',
'mainWebspace' => 'sulu-io2',
'mainWebspace' => 'sulu-io',
]) ?: null);

$response = $this->client->getResponse();
Expand All @@ -252,7 +253,7 @@ public function testGetList(): void
* @depends testPost
* @depends testGetList
*/
public function testDelete(int $id): void
public function testDelete(string $id): void
{
$this->client->request('DELETE', '/admin/api/articles/' . $id . '?locale=en');
$response = $this->client->getResponse();
Expand Down
11 changes: 8 additions & 3 deletions Tests/Functional/Integration/responses/article_cget.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"_embedded": {
"examples": [
"articles": [
{
"id": "@integer@",
"title": "Test Example 2"
"author": null,
"changed": "@datetime@",
"changer": "Max Mustermann",
"created": "@datetime@",
"creator": "Max Mustermann",
"id": "@string@",
"title": "Test Article 2"
}
]
},
Expand Down
11 changes: 6 additions & 5 deletions Tests/Functional/Integration/responses/article_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"contentLocales": [
"en"
],
"description": null,
"excerptCategories": [],
"excerptDescription": "Excerpt Description",
"excerptIcon": null,
Expand All @@ -18,8 +19,8 @@
],
"excerptTitle": "Excerpt Title",
"ghostLocale": "en",
"id": "@integer@",
"images": null,
"id": "@string@",
"image": null,
"mainWebspace": "sulu-io",
"locale": "en",
"published": null,
Expand All @@ -35,8 +36,8 @@
"shadowLocales": [],
"shadowOn": false,
"stage": "draft",
"template": "example-2",
"title": "Test Example",
"url": "/my-example",
"template": "article",
"title": "Test Article",
"url": "/my-article",
"workflowPlace": "unpublished"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"excerptTags": [],
"excerptTitle":null,
"ghostLocale": "en",
"id": "@integer@",
"id": "@string@",
"locale": null,
"mainWebspace": null,
"published": null,
Expand Down
11 changes: 6 additions & 5 deletions Tests/Functional/Integration/responses/article_post.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"contentLocales": [
"en"
],
"description": null,
"excerptCategories": [],
"excerptDescription": "Excerpt Description",
"excerptIcon": null,
Expand All @@ -18,8 +19,8 @@
],
"excerptTitle": "Excerpt Title",
"ghostLocale": "en",
"id": "@integer@",
"images": null,
"id": "@string@",
"image": null,
"locale": "en",
"published": null,
"publishedState": false,
Expand All @@ -34,9 +35,9 @@
"shadowLocales": [],
"shadowOn": false,
"stage": "draft",
"template": "example-2",
"title": "Test Example",
"url": "/my-example",
"template": "article",
"title": "Test Article",
"url": "/my-article",
"workflowPlace": "unpublished",
"mainWebspace": "sulu-io"
}
11 changes: 6 additions & 5 deletions Tests/Functional/Integration/responses/article_post_publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"contentLocales": [
"en"
],
"description": null,
"excerptCategories": [],
"excerptDescription": "Excerpt Description",
"excerptIcon": null,
Expand All @@ -18,8 +19,8 @@
],
"excerptTitle": "Excerpt Title",
"ghostLocale": "en",
"id": "@integer@",
"images": null,
"id": "@string@",
"image": null,
"locale": "en",
"published": "@[email protected]()",
"publishedState": true,
Expand All @@ -34,9 +35,9 @@
"shadowLocales": [],
"shadowOn": false,
"stage": "draft",
"template": "example-2",
"title": "Test Example",
"url": "/my-example",
"template": "article",
"title": "Test Article",
"url": "/my-article",
"workflowPlace": "published",
"mainWebspace": "sulu-io"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"en",
"de"
],
"description": null,
"excerptCategories": [],
"excerptDescription": "Excerpt Description",
"excerptIcon": null,
Expand All @@ -20,8 +21,8 @@
],
"excerptTitle": "Excerpt Title",
"ghostLocale": "en",
"id": "@integer@",
"images": null,
"id": "@string@",
"image": null,
"locale": "de",
"mainWebspace": "sulu-io",
"published": null,
Expand All @@ -37,8 +38,8 @@
"shadowLocales": [],
"shadowOn": false,
"stage": "draft",
"template": "example-2",
"title": "Test Example",
"url": "/my-example",
"template": "article",
"title": "Test Article",
"url": "/my-article",
"workflowPlace": "unpublished"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"contentLocales": [
"en"
],
"description": null,
"excerptCategories": [],
"excerptDescription": "Excerpt Description",
"excerptIcon": null,
Expand All @@ -18,8 +19,8 @@
],
"excerptTitle": "Excerpt Title",
"ghostLocale": "en",
"id": "@integer@",
"images": null,
"id": "@string@",
"image": null,
"locale": "en",
"published": null,
"publishedState": false,
Expand All @@ -34,9 +35,9 @@
"shadowLocales": [],
"shadowOn": false,
"stage": "draft",
"template": "example-2",
"title": "Test Example",
"url": "\/my-example",
"template": "article",
"title": "Test Article",
"url": "\/my-article",
"workflowPlace": "unpublished",
"mainWebspace": "sulu-io"
}
14 changes: 6 additions & 8 deletions Tests/Functional/Integration/responses/article_put.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"author": null,
"authored": "2020-06-09T00:00:00+00:00",
"article": "<p>Test Article 2</p>",
"availableLocales": [
"en",
"de"
Expand All @@ -10,8 +9,7 @@
"en",
"de"
],
"blocks": null,
"description": null,
"description": "<p>Test Article 2</p>",
"excerptCategories": [],
"excerptDescription": "Excerpt Description 2",
"excerptIcon": null,
Expand All @@ -23,7 +21,7 @@
],
"excerptTitle": "Excerpt Title 2",
"ghostLocale": "en",
"id": "@integer@",
"id": "@string@",
"image": null,
"locale": "en",
"published": null,
Expand All @@ -39,9 +37,9 @@
"shadowLocales": [],
"shadowOn": false,
"stage": "draft",
"template": "default",
"title": "Test Example 2",
"url": "/my-example-2",
"template": "article",
"title": "Test Article 2",
"url": "/my-article-2",
"workflowPlace": "unpublished",
"mainWebspace": "sulu-io2"
"mainWebspace": "sulu-io"
}
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<php>
<ini name="error_reporting" value="-1" />
<ini name="date.timezone" value="UTC" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="APP_ENV" value="test" force="true"/>
<server name="KERNEL_CLASS" value="Sulu\Article\Tests\Application\Kernel"/>
Expand Down
Loading

0 comments on commit ff93ad6

Please sign in to comment.