Skip to content

Merge 3.0 to main #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
php: [8.0, 8.1]
symfony: [4.4, 5.4]
symfony: ["4.4.*", "5.4.*"]

steps:
- name: Checkout code
Expand All @@ -24,15 +24,15 @@ jobs:
coverage: none

- name: Checkout Symfony 4.4 Sample
if: matrix.symfony == 4.4
if: "matrix.symfony == '4.4.*'"
uses: actions/checkout@v2
with:
repository: Codeception/symfony-module-tests
path: framework-tests
ref: 4.4_codecept5

- name: Checkout Symfony 5.4 Sample
if: matrix.symfony == 5.4
if: "matrix.symfony == '5.4.*'"
uses: actions/checkout@v2
with:
repository: Codeception/symfony-module-tests
Expand Down Expand Up @@ -60,8 +60,8 @@ jobs:
composer require symfony/dom-crawler=${{ matrix.symfony }} --ignore-platform-req=php --no-update
composer require symfony/browser-kit=${{ matrix.symfony }} --ignore-platform-req=php --no-update
composer require vlucas/phpdotenv --ignore-platform-req=php --no-update
composer require codeception/module-asserts --ignore-platform-req=php --no-update
composer require codeception/module-doctrine2 --ignore-platform-req=php --no-update
composer require codeception/module-asserts="3.*" --ignore-platform-req=php --no-update
composer require codeception/module-doctrine2="3.*" --ignore-platform-req=php --no-update
composer install --prefer-dist --no-progress --ignore-platform-req=php --no-dev

