Advertisement
Arckios

Untitled

Mar 11th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. <?php
  2. namespace App\Test\TestCase\Controller;
  3.  
  4. use App\Controller\ServiceCategoriesController;
  5. use Cake\TestSuite\IntegrationTestCase;
  6. use Cake\ORM\TableRegistry;
  7. /**
  8. * App\Controller\ServiceCategoriesController Test Case
  9. */
  10. class ServiceCategoriesControllerTest extends IntegrationTestCase
  11. {
  12.  
  13. /**
  14. * Fixtures
  15. *
  16. * @var array
  17. */
  18. public $fixtures = [
  19. 'app.service_categories',
  20. 'app.enterprises',
  21. 'app.users',
  22. 'app.pictures',
  23. 'app.employees',
  24. 'app.employe_categories',
  25. 'app.products',
  26. 'app.product_categories',
  27. 'app.services',
  28. 'app.suppliers',
  29. 'app.supplier_categories'
  30. ];
  31.  
  32. public function SessionInit()
  33. {
  34. $this->session([
  35. 'Auth' => [
  36. 'User' =>[
  37. 'id' => 1,
  38. 'email' => 'Lorem ipsum dolor sit amet',
  39. 'password' => 'Lorem ipsum dolor sit amet'
  40. ]
  41. ]
  42. ]);
  43. }
  44.  
  45. public function TestData()
  46. {
  47. $dataCat = [
  48. 'name' => "tests",
  49. 'enterprise_id' => 1
  50. ];
  51.  
  52. $dataServ = [
  53. 'name' => "tests",
  54. 'price' => "100.00",
  55. 'service_category_id' => 3,
  56. 'Picture' => ['tmp_name' => 'tmp/tests/test.txt']
  57. ];
  58.  
  59. $this->post('/serviceCategories/add',$dataCat);
  60. $this->post('/Services/add/3',$dataServ);
  61. }
  62.  
  63. public function testServiceCategoriesDelete_10() //Destruction d'une catégorie de service
  64. {
  65. $this->SessionInit();
  66.  
  67. $this->post('/serviceCategories/delete/2');
  68.  
  69. $serviceCat = TableRegistry::get('serviceCategories');
  70. $query = $serviceCat->find('all');
  71. $this->assertEquals(1, $query->count());
  72. }
  73.  
  74. public function testServiceCategoriesDelete_28()
  75. {
  76. $this->SessionInit();
  77. $this->TestData();
  78.  
  79. $this->post('/serviceCategories/delete/3');
  80.  
  81. $serviceCat = TableRegistry::get('serviceCategories');
  82. $service = TableRegistry::get('services');
  83. $AllCat = $serviceCat->find('all');
  84. $AllServ = $service->find('all');
  85. $this->assertEquals(2, $AllCat->count());
  86. $this->assertEquals(1, $AllServ->count());
  87.  
  88. }
  89.  
  90. public function testServiceCategoriesDelete_29()
  91. {
  92. $this->SessionInit();
  93. $this->TestData();
  94.  
  95. $this->post('/serviceCategories/delete/3');
  96.  
  97. $serviceCat = TableRegistry::get('serviceCategories');
  98. $picture = TableRegistry::get('pictures');
  99. $AllCat = $serviceCat->find('all');
  100. $AllPic = $picture->find('all');
  101. $this->assertEquals(2, $AllCat->count());
  102. $this->assertEquals(1, $AllPic->count());
  103.  
  104. }
  105.  
  106. public function testServiceCategoriesDelete_25()
  107. {
  108. $this->SessionInit();
  109. $this->TestData();
  110. $this->get('/serviceCategories/view/3');
  111. $this->assertResponseContains("<p>Are You really sure you want to delete this record?</p>");
  112. }
  113.  
  114. public function testServiceCategoriesDelete_26()
  115. {
  116. $this->enableRetainFlashMessages();
  117. $this->SessionInit();
  118. $this->TestData();
  119. $this->get('/serviceCategories/view/3');
  120. $this->assertResponseContains('&quot;tests&quot;');
  121. }
  122.  
  123. public function testServiceCategoriesDelete_27()
  124. {
  125. $this->SessionInit();
  126. $this->TestData();
  127. $this->get('/serviceCategories/view/3');
  128. $this->assertResponseContains("confirm");
  129. }
  130.  
  131. public function testServiceCategoriesDelete_34_35()
  132. {
  133. $this->enableRetainFlashMessages();
  134. $this->SessionInit();
  135. $this->TestData();
  136. $this->post('/serviceCategories/delete/3');
  137. $this->assertSession('The service category has been deleted.', 'Flash.flash.0.message');
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement