--- /dev/null
+<?php
+
+class ProductsControllerTest extends AlloServeurTest {
+
+ /** @var ProductsController */
+ private $productsController;
+
+ protected function setUp(){
+ parent::setUp();
+ $this->productsController = new ProductsController();
+ $this->productsController->login('admin');
+ }
+
+ public function testNbAction(){
+ $this->assertEquals(1,$this->productsController->nbAction());
+ }
+
+ public function testListAction(){
+ $this->productsController->setGetParameters(new GetParameters());
+ $this->assertEquals('Pastell',$this->productsController->listAction()[0]['name']);
+ }
+
+ public function testEditAction(){
+ $this->productsController->setGetParameters(new GetParameters(array('name'=>'foo')));
+ $this->productsController->editAction();
+ $pdoProductManager = new PdoProductManager();
+ $result = $pdoProductManager->getProducts(0,100);
+ $this->assertEquals('foo',$result[0]['name']);
+ }
+
+ public function testDeleteAction(){
+ $nb_product = $this->productsController->nbAction();
+
+ $pdoProductManager = new PdoProductManager();
+ $product = new Product();
+ $product->name = 'foo';
+ $product->diminutif = 'bar';
+ $id = $pdoProductManager->editProduct($product);
+ $this->productsController->setGetParameters(new GetParameters(array('id'=>$id)));
+ $this->productsController->deleteAction();
+ $result = $pdoProductManager->getProducts(0,100);
+ $this->assertEquals($nb_product,count($result));
+ }
+
+ public function testExistsByNameAction(){
+ $this->productsController->setGetParametersByArray(array('name'=>'Pastell'));
+ $this->assertTrue($this->productsController->existsByNameAction());
+ }
+
+}
\ No newline at end of file