Skip to content

Symfony 6 Support: Form and Session Assertions #158

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 3 commits into from
May 27, 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
14 changes: 11 additions & 3 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.*", "6.0.*"]

steps:
- name: Checkout code
Expand All @@ -29,15 +29,23 @@ jobs:
with:
repository: Codeception/symfony-module-tests
path: framework-tests
ref: 4.4_codecept5
ref: "4.4_codecept5"

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

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

- name: Get composer cache directory
id: composer-cache
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 @@ -50,7 +50,7 @@ public function seeFormErrorMessage(string $field, ?string $message = null): voi
{
$formCollector = $this->grabFormCollector(__FUNCTION__);

if (!$forms = $formCollector->getData()->getValue('forms')['forms']) {
if (!$forms = $formCollector->getData()->getValue(true)['forms']) {
$this->fail('There are no forms on the current page.');
}

Expand Down
14 changes: 8 additions & 6 deletions src/Codeception/Module/Symfony/SessionAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ public function dontSeeInSession(string $attribute, $value = null): void
{
$session = $this->getCurrentSession();

if (null === $value) {
if ($session->has($attribute)) {
$this->fail("Session attribute with name '{$attribute}' does exist");
}
} else {
if ($attributeExists = $session->has($attribute)) {
$this->fail("Session attribute with name '{$attribute}' does exist");
}
$this->assertFalse($attributeExists);

if (null !== $value) {
$this->assertNotSame($value, $session->get($attribute));
}
}
Expand Down Expand Up @@ -167,9 +168,10 @@ public function seeInSession(string $attribute, $value = null): void
{
$session = $this->getCurrentSession();

if (!$session->has($attribute)) {
if (!$attributeExists = $session->has($attribute)) {
$this->fail("No session attribute with name '{$attribute}'");
}
$this->assertTrue($attributeExists);

if (null !== $value) {
$this->assertSame($value, $session->get($attribute));
Expand Down