--- /dev/null
+<?php
+
+
+class ChannelControllerTest extends AlloServeurTest {
+
+ /** @var ChannelController */
+ private $channelController;
+
+ protected function setUp() {
+ parent::setUp();
+ $this->channelController = new ChannelController();
+ }
+
+ private function editAction(array $parameters){
+ $this->channelController->setGetParametersByArray($parameters);
+ return $this->channelController->editAction();
+ }
+
+ private function getParameters(){
+ return array(
+ 'id'=>0,
+ 'channel_id'=>1,
+ 'version_id'=>1,
+ 'status'=>ChannelVersion::STATUS_MAK_KO
+ );
+ }
+
+ public function testEditAction(){
+ $channel_version_id = $this->editAction($this->getParameters());
+ $pdoChannelVersionManager = new PdoChannelVersionManager();
+ $channelVersion = $pdoChannelVersionManager->getChannel($channel_version_id);
+ $this->assertEquals(1,$channelVersion->channel_id);
+ }
+
+ public function testEditActionStatutNotExisting(){
+ $parameters = $this->getParameters();
+ $parameters['status'] = 'not existing statut';
+ $this->setExpectedException("Exception","Le statut {$parameters['status']} n'existe pas");
+ $this->editAction($parameters);
+ }
+
+ public function testEditActionVersionIdNotExisting(){
+ $parameters = $this->getParameters();
+ $parameters['version_id'] = '42';
+ $this->setExpectedException("Exception","Cette version_id est inconnu sur le serveur");
+ $this->editAction($parameters);
+ }
+
+ public function testStatusListAction(){
+ $list = $this->channelController->statusListAction();
+ $this->assertArrayHasKey(ChannelVersion::STATUS_MAK_KO,$list);
+ }
+
+ public function testListByVersionAction(){
+ $this->channelController->setGetParametersByArray(array('version_id'=>1));
+ $list = $this->channelController->listByVersionAction();
+ $this->assertEquals(1,$list[0]['id']);
+ }
+
+ public function testDeleteAction(){
+ $this->channelController->setGetParametersByArray(array('id'=>1));
+ $this->channelController->deleteAction();
+ $this->assertEmpty($this->channelController->listByVersionAction());
+ }
+
+ public function testList(){
+ $list = $this->channelController->listAction();
+ $this->assertEquals("PROD",$list[0]['libelle']);
+ }
+
+}
\ No newline at end of file