public function setUp()
 {
     $this->setCommandName('weburg-series-add');
     parent::setUp();
     $this->configFile = tempnam(sys_get_temp_dir(), 'config');
     $config = new Config($this->configFile);
     $config->saveConfigFile();
     $this->app->setConfig($config);
 }
Exemplo n.º 2
0
 public function testSaveLoadConfig()
 {
     $homeDir = sys_get_temp_dir();
     $configFile = $homeDir . '/.transmission-cli.yml';
     putenv('HOME=' . $homeDir);
     $config = new Config($configFile);
     $config->set('param', 'value');
     $this->assertEquals('value', $config->get('param'));
     $config->saveConfigFile();
     $config->set('param', 'valueChanged');
     $config->loadConfigFile();
     $this->assertEquals('value', $config->get('param'));
     unlink($configFile);
 }
Exemplo n.º 3
0
 public function setUp()
 {
     $this->app = new Application();
     // logger
     $this->logger = $this->getMock('\\Psr\\Log\\LoggerInterface');
     $this->app->setLogger($this->logger);
     // config
     $homeDir = sys_get_temp_dir();
     $this->configFile = tempnam($homeDir, 'transmission-cli.yml');
     if (file_exists($this->configFile)) {
         unlink($this->configFile);
     }
     putenv('HOME=' . $homeDir);
     $config = new Config();
     $config->saveConfigFile();
     // TransmissionClient
     $httpClient = $this->getMock('GuzzleHttp\\ClientInterface');
     $api = $this->getMock('Martial\\Transmission\\API\\RpcClient', [], [$httpClient, '', '']);
     $client = $this->getMock('Popstas\\Transmission\\Console\\TransmissionClient', [], [$api]);
     $client->method('getTorrentData')->will($this->returnValue($this->expectedTorrentList));
     $this->app->setClient($client);
     // InfluxDbClient
     $influxDb = $this->getMockBuilder('InfluxDB\\Client')->setMethods([])->setConstructorArgs([''])->disableOriginalConstructor()->getMock();
     $influxDbClient = new InfluxDbClient($influxDb, 'dbname');
     $database = $this->getMock('InfluxDB\\Database', [], ['dbname', $influxDb]);
     $queryBuilder = $this->getMock('InfluxDB\\Query\\Builder', ['getResultSet'], [$database]);
     $resultSet = $this->getMockBuilder('InfluxDB\\ResultSet')->setMethods([])->setConstructorArgs([''])->disableOriginalConstructor()->getMock();
     $resultSet->method('getPoints')->willReturn([]);
     $queryBuilder->method('getResultSet')->will($this->returnValue($resultSet));
     $database->method('getQueryBuilder')->willReturn($queryBuilder);
     $influxDbClient->setDatabase($database);
     $this->app->setInfluxDbClient($influxDbClient);
     $this->command = $this->app->find($this->commandName);
     $this->commandTester = new CommandTester($this->command);
     parent::setUp();
 }