- name: Validate composer.json and composer.lock
Expand All @@ -83,4 +83,4 @@ jobs:
- name: Run test suite
run: |
php vendor/bin/codecept build -c framework-tests
php vendor/bin/codecept run Functional -c framework-tests
php vendor/bin/codecept run Functional -c framework-tests
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
],
"minimum-stability": "dev",
"require": {
"php": "^7.4 | ^8.0",
"php": "^8.0",
"ext-json": "*",
"codeception/lib-innerbrowser": "^2.0 | *@dev",
"codeception/codeception": "^5.0.0-alpha1"
"codeception/lib-innerbrowser": "^3.1.1",
"codeception/codeception": "^5.0.0-RC1"
},
"require-dev": {
"codeception/module-asserts": "^2.0 | *@dev",
"codeception/module-doctrine2": "^2.0 | *@dev",
"codeception/module-asserts": "^3.0",
"codeception/module-doctrine2": "^3.0",
"doctrine/orm": "^2.10",
"symfony/form": "^4.4 | ^5.0",
"symfony/framework-bundle": "^4.4 | ^5.0",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A Codeception module for Symfony framework.
## Requirements

* `Symfony 4.4` or higher.
* `PHP 7.4` or higher.
* `PHP 8.0` or higher.

## Installation

Expand Down
15 changes: 9 additions & 6 deletions src/Codeception/Lib/Connector/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
namespace Codeception\Lib\Connector;

use InvalidArgumentException;
use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;
use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -28,9 +31,9 @@ class Symfony extends HttpKernelBrowser
/**
* Constructor.
*
* @param Kernel $kernel A booted HttpKernel instance
* @param array $services An injected services
* @param bool $rebootable
* @param Kernel $kernel A booted HttpKernel instance
* @param array $services An injected services
* @param bool $rebootable
*/
public function __construct(Kernel $kernel, array $services = [], bool $rebootable = true)
{
Expand Down Expand Up @@ -133,17 +136,17 @@ private function persistDoctrineConnections(): void
}

if ($this->container instanceof TestContainer) {
$reflectedTestContainer = new \ReflectionMethod($this->container, 'getPublicContainer');
$reflectedTestContainer = new ReflectionMethod($this->container, 'getPublicContainer');
$reflectedTestContainer->setAccessible(true);
$publicContainer = $reflectedTestContainer->invoke($this->container);
} else {
$publicContainer = $this->container;
}

$reflectedContainer = new \ReflectionClass($publicContainer);
$reflectedContainer = new ReflectionClass($publicContainer);
$reflectionTarget = $reflectedContainer->hasProperty('parameters') ? $publicContainer : $publicContainer->getParameterBag();

$reflectedParameters = new \ReflectionProperty($reflectionTarget, 'parameters');
$reflectedParameters = new ReflectionProperty($reflectionTarget, 'parameters');
$reflectedParameters->setAccessible(true);
$parameters = $reflectedParameters->getValue($reflectionTarget);
unset($parameters['doctrine.connections']);
Expand Down
7 changes: 2 additions & 5 deletions src/Codeception/Module/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ class Symfony extends Framework implements DoctrineProvider, PartedModule
*/
public ?AbstractBrowser $client = null;

/**
* @var array
*/
public $config = [
public array $config = [
'app_path' => 'app',
'kernel_class' => 'App\Kernel',
'environment' => 'test',
Expand Down Expand Up @@ -196,7 +193,7 @@ public function _initialize(): void
$maxNestingLevel = 200; // Symfony may have very long nesting level
$xdebugMaxLevelKey = 'xdebug.max_nesting_level';
if (ini_get($xdebugMaxLevelKey) < $maxNestingLevel) {
ini_set($xdebugMaxLevelKey, (string) $maxNestingLevel);
ini_set($xdebugMaxLevelKey, (string)$maxNestingLevel);
}

$this->kernel = new $this->kernelClass($this->config['environment'], $this->config['debug']);
Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function runSymfonyConsoleCommand(string $command, array $parameters = []
$this->assertSame(
$expectedExitCode,
$exitCode,
'Command did not exit with code '.$expectedExitCode
.' but with '.$exitCode.': '.$output
'Command did not exit with code ' . $expectedExitCode
. ' but with ' . $exitCode . ': ' . $output
);

return $output;
Expand Down
10 changes: 5 additions & 5 deletions src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ trait DoctrineAssertionsTrait
* $I->grabNumRecords('User::class', ['name' => 'davert']);
* ```
*
* @param string $entityClass The entity class
* @param array $criteria Optional query criteria
* @param string $entityClass The entity class
* @param array $criteria Optional query criteria
* @return int
*/
public function grabNumRecords(string $entityClass, array $criteria = []): int
Expand Down Expand Up @@ -59,7 +59,7 @@ public function grabNumRecords(string $entityClass, array $criteria = []): int
* @param object|string $mixed
* @return \Doctrine\ORM\EntityRepository|null
*/
public function grabRepository($mixed)
public function grabRepository($mixed): ?EntityRepository
{
$entityRepoClass = EntityRepository::class;
$isNotARepo = function () use ($mixed): void {
Expand All @@ -86,12 +86,12 @@ public function grabRepository($mixed)
return $getRepo();
}

if (!is_string($mixed) || !class_exists($mixed) ) {
if (!is_string($mixed) || !class_exists($mixed)) {
$isNotARepo();
return null;
}

if (is_subclass_of($mixed, $entityRepoClass)){
if (is_subclass_of($mixed, $entityRepoClass)) {
return $getRepo();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Symfony/EventsAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function assertEventNotTriggered(Data $data, array $expected): void
foreach ($expected as $expectedEvent) {
$expectedEvent = is_object($expectedEvent) ? get_class($expectedEvent) : $expectedEvent;
$this->assertFalse(
$this->eventWasTriggered($actual, (string) $expectedEvent),
$this->eventWasTriggered($actual, (string)$expectedEvent),
"The '{$expectedEvent}' event triggered"
);
}
Expand All @@ -142,7 +142,7 @@ protected function assertEventTriggered(Data $data, array $expected): void
foreach ($expected as $expectedEvent) {
$expectedEvent = is_object($expectedEvent) ? get_class($expectedEvent) : $expectedEvent;
$this->assertTrue(
$this->eventWasTriggered($actual, (string) $expectedEvent),
$this->eventWasTriggered($actual, (string)$expectedEvent),
"The '{$expectedEvent}' event did not trigger"
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/FormAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function dontSeeFormErrors(): void
{
$formCollector = $this->grabFormCollector(__FUNCTION__);

$errors = (int) $formCollector->getData()->offsetGet('nb_errors');
$errors = (int)$formCollector->getData()->offsetGet('nb_errors');

$this->assertSame(
0,
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/RouterAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function seeInCurrentRoute(string $routeName): void
$uri = explode('?', $this->grabFromCurrentUrl())[0];
$matchedRouteName = '';
try {
$matchedRouteName = (string) $router->match($uri)['_route'];
$matchedRouteName = (string)$router->match($uri)['_route'];
} catch (ResourceNotFoundException $e) {
$this->fail(sprintf('The "%s" url does not match with any route', $uri));
}
Expand Down
7 changes: 3 additions & 4 deletions src/Codeception/Module/Symfony/SessionAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function amLoggedInAs(UserInterface $user, string $firewallName = 'main',
}

if ($firewallContext) {
$session->set('_security_'.$firewallContext, serialize($token));
$session->set('_security_' . $firewallContext, serialize($token));
} else {
$session->set('_security_'.$firewallName, serialize($token));
$session->set('_security_' . $firewallName, serialize($token));
}

$session->save();
Expand Down Expand Up @@ -75,8 +75,7 @@ public function dontSeeInSession(string $attribute, $value = null): void
if ($session->has($attribute)) {
$this->fail("Session attribute with name '{$attribute}' does exist");
}
}
else {
} else {
$this->assertNotSame($value, $session->get($attribute));
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Codeception/Module/Symfony/TwigAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function dontSeeRenderedTemplate(string $template): void
{
$twigCollector = $this->grabTwigCollector(__FUNCTION__);

$templates = (array) $twigCollector->getTemplates();
$templates = (array)$twigCollector->getTemplates();

$this->assertArrayNotHasKey(
$template,
Expand All @@ -46,8 +46,8 @@ public function seeCurrentTemplateIs(string $expectedTemplate): void
{
$twigCollector = $this->grabTwigCollector(__FUNCTION__);

$templates = (array) $twigCollector->getTemplates();
$actualTemplate = (string) array_key_first($templates);
$templates = (array)$twigCollector->getTemplates();
$actualTemplate = (string)array_key_first($templates);

$this->assertSame(
$expectedTemplate,
Expand All @@ -72,7 +72,7 @@ public function seeRenderedTemplate(string $template): void
{
$twigCollector = $this->grabTwigCollector(__FUNCTION__);

$templates = (array) $twigCollector->getTemplates();
$templates = (array)$twigCollector->getTemplates();

$this->assertArrayHasKey(
$template,
Expand Down