Skip to content

Commit 5fa214c

Browse files
committed
add environment assertions trait and tests
1 parent 7afd4df commit 5fa214c

File tree

6 files changed

+674
-50
lines changed

6 files changed

+674
-50
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
},
7171
"autoload-dev": {
7272
"psr-4": {
73-
"App\\Tests\\": "tests/"
73+
"App\\Tests\\": "tests/",
74+
"Codeception\\Module\\Symfony\\": "tests/Support/Codeception/Module/Symfony/"
7475
}
7576
},
7677
"replace": {

composer.lock

Lines changed: 51 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Functional.suite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ modules:
99
- Doctrine:
1010
depends: Symfony
1111
cleanup: true
12+
- App\Tests\Support\Helper\Environment
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Tests\Functional;
6+
7+
use App\Tests\Support\FunctionalTester;
8+
9+
class EnvironmentAssertionsCest
10+
{
11+
public function _before(): void
12+
{
13+
@mkdir(codecept_root_dir() . 'var/log', 0777, true);
14+
@mkdir(codecept_root_dir() . 'var/sessions/test', 0777, true);
15+
}
16+
17+
public function phpEnvironmentAssertions(FunctionalTester $I): void
18+
{
19+
$I->assertPhpVersion('>=', '8.2');
20+
$I->assertPhpExtensionLoaded('json');
21+
$I->assertRequiredExtensionsAreLoaded();
22+
$I->assertComposerDependenciesSynchronized();
23+
$I->assertPhpDefaultTimezoneIs('UTC');
24+
}
25+
26+
public function symfonyKernelAssertions(FunctionalTester $I): void
27+
{
28+
$I->assertKernelEnvironment('test');
29+
$I->assertDebugModeIsEnabled();
30+
$I->assertSymfonyVersion('>=', '7.3');
31+
$I->assertAppEnvAndDebugMatchKernel();
32+
$I->assertAppCacheIsWritable();
33+
$I->assertProjectStructureIsSane();
34+
}
35+
36+
public function serviceAndBundleAssertions(FunctionalTester $I): void
37+
{
38+
$I->assertBundleIsEnabled(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class);
39+
}
40+
41+
public function securityAssertions(FunctionalTester $I): void
42+
{
43+
$I->assertFirewallIsActive('main');
44+
}
45+
46+
public function doctrineAssertions(FunctionalTester $I): void
47+
{
48+
$I->assertDoctrineDatabaseIsUp();
49+
$I->assertDoctrineEntityManagerExists();
50+
$I->assertDoctrineConnectionExists();
51+
}
52+
53+
public function otherComponentAssertions(FunctionalTester $I): void
54+
{
55+
$I->assertSessionSavePathIsWritable();
56+
$I->assertKernelCharsetIs('UTF-8');
57+
}
58+
}

0 commit comments

Comments
 (0)