--- /dev/null
+<?php
+class PdoProductManagerTest extends AlloServeurTest {
+
+ /** @var PdoProductManager */
+ private $pdoProductManager;
+
+ private $product;
+
+ protected function setUp(){
+ parent::setUp();
+ $this->pdoProductManager = new PdoProductManager();
+ $this->product = new Product();
+ $this->product->name = "foo";
+ $this->product->diminutif = "baz";
+ $this->product->icon_url = "bar";
+ $this->product->id = $this->pdoProductManager->editProduct($this->product);
+ }
+
+ public function testCreate(){
+ $result = $this->pdoProductManager->getProducts(0,100);
+ $this->assertEquals('foo',$result[0]['name']);
+ $this->assertEquals('bar',$result[0]['icon_url']);
+ }
+
+ public function testUpdate(){
+ $this->product->name = 'baz';
+ $this->pdoProductManager->editProduct($this->product);
+ $result = $this->pdoProductManager->getProducts(0,100);
+ $this->assertEquals('baz',$result[0]['name']);
+ }
+
+ public function testNb(){
+ $this->assertEquals(2,$this->pdoProductManager->getNbProducts());
+ }
+
+ public function testDelete(){
+ $this->pdoProductManager->delete($this->product->id);
+ $this->assertEquals(1,$this->pdoProductManager->getNbProducts());
+ }
+
+ public function testExistsByName(){
+ $this->assertTrue($this->pdoProductManager->existsByName("Pastell"));
+ }
+
+ public function testGetBySugarId(){
+ $sugar_id = "PAST-EL22-3333-4444";
+ $product = $this->pdoProductManager->getBySugarId($sugar_id);
+ $this->assertEquals($sugar_id,$product->sugar_id);
+ }
+
+}
\ No newline at end of file