예제 #1
0
 protected function loadConfig($configFilename)
 {
     require $configFilename;
     if (isset($config['timezone'])) {
         date_default_timezone_set($config['timezone']);
     }
     if (isset($config['theme'])) {
         $theme = str_replace('@[^A-Za-z0-9-_]+@', '', $config['theme']);
         $themeFile = dirname(__FILE__) . '/../theme/' . $theme . '.php';
         if (file_exists($themeFile)) {
             $this->themeFilename = $themeFile;
         } else {
             $this->themeFilename = dirname(__FILE__) . '/../theme/' . self::DEFAULTTHEME . '.php';
         }
     } else {
         $this->themeFilename = dirname(__FILE__) . '/../theme/' . self::DEFAULTTHEME . '.php';
     }
     foreach ($config['groups'] as $groupConfig) {
         $TestGroup = new TestGroup($groupConfig['name'], $groupConfig['host']);
         // add tests to group
         foreach ($groupConfig['tests'] as $testConfig) {
             $TestGroup->addTest($TestGroup->createTest($testConfig));
         }
         $this->TestGroups[] = $TestGroup;
     }
     return true;
 }
 public function addGroup(TestGroup $group)
 {
     $group->setUser($this);
     $this->groups->add($group);
     return $this;
 }
    protected function configure()
    {
        $this->addIndex('child1', $this->one);
        $this->addIndex('child2', $this->two);
        $this->getServiceRegistry()->register($this->service);
    }
}
$one = new TestChildOne();
$two = new TestChildTwo();
$two->setServiceRegistry(new xfServiceRegistry());
$two->describe();
// forces ->setup()
$dispatcher = new sfEventDispatcher();
$logger = new xfLoggerEventDispatcher($dispatcher);
$service = new xfService(new xfMockIdentifier());
$group = new TestGroup();
$group->setLogger($logger);
$group->one = $one;
$group->two = $two;
$group->service = $service;
$t = new lime_test(11, new lime_output_color());
$t->ok($group->getIndex('child1') === $one, '->getIndex() returns the index');
try {
    $msg = '->getIndex() fails if index does not exist';
    $group->getIndex('foobar');
    $t->fail($msg);
} catch (Exception $e) {
    $t->pass($msg);
}
$t->ok($one->getLogger() === $logger, '->setup() configures the logger of the child');
$t->ok($one->getServiceRegistry() === $group->getServiceRegistry(), '->search() passes on the service registry');