--- /dev/null
+<?php
+
+class PdoContractManagerTest extends AlloServeurTest {
+
+ const START_DATE = "2013-01-01";
+
+ /** @var PdoContractManager */
+ private $pdoContractManager;
+
+ /** @var Contract */
+ private $contract;
+
+ protected function setUp(){
+ parent::setUp();
+ $this->pdoContractManager = new PdoContractManager();
+ $this->contract = new Contract();
+ $this->contract->number = "FOO";
+ $this->contract->sugar_id="BAR";
+ $this->contract->customer_id = 0;
+ $this->contract->start_date = self::START_DATE;
+ }
+
+ public function testCreateContract(){
+ $this->pdoContractManager->createContract($this->contract);
+ $contract = $this->pdoContractManager->getContractByNumber("FOO");
+ $this->assertEquals(self::START_DATE,$contract->start_date);
+ }
+
+ public function testUpdateContract(){
+ $new_start_date = "2014-01-01";
+ $this->contract->id = $this->pdoContractManager->createContract($this->contract);
+ $this->contract->start_date = $new_start_date;
+ $this->pdoContractManager->updateContract($this->contract);
+ $contract = $this->pdoContractManager->getContract($this->contract->id);
+ $this->assertEquals($new_start_date,$contract->start_date);
+ }
+
+ public function testGetContracts(){
+ $this->pdoContractManager->createContract($this->contract);
+ $result = $this->pdoContractManager->getContracts();
+ $this->assertEquals(self::START_DATE,$result[1]->start_date);
+ }
+
+ public function testRemove(){
+ $nb_contrat = $this->pdoContractManager->getNbContrat();
+ $this->contract->id = $this->pdoContractManager->createContract($this->contract);
+ $this->pdoContractManager->removeContract($this->contract);
+ $this->assertEquals($nb_contrat,$this->pdoContractManager->getNbContrat());
+ }
+}
\ No newline at end of file