Commit b6f3fdbf2a6f103f8691ebd39c03867d97726b7e

Authored by Etienne Pallier
1 parent 7b6f5caa

add tests for domaines et categories

tests/Fixture/CategoriesFixture.php
... ... @@ -43,8 +43,18 @@ class CategoriesFixture extends TestFixture
43 43 public $records = [
44 44 [
45 45 'id' => 1,
46   - 'nom' => 'Lorem ipsum dolor sit amet',
  46 + 'nom' => 'Categ1',
47 47 'sur_categorie_id' => 1
48 48 ],
  49 + [
  50 + 'id' => 2,
  51 + 'nom' => 'Categ2',
  52 + 'sur_categorie_id' => 1
  53 + ],
  54 + [
  55 + 'id' => 3,
  56 + 'nom' => 'Categ3',
  57 + 'sur_categorie_id' => 2
  58 + ],
49 59 ];
50 60 }
... ...
tests/Fixture/SurCategoriesFixture.php
... ... @@ -38,7 +38,11 @@ class SurCategoriesFixture extends TestFixture
38 38 public $records = [
39 39 [
40 40 'id' => 1,
41   - 'nom' => 'Lorem ipsum dolor sit amet'
  41 + 'nom' => 'Electronique'
  42 + ],
  43 + [
  44 + 'id' => 2,
  45 + 'nom' => 'Optique'
42 46 ],
43 47 ];
44 48 }
... ...
tests/TestCase/Controller/SurCategoriesControllerTest.php 0 → 100755
... ... @@ -0,0 +1,83 @@
  1 +<?php
  2 +/**
  3 + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4 + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5 + *
  6 + * Licensed under The MIT License
  7 + * For full copyright and license information, please see the LICENSE.txt
  8 + * Redistributions of files must retain the above copyright notice
  9 + *
  10 + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11 + * @link http://cakephp.org CakePHP(tm) Project
  12 + * @since 1.2.0
  13 + * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14 + */
  15 +namespace App\Test\TestCase\Controller;
  16 +
  17 +use Cake\Core\Configure;
  18 +use Cake\TestSuite\IntegrationTestCase;
  19 +
  20 +/**
  21 + * PagesControllerTest class
  22 + */
  23 +//class PagesControllerTest extends IntegrationTestCase
  24 +class SurCategoriesControllerTest extends General
  25 +{
  26 + /**
  27 + * Fixtures
  28 + *
  29 + * @var array
  30 + */
  31 + public $fixtures = [
  32 + 'app.users',
  33 + 'app.configurations',
  34 + 'app.sur_categories',
  35 + 'app.categories',
  36 + 'app.sous_categories',
  37 + /*
  38 + 'app.groupes_thematiques',
  39 + 'app.groupes_metiers',
  40 + 'app.organismes',
  41 + 'app.sites',
  42 + 'app.documents',
  43 + 'app.type_suivis',
  44 + 'app.type_documents',
  45 + 'app.fournisseurs',
  46 + 'app.unites'
  47 + */
  48 + ];
  49 +
  50 + public function testSurCategoriesReadAllAsSuperAdmin() { $this->_testSurCategoriesReadAllAs('SUPER'); }
  51 + private function _testSurCategoriesReadAllAs($role) {
  52 + //$this->authUser();
  53 + $this->authAs($role);
  54 +
  55 + $this->get('/sur-categories/index');
  56 + $this->get('/sur-categories?sort=nom');
  57 + $this->assertResponseOk();
  58 + $this->assertResponseContains('Liste des domaines');
  59 + $this->assertResponseContains('Electronique');
  60 + $this->assertResponseContains('Optique');
  61 + }
  62 +
  63 + public function testCategoriesReadAllAsSuperAdmin() { $this->_testCategoriesReadAllAs('SUPER'); }
  64 + private function _testCategoriesReadAllAs($role) {
  65 + //$this->authUser();
  66 + $this->authAs($role);
  67 +
  68 + $this->get('/categories/index');
  69 + $this->get('/categories?sort=nom');
  70 + $this->assertResponseOk();
  71 + $this->assertResponseContains('Liste des catégories');
  72 +
  73 + $this->assertResponseContains('Categ1');
  74 + $this->assertResponseContains('Electronique');
  75 +
  76 + $this->assertResponseContains('Categ2');
  77 + //$this->assertResponseContains('Electronique');
  78 +
  79 + $this->assertResponseContains('Categ3');
  80 + $this->assertResponseContains('Optique');
  81 + }
  82 +
  83 +}
... ...