From 9b5544beaf0cfeef90710855875d548dba836227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 30 Nov 2015 22:10:04 +0100 Subject: [PATCH] create test for custom fields group complete scenario a deps is added on the bundle "person" in order to make test working. --- .../CustomFieldsGroupControllerTest.php | 67 +++++++++++++++++++ .../CustomFieldsGroupControllerTest_TODO.php | 55 --------------- Tests/Fixtures/App/app/AppKernel.php | 3 +- composer.json | 10 ++- 4 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 Tests/Controller/CustomFieldsGroupControllerTest.php delete mode 100644 Tests/Controller/CustomFieldsGroupControllerTest_TODO.php diff --git a/Tests/Controller/CustomFieldsGroupControllerTest.php b/Tests/Controller/CustomFieldsGroupControllerTest.php new file mode 100644 index 000000000..920e02986 --- /dev/null +++ b/Tests/Controller/CustomFieldsGroupControllerTest.php @@ -0,0 +1,67 @@ + 'test_customizable_entities_test_not_empty_config')); + // Create a new client to browse the application + $client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'admin', + 'PHP_AUTH_PW' => 'olala', + )); + + //create the entity + $this->createCustomFieldsGroup($client); + + // Edit the entity + $this->editCustomFieldsGroup($client); + } + + private function createCustomFieldsGroup(Client &$client) + { + // Create a new entry in the database + $crawler = $client->request('GET', '/fr/admin/customfieldsgroup/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), + "Unexpected HTTP status code for GET /customfieldsgroup/"); + + $crawler = $client->click($crawler->selectLink('Créer un nouveau groupe')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Créer')->form(array( + 'custom_fields_group[name][fr]' => 'Test', + 'custom_fields_group[entity]' => 'Chill\PersonBundle\Entity\Person' + )); + + $crawler = $client->submit($form); + + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), + 'Missing element td:contains("Test")'); + } + + private function editCustomFieldsGroup(Client $client) + { + $crawler = $client->request('GET', '/fr/admin/customfieldsgroup/'); + $crawler = $client->click($crawler->selectLink('modifier')->link()); + fwrite(STDOUT, $crawler->text()); + $form = $crawler->selectButton('Update')->form(array( + 'custom_fields_group[name][fr]' => 'Foo', + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), + 'Missing element [value="Foo"]'); + } +} diff --git a/Tests/Controller/CustomFieldsGroupControllerTest_TODO.php b/Tests/Controller/CustomFieldsGroupControllerTest_TODO.php deleted file mode 100644 index afa7bad25..000000000 --- a/Tests/Controller/CustomFieldsGroupControllerTest_TODO.php +++ /dev/null @@ -1,55 +0,0 @@ -request('GET', '/customfieldsgroup/'); - $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /customfieldsgroup/"); - $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); - - // Fill in the form and submit it - $form = $crawler->selectButton('Create')->form(array( - 'cl_customfieldsbundle_customfieldsgroup[field_name]' => 'Test', - // ... other fields to fill - )); - - $client->submit($form); - $crawler = $client->followRedirect(); - - // Check data in the show view - $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); - - // Edit the entity - $crawler = $client->click($crawler->selectLink('Edit')->link()); - - $form = $crawler->selectButton('Update')->form(array( - 'cl_customfieldsbundle_customfieldsgroup[field_name]' => 'Foo', - // ... other fields to fill - )); - - $client->submit($form); - $crawler = $client->followRedirect(); - - // Check the element contains an attribute with value equals "Foo" - $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); - - // Delete the entity - $client->submit($crawler->selectButton('Delete')->form()); - $crawler = $client->followRedirect(); - - // Check the entity has been delete on the list - $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); - } - - */ -} diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Tests/Fixtures/App/app/AppKernel.php index 59ec46bfa..d2e57ab94 100644 --- a/Tests/Fixtures/App/app/AppKernel.php +++ b/Tests/Fixtures/App/app/AppKernel.php @@ -17,7 +17,8 @@ class AppKernel extends Kernel new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new \Chill\MainBundle\ChillMainBundle, new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), - new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle() + new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), + new Chill\PersonBundle\ChillPersonBundle(), #add here all the required bundle (some bundle are not required) ); } diff --git a/composer.json b/composer.json index af1c0c6b4..32c01e7f5 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "~5.5", - "symfony/symfony": "~2.7", + "symfony/symfony": "2.7.*", "doctrine/orm": "~2.4", "doctrine/dbal" : "~2.5", "doctrine/common": "~2.4", @@ -34,7 +34,8 @@ "chill-project/main": "dev-master" }, "require-dev": { - "doctrine/doctrine-fixtures-bundle": "~2.2@dev" + "doctrine/doctrine-fixtures-bundle": "~2.2@dev", + "chill-project/person": "dev-master@dev" }, "scripts": { "post-install-cmd": [ @@ -54,6 +55,9 @@ }, "extra": { "symfony-app-dir": "Tests/Fixtures/App/app", - "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations" + "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations", + "branch-alias": { + "dev-master": "fix_admin_interface-dev" + } } }