--- /dev/null
+<?php
+
+class ApplianceControllerTest extends AlloServeurTest {
+
+ const CONTRACT_NUMBER = 'PA/VILLEBEAU_30032/2014';
+
+ /** @var AppliancesController */
+ private $applianceController;
+
+ protected function setUp(){
+ parent::setUp();
+ $this->applianceController = new AppliancesController();
+ }
+
+ public function testCreateAction(){
+ $this->applianceController->setGetParametersByArray(
+ array(
+ 'contract_number'=>self::CONTRACT_NUMBER,
+ 'produit' => 'Pastell',
+ 'channel_key' => 'prod',
+ 'type_hebergement_key'=>'CLIENT',
+ )
+ );
+ $uuid = $this->applianceController->createAction();
+ $pdoApplianceManager = new PdoApplianceManager();
+ $info = $pdoApplianceManager->getInfoByUUID($uuid);
+ $this->assertNotEmpty($info);
+ }
+
+ public function testNbAction(){
+ $this->assertEquals(1,$this->applianceController->nbAction());
+ }
+
+ public function testListAction(){
+ $this->applianceController->setGetParametersByArray(array());
+ $this->assertEquals('PA/VILLEBEAU_30032_20160318082426',$this->applianceController->listAction()[0]['reference']);
+ }
+
+ public function testEditFicheVersionActionNotExisting(){
+ $this->setExpectedException("Exception","L'id (appliance_version) ne correspond à aucune version installée");
+ $this->applianceController->setGetParametersByArray(array('id'=>"foo"));
+ $this->applianceController->editFicheVersionAction();
+ }
+
+ public function testEditFicheVersionAction(){
+ $sugar_id = 12;
+ $appliance_version_id = 1;
+
+ $this->applianceController->setGetParametersByArray(array('id'=>$appliance_version_id));
+
+ $sugarWrapper = $this->getMockBuilder("SugarWrapper")->disableOriginalConstructor()->getMock();
+ $sugarWrapper->expects($this->any())->method("setEntry")->willReturn(array('id'=>$sugar_id));
+ /** @var SugarWrapper $sugarWrapper */
+ $this->applianceController->setSugarWrapper($sugarWrapper);
+
+ $this->applianceController->editFicheVersionAction();
+
+ $pdoApplianceVersion = new PdoApplianceVersionManager();
+ $applianceVersion = $pdoApplianceVersion->get($appliance_version_id);
+ $this->assertEquals($sugar_id,$applianceVersion->sugar_id);
+ }
+}
\ No newline at end of file