From b6f3fdbf2a6f103f8691ebd39c03867d97726b7e Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Wed, 30 Aug 2017 00:15:42 +0200 Subject: [PATCH] add tests for domaines et categories --- tests/Fixture/CategoriesFixture.php | 12 +++++++++++- tests/Fixture/SurCategoriesFixture.php | 6 +++++- tests/TestCase/Controller/SurCategoriesControllerTest.php | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100755 tests/TestCase/Controller/SurCategoriesControllerTest.php diff --git a/tests/Fixture/CategoriesFixture.php b/tests/Fixture/CategoriesFixture.php index 54d9215..feb4cf7 100755 --- a/tests/Fixture/CategoriesFixture.php +++ b/tests/Fixture/CategoriesFixture.php @@ -43,8 +43,18 @@ class CategoriesFixture extends TestFixture public $records = [ [ 'id' => 1, - 'nom' => 'Lorem ipsum dolor sit amet', + 'nom' => 'Categ1', 'sur_categorie_id' => 1 ], + [ + 'id' => 2, + 'nom' => 'Categ2', + 'sur_categorie_id' => 1 + ], + [ + 'id' => 3, + 'nom' => 'Categ3', + 'sur_categorie_id' => 2 + ], ]; } diff --git a/tests/Fixture/SurCategoriesFixture.php b/tests/Fixture/SurCategoriesFixture.php index 16f3665..d90b3a8 100755 --- a/tests/Fixture/SurCategoriesFixture.php +++ b/tests/Fixture/SurCategoriesFixture.php @@ -38,7 +38,11 @@ class SurCategoriesFixture extends TestFixture public $records = [ [ 'id' => 1, - 'nom' => 'Lorem ipsum dolor sit amet' + 'nom' => 'Electronique' + ], + [ + 'id' => 2, + 'nom' => 'Optique' ], ]; } diff --git a/tests/TestCase/Controller/SurCategoriesControllerTest.php b/tests/TestCase/Controller/SurCategoriesControllerTest.php new file mode 100755 index 0000000..226708f --- /dev/null +++ b/tests/TestCase/Controller/SurCategoriesControllerTest.php @@ -0,0 +1,83 @@ +_testSurCategoriesReadAllAs('SUPER'); } + private function _testSurCategoriesReadAllAs($role) { + //$this->authUser(); + $this->authAs($role); + + $this->get('/sur-categories/index'); + $this->get('/sur-categories?sort=nom'); + $this->assertResponseOk(); + $this->assertResponseContains('Liste des domaines'); + $this->assertResponseContains('Electronique'); + $this->assertResponseContains('Optique'); + } + + public function testCategoriesReadAllAsSuperAdmin() { $this->_testCategoriesReadAllAs('SUPER'); } + private function _testCategoriesReadAllAs($role) { + //$this->authUser(); + $this->authAs($role); + + $this->get('/categories/index'); + $this->get('/categories?sort=nom'); + $this->assertResponseOk(); + $this->assertResponseContains('Liste des catégories'); + + $this->assertResponseContains('Categ1'); + $this->assertResponseContains('Electronique'); + + $this->assertResponseContains('Categ2'); + //$this->assertResponseContains('Electronique'); + + $this->assertResponseContains('Categ3'); + $this->assertResponseContains('Optique'); + } + +} -- libgit2 0.21.2