Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Test\TestCase\Controller;
- use App\Controller\ServiceCategoriesController;
- use Cake\TestSuite\IntegrationTestCase;
- use Cake\ORM\TableRegistry;
- /**
- * App\Controller\ServiceCategoriesController Test Case
- */
- class ServiceCategoriesControllerTest extends IntegrationTestCase
- {
- /**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = [
- 'app.service_categories',
- 'app.enterprises',
- 'app.users',
- 'app.pictures',
- 'app.employees',
- 'app.employe_categories',
- 'app.products',
- 'app.product_categories',
- 'app.services',
- 'app.suppliers',
- 'app.supplier_categories'
- ];
- public function SessionInit()
- {
- $this->session([
- 'Auth' => [
- 'User' =>[
- 'id' => 1,
- 'email' => 'Lorem ipsum dolor sit amet',
- 'password' => 'Lorem ipsum dolor sit amet'
- ]
- ]
- ]);
- }
- public function TestData()
- {
- $dataCat = [
- 'name' => "tests",
- 'enterprise_id' => 1
- ];
- $dataServ = [
- 'name' => "tests",
- 'price' => "100.00",
- 'service_category_id' => 3,
- 'Picture' => ['tmp_name' => 'tmp/tests/test.txt']
- ];
- $this->post('/serviceCategories/add',$dataCat);
- $this->post('/Services/add/3',$dataServ);
- }
- public function testServiceCategoriesDelete_10() //Destruction d'une catégorie de service
- {
- $this->SessionInit();
- $this->post('/serviceCategories/delete/2');
- $serviceCat = TableRegistry::get('serviceCategories');
- $query = $serviceCat->find('all');
- $this->assertEquals(1, $query->count());
- }
- public function testServiceCategoriesDelete_28()
- {
- $this->SessionInit();
- $this->TestData();
- $this->post('/serviceCategories/delete/3');
- $serviceCat = TableRegistry::get('serviceCategories');
- $service = TableRegistry::get('services');
- $AllCat = $serviceCat->find('all');
- $AllServ = $service->find('all');
- $this->assertEquals(2, $AllCat->count());
- $this->assertEquals(1, $AllServ->count());
- }
- public function testServiceCategoriesDelete_29()
- {
- $this->SessionInit();
- $this->TestData();
- $this->post('/serviceCategories/delete/3');
- $serviceCat = TableRegistry::get('serviceCategories');
- $picture = TableRegistry::get('pictures');
- $AllCat = $serviceCat->find('all');
- $AllPic = $picture->find('all');
- $this->assertEquals(2, $AllCat->count());
- $this->assertEquals(1, $AllPic->count());
- }
- public function testServiceCategoriesDelete_25()
- {
- $this->SessionInit();
- $this->TestData();
- $this->get('/serviceCategories/view/3');
- $this->assertResponseContains("<p>Are You really sure you want to delete this record?</p>");
- }
- public function testServiceCategoriesDelete_26()
- {
- $this->enableRetainFlashMessages();
- $this->SessionInit();
- $this->TestData();
- $this->get('/serviceCategories/view/3');
- $this->assertResponseContains('"tests"');
- }
- public function testServiceCategoriesDelete_27()
- {
- $this->SessionInit();
- $this->TestData();
- $this->get('/serviceCategories/view/3');
- $this->assertResponseContains("confirm");
- }
- public function testServiceCategoriesDelete_34_35()
- {
- $this->enableRetainFlashMessages();
- $this->SessionInit();
- $this->TestData();
- $this->post('/serviceCategories/delete/3');
- $this->assertSession('The service category has been deleted.', 'Flash.flash.0.message');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement