// ->validate()
try {
    $loader->validate(sfYaml::load(dirname(__FILE__) . '/fixtures/yaml/nonvalid1.yml'));
    $t->fail('->validate() throws an InvalidArgumentException if the loaded definition is not an array');
} catch (InvalidArgumentException $e) {
    $t->pass('->validate() throws an InvalidArgumentException if the loaded definition is not an array');
}
try {
    $loader->validate(sfYaml::load(dirname(__FILE__) . '/fixtures/yaml/nonvalid2.yml'));
    $t->fail('->validate() throws an InvalidArgumentException if the loaded definition is not a valid array');
} catch (InvalidArgumentException $e) {
    $t->pass('->validate() throws an InvalidArgumentException if the loaded definition is not a valid array');
}
// ->load() # parameters
$t->diag('->load() # parameters');
list($services, $parameters) = $loader->doLoad(array());
$t->is($parameters, array(), '->load() return emty parameters array for an empty array definition');
list($services, $parameters) = $loader->doLoad(sfYaml::load(dirname(__FILE__) . '/fixtures/yaml/services2.yml'));
$t->is($parameters, array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new sfServiceReference('foo_bar')), '->load() converts array keys to lowercase');
// ->load() # services
list($services, $parameters) = $loader->doLoad(sfYaml::load(dirname(__FILE__) . '/fixtures/yaml/services2.yml'));
$t->is($services, array(), '->load() return emty services array for an empty array definition');
$t->diag('->load() # services');
list($services, $parameters) = $loader->doLoad(sfYaml::load(dirname(__FILE__) . '/fixtures/yaml/services3.yml'));
$t->ok(isset($services['foo']), '->load() parses service elements');
$t->is(get_class($services['foo']), 'sfServiceDefinition', '->load() converts service element to sfServiceDefinition instances');
$t->is($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute');
$t->ok($services['shared']->isShared(), '->load() parses the shared attribute');
$t->ok(!$services['non_shared']->isShared(), '->load() parses the shared attribute');
$t->is($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute');
$t->is($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag');
// ->validate()
try {
    $loader->validate(sfYaml::load(__DIR__ . '/fixtures/yaml/nonvalid1.yml'));
    $t->fail('->validate() throws an InvalidArgumentException if the loaded definition is not an array');
} catch (InvalidArgumentException $e) {
    $t->pass('->validate() throws an InvalidArgumentException if the loaded definition is not an array');
}
try {
    $loader->validate(sfYaml::load(__DIR__ . '/fixtures/yaml/nonvalid2.yml'));
    $t->fail('->validate() throws an InvalidArgumentException if the loaded definition is not a valid array');
} catch (InvalidArgumentException $e) {
    $t->pass('->validate() throws an InvalidArgumentException if the loaded definition is not a valid array');
}
// ->load() # parameters
$t->diag('->load() # parameters');
list($services, $parameters) = $loader->doLoad(array());
$t->is($parameters, array(), '->load() return emty parameters array for an empty array definition');
list($services, $parameters) = $loader->doLoad(sfYaml::load(__DIR__ . '/fixtures/yaml/services2.yml'));
$t->is($parameters, array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new sfServiceReference('foo_bar')), '->load() converts array keys to lowercase');
// ->load() # services
list($services, $parameters) = $loader->doLoad(sfYaml::load(__DIR__ . '/fixtures/yaml/services2.yml'));
$t->is($services, array(), '->load() return emty services array for an empty array definition');
$t->diag('->load() # services');
list($services, $parameters) = $loader->doLoad(sfYaml::load(__DIR__ . '/fixtures/yaml/services3.yml'));
$t->ok(isset($services['foo']), '->load() parses service elements');
$t->is(get_class($services['foo']), 'sfServiceDefinition', '->load() converts service element to sfServiceDefinition instances');
$t->is($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute');
$t->ok($services['shared']->isShared(), '->load() parses the shared attribute');
$t->ok(!$services['non_shared']->isShared(), '->load() parses the shared attribute');
$t->is($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute');
$t->is($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag');
        $loader->getFilesAsArray(array($fixture . '.yml'));
        $t->fail('->load() throws an InvalidArgumentException if the loaded file does not validate');
    } catch (InvalidArgumentException $e) {
        $t->pass('->load() throws an InvalidArgumentException if the loaded file does not validate');
    }
}
$yamls = $loader->getFilesAsArray(array('services1.yml'));
$t->ok(is_array($yamls), '->getFilesAsArray() returns an array');
$t->is(key($yamls), realpath(dirname(__FILE__) . '/fixtures/yaml/services1.yml'), '->getFilesAsArray() returns an array where the keys are absolutes paths to the original YAML file');
// ->load() # parameters
$t->diag('->load() # parameters');
$loader = new ProjectLoader(null, dirname(__FILE__) . '/fixtures/yaml');
list($services, $parameters) = $loader->doLoad(array('services2.yml'));
$t->is($parameters, array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new sfServiceReference('foo_bar')), '->load() converts YAML keys to lowercase');
$loader = new ProjectLoader(null, dirname(__FILE__) . '/fixtures/yaml');
list($services, $parameters) = $loader->doLoad(array('services2.yml', 'services3.yml'));
$t->is($parameters, array('foo' => 'foo', 'values' => array(true, false), 'bar' => 'foo', 'foo_bar' => new sfServiceReference('foo_bar')), '->load() merges the first level of arguments when multiple files are loaded');
// ->load() # imports
$t->diag('->load() # imports');
list($services, $parameters) = $loader->doLoad(array('services4.yml'));
$t->is($parameters, array('foo' => 'bar', 'bar' => '%foo%', 'values' => array(true, false), 'foo_bar' => new sfServiceReference('foo_bar')), '->load() imports and merges imported files');
// ->load() # services
$t->diag('->load() # services');
list($services, $parameters) = $loader->doLoad(array('services6.yml'));
$t->ok(isset($services['foo']), '->load() parses service elements');
$t->is(get_class($services['foo']), 'sfServiceDefinition', '->load() converts service element to sfServiceDefinition instances');
$t->is($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute');
$t->ok($services['shared']->isShared(), '->load() parses the shared attribute');
$t->ok(!$services['non_shared']->isShared(), '->load() parses the shared attribute');
$t->is($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute');
$t->is($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag');