public function testDefaults()
    {
        $config_path = Util::getRelativePath(__DIR__ . '/../yaml');
        $cmd_name = 'test:default';
        $config_cmd = new TestConfigOptionCommand($cmd_name);
        $config = new Config(array($config_path . '/complete.yaml'));
        $config->load();
        $app = new Application();
        $app->configure();
        $app->setAutoExit(false);
        $app->getContainer()->set('config', $config);
        $app->add($config_cmd);
        $command = $app->find($cmd_name);
        $commandTester = new CommandTester($command);
        $commandTester->execute(array('command' => $cmd_name));
        $sugar_path = dirname(Util::getRelativePath(__DIR__)) . '/yaml/toto';
        $expected = <<<EOF
path: {$sugar_path}
url: titi

EOF;
        $this->assertEquals($expected, $commandTester->getDisplay());
        $commandTester = new CommandTester($command);
        $commandTester->execute(array('command' => $cmd_name, '-p' => 'foo', '--url' => 'bar'));
        $expected = <<<EOF
path: foo
url: bar

EOF;
        $this->assertEquals($expected, $commandTester->getDisplay());
    }
Example #2
0
 /**
  */
 public function testGetValue()
 {
     $sugar_path = Util::getRelativePath(__DIR__ . '/yaml/../yaml/toto');
     $relative_path = 'tests/Console/yaml/toto';
     $conf = new Config(array(__DIR__ . '/yaml/../yaml/complete.yaml'));
     $conf->load();
     $this->assertEquals($relative_path, $conf->get('sugarcrm.path'));
     $this->assertEquals('titi', $conf->get('sugarcrm.url'));
     $this->assertEquals(array('path' => $relative_path, 'url' => 'titi'), $conf->get('sugarcrm'));
     $this->assertTrue($conf->has());
     $this->assertTrue($conf->has('sugarcrm'));
     $this->assertTrue($conf->has('sugarcrm.path'));
     $this->assertFalse($conf->has('foo'));
     $this->assertFalse($conf->has('sugarcrm.foo'));
     $this->assertFalse($conf->has('sugarcrm.path.foo'));
 }
Example #3
0
 public function pathProvider()
 {
     return array(array('conf/bar', 'conf', 'bar', null), array(Util::getRelativePath('/var/www'), '/etc', '/var/www', null), array(Util::getRelativePath('/var/www'), 'conf', '/var/www', null), array(Util::getRelativePath('/etc/www'), '/etc', 'www', null), array('baz', getcwd() . '/', 'baz', null), array('toto/tests.php', 'tests/..', 'toto/tests.php', null), array('.', 'www', '..', null));
 }