Skip to content
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

[DomCrawler] Add assertFormValue() in WebTestCase #38288

Merged
merged 1 commit into from Sep 24, 2020

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Sep 24, 2020

Q A
Branch? master for features
Bug fix? no
New feature? yes
Deprecations? no
Tickets
License MIT
Doc PR symfony/symfony-docs#...

Add new assertions for checking form values, to use in functional tests.

Example:

    public function testForm()
    {
        $this->visit('/edit-form');

        self::assertNoFormValue('#form', 'activateMembership'); // checkboxes don't have values when unchecked
        self::assertFormValue('#form', 'trialPeriod', '15');

        $this->client->submitForm('Save', [
            'activateMembership' => 'on',
            'trialPeriod' => '7',
        ]);

        self::assertResponseIsSuccessful();
        self::assertFormValue('#form', 'activateMembership', 'on');
        self::assertFormValue('#form', 'trialPeriod', '7');
    }

I resorted to using the ->form() API because:

fabpot
fabpot approved these changes Sep 24, 2020
fabpot
fabpot approved these changes Sep 24, 2020
@fabpot fabpot force-pushed the domcrawler/assert-form-value branch from b135c47 to c3e0336 Compare Sep 24, 2020
@fabpot
Copy link
Member

fabpot commented Sep 24, 2020

Thank you @mnapoli.

@fabpot fabpot merged commit 713f30e into symfony:master Sep 24, 2020
1 of 3 checks passed
@mnapoli mnapoli deleted the domcrawler/assert-form-value branch Sep 24, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
@fabpot fabpot mentioned this pull request Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants