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