Skip to content

Instantly share code, notes, and snippets.

@AlexandreGerault
Created February 7, 2023 19:44
Show Gist options
  • Save AlexandreGerault/3ba643211549c01ff32e05c9979d632b to your computer and use it in GitHub Desktop.
Save AlexandreGerault/3ba643211549c01ff32e05c9979d632b to your computer and use it in GitHub Desktop.
Confusing error with EasyAdmin integration test
class EditSchoolTest extends SchoolTestCase
{
use ResetDatabase;
public function testItEditsASchool(): void
{
$admin = $this->createAdmin();
$school = $this->createSchool();
$client = static::createClient();
$client->loginUser($admin->object());
$urlGenerator = $this->getAdminUrlGenerator();
$url = $urlGenerator
->setController(SchoolCrudController::class)
->setAction('edit')
->setEntityId($school->id)
->generateUrl();
$client->request('GET', $url);
self::assertResponseIsSuccessful();
$crawler = $client->getCrawler();
$form = $crawler->filter('form[name="School"]')->form();
$client->submit($form, [
'School' => [
'name' => 'New name',
'website' => 'https://new-website.com',
'region' => 'New region',
'department' => 'New department',
'city' => 'New city',
'address' => 'New address',
'isPublic' => '1',
'foundationDate' => '2020-01-01',
'shortDescription' => 'New short description',
'longDescription' => 'New long description',
]
]);
self::assertResponseRedirects();
$client->followRedirect();
self::assertResponseIsSuccessful();
SchoolFactory::assert()->exists([
'name' => 'New name',
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment