Skip to content

Commit

Permalink
moved test to install state
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 11, 2022
1 parent d6ac9f7 commit 1bc16d5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 36 deletions.
56 changes: 56 additions & 0 deletions tests/codeception/acceptance/Install/InstallStateCest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
<?php

use Faker\Factory;

/**
* Class InstallStateCest.
*
* @group install
*/
class InstallStateCest {

/**
* Faker service.
*
* @var \Faker\Generator
*/
protected $faker;

/**
* Test constructor.
*/
public function __construct() {
$this->faker = Factory::create();
}

/**
* Default content should be visible.
*/
Expand Down Expand Up @@ -103,4 +119,44 @@ public function testUnpublishedMenuItems(AcceptanceTester $I) {
$I->assertEquals('/unpublished-parent/child-page', $I->grabFromCurrentUrl());
}

/**
* Test fast 404 page.
*
* @group fast404
*/
public function testFast404(AcceptanceTester $I) {
$path = $this->faker->words(2, TRUE);
$path = preg_replace('/[^a-z]/', '-', strtolower($path));
$I->amOnPage($path);
$I->canSeeResponseCodeIs(404);

$redirect_source = $this->faker->words(2, TRUE);
$redirect_source = preg_replace('/[^a-z]/', '-', strtolower($redirect_source));

$node = $I->createEntity([
'type' => 'hs_basic_page',
'title' => $this->faker->words(3, TRUE),
]);

$I->createEntity([
'redirect_source' => [
[
'path' => $redirect_source,
'query' => [],
],
],
'redirect_redirect' => [
[
'uri' => 'internal:/node/' . $node->id(),
'options' => [],
],
],
'status_code' => 301,
], 'redirect');
$I->amOnPage($redirect_source);

$I->canSeeResponseCodeIs(200);
$I->canSeeInCurrentUrl($node->toUrl()->toString());
}

}
36 changes: 0 additions & 36 deletions tests/codeception/acceptance/MenuItemsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,42 +120,6 @@ public function testPathAuto(AcceptanceTester $I) {
$I->canSeeInCurrentUrl('/foo-bar/');
}

/**
* Test fast 404 page.
*
* @group fast404
*/
public function testFast404(AcceptanceTester $I) {
$path = $this->faker->words(2, TRUE);
$path = preg_replace('/[^a-z]/', '-', strtolower($path));
$I->amOnPage($path);
$I->canSeeResponseCodeIs(404);

$redirect_source = $this->faker->words(2, TRUE);
$redirect_source = preg_replace('/[^a-z]/', '-', strtolower($redirect_source));

$node = $I->createEntity([
'type' => 'hs_basic_page',
'title' => $this->faker->words(3, TRUE),
]);

$I->createEntity([
'redirect_source' => [[
'path' => $redirect_source,
'query' => [],
]],
'redirect_redirect' => [[
'uri' => 'internal:/node/' . $node->id(),
'options' => [],
]],
'status_code' => 301,
], 'redirect');
$I->amOnPage($redirect_source);

$I->canSeeResponseCodeIs(200);
$I->canSeeInCurrentUrl($node->toUrl()->toString());
}

/**
* Get all relative url paths to test.
*
Expand Down

0 comments on commit 1bc16d5

Please sign in to comment.