コード例 #1
0
 public function testCreateTransmissionClientSuccess()
 {
     $this->setCommandName('weburg-download');
     parent::setUp();
     $this->app->setClient(null);
     $config = new Config();
     $config->set('transmission-host', 'devnull');
     $config->set('transmission-port', 1234);
     $config->set('transmission-user', 'user');
     $config->set('transmission-password', 'pass');
     $config->set('dest', '');
     $this->app->setConfig($config);
     $result = $this->executeCommand();
     $this->assertEquals(1, $result);
     $this->assertRegExp('/Destination directory not defined/', $this->getDisplay());
 }
コード例 #2
0
 public function setUp()
 {
     $this->setCommandName('stats-get');
     parent::setUp();
     $config = new Config();
     $config->set('influxdb-host', 'devnull');
     $config->set('influxdb-port', 1234);
     $config->set('influxdb-user', 'user');
     $config->set('influxdb-password', 'pass');
     $this->app->setConfig($config);
     $this->influxDb = $this->getMockBuilder('InfluxDB\\Client')->setMethods([])->setConstructorArgs([''])->disableOriginalConstructor()->getMock();
     $this->influxDbClient = $this->getMock('Popstas\\Transmission\\Console\\InfluxDbClient', [], [$this->influxDb, 'test']);
     $this->database = $this->getMock('InfluxDB\\Database', [], ['dbname', $this->influxDb]);
     $this->database->method('exists')->will($this->returnValue(true));
     $this->influxDb->method('selectDB')->will($this->returnValue($this->database));
     $this->app->setInfluxDbClient($this->influxDbClient);
 }
コード例 #3
0
 public function setUp()
 {
     $this->setCommandName('weburg-download');
     parent::setUp();
     $this->dest = sys_get_temp_dir() . '/transmission-cli-torrents';
     if (!file_exists($this->dest)) {
         mkdir($this->dest);
     }
     $config = new Config();
     $config->set('download-torrents-dir', $this->dest);
     $config->set('weburg-series-list', [1, 2, 3]);
     $this->app->setConfig($config);
     $httpClient = $this->getMock('GuzzleHttp\\ClientInterface');
     $client = $this->getMock('Popstas\\Transmission\\Console\\WeburgClient', [], [$httpClient]);
     $client->method('getMoviesIds')->will($this->returnValue([1, 2, 3]));
     $client->method('getMovieTorrentUrlsById')->will($this->returnValue(['http://torrent-url']));
     $client->method('getSeriesTorrents')->willReturn(['torrent-url']);
     $client->method('getMovieInfoById')->willReturn(['title' => 'movie', 'comments' => 123, 'rating_imdb' => null]);
     $this->app->setWeburgClient($client);
 }
コード例 #4
0
 public function testOverrideConfig()
 {
     $config = new Config();
     $config->set('config-parameter', 'original');
     // not defined option
     $input = $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface');
     $input->method('hasOption')->willReturn(false);
     $input->expects($this->never())->method('getOption');
     $config->overrideConfig($input, 'config-parameter');
     $this->assertEquals('original', $config->get('config-parameter'));
     // override with option name = config name
     $input = $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface');
     $input->method('hasOption')->willReturn(true);
     $input->method('getOption')->willReturn('overrided');
     $config->overrideConfig($input, 'config-parameter');
     $this->assertEquals('overrided', $config->get('config-parameter'));
     // override with option name != config name
     $input = $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface');
     $input->method('hasOption')->willReturn(true);
     $input->method('getOption')->willReturn('overrided2');
     $config->overrideConfig($input, 'option-name', 'config-parameter');
     $this->assertEquals('overrided2', $config->get('config-parameter'));
 }