本文整理汇总了PHP中LimeTest::is方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeTest::is方法的具体用法?PHP LimeTest::is怎么用?PHP LimeTest::is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LimeTest
的用法示例。
在下文中一共展示了LimeTest::is方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__.'/../../../../bootstrap.php';
use Symfony\Components\Templating\Storage\Storage;
use Symfony\Components\Templating\Renderer\PhpRenderer;
$t = new LimeTest(2);
class TestStorage extends Storage
{
public function getContent()
{
}
}
// __construct() __toString()
$t->diag('__construct() __toString()');
$storage = new TestStorage('foo');
$t->is((string) $storage, 'foo', '__toString() returns the template name');
// ->getRenderer()
$t->diag('->getRenderer()');
$storage = new TestStorage('foo', $renderer = new PhpRenderer());
$t->ok($storage->getRenderer() === $renderer, '->getRenderer() returns the renderer');
示例2: LimeTest
$fixturesPath = __DIR__.'/../../../../fixtures/Symfony/Components/DependencyInjection/';
$t = new LimeTest(39);
// __construct()
$t->diag('__construct()');
$definitions = array(
'foo' => new Definition('FooClass'),
'bar' => new Definition('BarClass'),
);
$parameters = array(
'foo' => 'foo',
'bar' => 'bar',
);
$configuration = new BuilderConfiguration($definitions, $parameters);
$t->is($configuration->getDefinitions(), $definitions, '__construct() takes an array of definitions as its first argument');
$t->is($configuration->getParameters(), $parameters, '__construct() takes an array of parameters as its second argument');
// ->merge()
$t->diag('->merge()');
$configuration = new BuilderConfiguration();
$configuration->merge(null);
$t->is($configuration->getParameters(), array(), '->merge() accepts null as an argument');
$t->is($configuration->getDefinitions(), array(), '->merge() accepts null as an argument');
$configuration = new BuilderConfiguration(array(), array('bar' => 'foo'));
$configuration1 = new BuilderConfiguration(array(), array('foo' => 'bar'));
$configuration->merge($configuration1);
$t->is($configuration->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones');
$configuration = new BuilderConfiguration(array(), array('bar' => 'foo', 'foo' => 'baz'));
示例3: LimeTest
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../../bootstrap.php';
use Symfony\Components\DependencyInjection\Builder;
use Symfony\Components\DependencyInjection\Dumper\GraphvizDumper;
$t = new LimeTest(4);
$fixturesPath = __DIR__ . '/../../../../../fixtures/Symfony/Components/DependencyInjection/';
// ->dump()
$t->diag('->dump()');
$dumper = new GraphvizDumper($container = new Builder());
$t->is($dumper->dump(), file_get_contents($fixturesPath . '/graphviz/services1.dot'), '->dump() dumps an empty container as an empty dot file');
$container = new Builder();
$dumper = new GraphvizDumper($container);
$container = (include $fixturesPath . '/containers/container9.php');
$dumper = new GraphvizDumper($container);
$t->is($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents($fixturesPath . '/graphviz/services9.dot')), '->dump() dumps services');
$container = (include $fixturesPath . '/containers/container10.php');
$dumper = new GraphvizDumper($container);
$t->is($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents($fixturesPath . '/graphviz/services10.dot')), '->dump() dumps services');
$container = (include $fixturesPath . '/containers/container10.php');
$dumper = new GraphvizDumper($container);
$t->is($dumper->dump(array('graph' => array('ratio' => 'normal'), 'node' => array('fontsize' => 13, 'fontname' => 'Verdana', 'shape' => 'square'), 'edge' => array('fontsize' => 12, 'fontname' => 'Verdana', 'color' => 'white', 'arrowhead' => 'closed', 'arrowsize' => 1), 'node.instance' => array('fillcolor' => 'green', 'style' => 'empty'), 'node.definition' => array('fillcolor' => 'grey'), 'node.missing' => array('fillcolor' => 'red', 'style' => 'empty'))), str_replace('%path%', __DIR__, file_get_contents($fixturesPath . '/graphviz/services10-1.dot')), '->dump() dumps services');
示例4: LimeTest
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../bootstrap.php';
use Symfony\Components\DependencyInjection\Definition;
$t = new LimeTest(21);
// __construct()
$t->diag('__construct()');
$def = new Definition('stdClass');
$t->is($def->getClass(), 'stdClass', '__construct() takes the class name as its first argument');
$def = new Definition('stdClass', array('foo'));
$t->is($def->getArguments(), array('foo'), '__construct() takes an optional array of arguments as its second argument');
// ->setConstructor() ->getConstructor()
$t->diag('->setConstructor() ->getConstructor()');
$def = new Definition('stdClass');
$t->is(spl_object_hash($def->setConstructor('foo')), spl_object_hash($def), '->setConstructor() implements a fluent interface');
$t->is($def->getConstructor(), 'foo', '->getConstructor() returns the constructor name');
// ->setClass() ->getClass()
$t->diag('->setClass() ->getClass()');
$def = new Definition('stdClass');
$t->is(spl_object_hash($def->setClass('foo')), spl_object_hash($def), '->setClass() implements a fluent interface');
$t->is($def->getClass(), 'foo', '->getClass() returns the class name');
// ->setArguments() ->getArguments() ->addArgument()
$t->diag('->setArguments() ->getArguments() ->addArgument()');
$def = new Definition('stdClass');
示例5: LimeTest
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../bootstrap.php';
use Symfony\Components\Yaml\Yaml;
use Symfony\Components\Yaml\Inline;
Yaml::setSpecVersion('1.1');
$t = new LimeTest(124);
// ::load()
$t->diag('::load()');
$testsForLoad = array('' => '', 'null' => null, 'false' => false, 'true' => true, '12' => 12, '"quoted string"' => 'quoted string', "'quoted string'" => 'quoted string', '12.30e+02' => 1230.0, '0x4D2' => 0x4d2, '02333' => 02333, '.Inf' => -log(0), '-.Inf' => log(0), '123456789123456789' => '123456789123456789', '"foo\\r\\nbar"' => "foo\r\nbar", "'foo#bar'" => 'foo#bar', "'foo # bar'" => 'foo # bar', "'#cfcfcf'" => '#cfcfcf', '2007-10-30' => mktime(0, 0, 0, 10, 30, 2007), '2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007), '2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007), '"a \\"string\\" with \'quoted strings inside\'"' => 'a "string" with \'quoted strings inside\'', "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', '[foo, http://urls.are/no/mappings, false, null, 12]' => array('foo', 'http://urls.are/no/mappings', false, null, 12), '[ foo , bar , false , null , 12 ]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), '{foo:bar,bar:foo,false:false,null:null,integer:12}' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), '{ foo : bar, bar : foo, false : false, null : null, integer : 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), '{foo: \'bar\', bar: \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'), '{\'foo\': \'bar\', "bar": \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'), '{\'foo\'\'\': \'bar\', "bar\\"": \'foo: bar\'}' => array('foo\'' => 'bar', "bar\"" => 'foo: bar'), '{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}' => array('foo: ' => 'bar', "bar: " => 'foo: bar'), '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')), '[foo, {bar: foo}]' => array('foo', array('bar' => 'foo')), '{ foo: {bar: foo} }' => array('foo' => array('bar' => 'foo')), '{ foo: [bar, foo] }' => array('foo' => array('bar', 'foo')), '[ foo, [ bar, foo ] ]' => array('foo', array('bar', 'foo')), '[{ foo: {bar: foo} }]' => array(array('foo' => array('bar' => 'foo'))), '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')), '[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))));
foreach ($testsForLoad as $yaml => $value) {
$t->is(Inline::load($yaml), $value, sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml));
}
$testsForDump = array('null' => null, 'false' => false, 'true' => true, '12' => 12, "'quoted string'" => 'quoted string', '12.30e+02' => 1230.0, '1234' => 0x4d2, '1243' => 02333, '.Inf' => -log(0), '-.Inf' => log(0), '"foo\\r\\nbar"' => "foo\r\nbar", "'foo#bar'" => 'foo#bar', "'foo # bar'" => 'foo # bar', "'#cfcfcf'" => '#cfcfcf', "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), '{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), '{ foo: bar, bar: \'foo: bar\' }' => array('foo' => 'bar', 'bar' => 'foo: bar'), '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')), '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')), '{ foo: { bar: foo } }' => array('foo' => array('bar' => 'foo')), '[foo, { bar: foo }]' => array('foo', array('bar' => 'foo')), '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))));
// ::dump()
$t->diag('::dump()');
foreach ($testsForDump as $yaml => $value) {
$t->is(Inline::dump($value), $yaml, sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
}
foreach ($testsForLoad as $yaml => $value) {
if ($value == 1230) {
continue;
}
$t->is(Inline::load(Inline::dump($value)), $value, 'check consistency');
}
foreach ($testsForDump as $yaml => $value) {
if ($value == 1230) {
示例6: LimeTest
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../bootstrap.php';
use Symfony\Components\DependencyInjection\Container;
$fixturesPath = __DIR__ . '/../../../../fixtures/Symfony/Components/DependencyInjection/';
$t = new LimeTest(42);
// __construct()
$t->diag('__construct()');
$sc = new Container();
$t->is(spl_object_hash($sc->getService('service_container')), spl_object_hash($sc), '__construct() automatically registers itself as a service');
$sc = new Container(array('foo' => 'bar'));
$t->is($sc->getParameters(), array('foo' => 'bar'), '__construct() takes an array of parameters as its first argument');
// ->setParameters() ->getParameters()
$t->diag('->setParameters() ->getParameters()');
$sc = new Container();
$t->is($sc->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined');
$sc->setParameters(array('foo' => 'bar'));
$t->is($sc->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters');
$sc->setParameters(array('bar' => 'foo'));
$t->is($sc->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters');
$sc->setParameters(array('Bar' => 'foo'));
$t->is($sc->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase');
// ->setParameter() ->getParameter()
$t->diag('->setParameter() ->getParameter() ');
$sc = new Container(array('foo' => 'bar'));
示例7: __toString
class OutputEscaperTest
{
public function __toString()
{
return $this->getTitle();
}
public function getTitle()
{
return '<strong>escaped!</strong>';
}
public function getTitles()
{
return array(1, 2, '<strong>escaped!</strong>');
}
}
$object = new OutputEscaperTest();
$escaped = Escaper::escape('entities', $object);
$t->is($escaped->getTitle(), '<strong>escaped!</strong>', 'The escaped object behaves like the real object');
$array = $escaped->getTitles();
$t->is($array[2], '<strong>escaped!</strong>', 'The escaped object behaves like the real object');
// __toString()
$t->diag('__toString()');
$t->is($escaped->__toString(), '<strong>escaped!</strong>', 'The escaped object behaves like the real object');
示例8: LimeTest
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__.'/../../../../bootstrap.php';
use Symfony\Components\DependencyInjection\Builder;
use Symfony\Components\DependencyInjection\Loader\IniFileLoader;
$t = new LimeTest(3);
$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/');
$loader = new IniFileLoader($fixturesPath.'/ini');
$config = $loader->load('parameters.ini');
$t->is($config->getParameters(), array('foo' => 'bar', 'bar' => '%foo%'), '->load() takes a single file name as its first argument');
try
{
$loader->load('foo.ini');
$t->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
}
catch (InvalidArgumentException $e)
{
$t->pass('->load() throws an InvalidArgumentException if the loaded file does not exist');
}
try
{
@$loader->load('nonvalid.ini');
$t->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable');
示例9: normalizeUrl
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../../bootstrap.php';
use Symfony\Components\Routing\Matcher\UrlMatcher;
use Symfony\Components\Routing\RouteCollection;
use Symfony\Components\Routing\Route;
$t = new LimeTest(1);
$collection = new RouteCollection();
$collection->addRoute('foo', new Route('/:foo'));
class UrlMatcherTest extends UrlMatcher
{
public function normalizeUrl($url)
{
return parent::normalizeUrl($url);
}
}
$matcher = new UrlMatcherTest($collection, array(), array());
// ->normalizeUrl()
$t->diag('->normalizeUrl()');
$t->is($matcher->normalizeUrl(''), '/', '->normalizeUrl() adds a / at the beginning of the URL if needed');
$t->is($matcher->normalizeUrl('foo'), '/foo', '->normalizeUrl() adds a / at the beginning of the URL if needed');
$t->is($matcher->normalizeUrl('/foo?foo=bar'), '/foo', '->normalizeUrl() removes the query string');
$t->is($matcher->normalizeUrl('/foo//bar'), '/foo/bar', '->normalizeUrl() removes duplicated /');
// ->match()
$t->diag('->match()');
//var_export($matcher->match('/foo'));
//print_R($compiler->compile(new route('/:foo')));
示例10: FooFilter
$fooFilter = new FooFilter();
$barFilter = new BarFilter();
$bazFilter = new BazFilter();
// @After
unset($fooFilter);
unset($barFilter);
unset($bazFilter);
// @Test: ->getFilters()
$fc = new Sonata_FilterChain();
$t->ok(is_array($fc->getFilters()) && count($fc->getFilters()) == 0, 'The method returns the empty filters array');
// @Test: ->addFilter()
$fc = new Sonata_FilterChain();
$fc->addFilter($fooFilter);
$fc->addFilter($barFilter);
$fc->addFilter($bazFilter);
$t->is($fc->getFilters(), array($fooFilter, $barFilter, $bazFilter), 'All filters were added correctly');
// @Test: ->processFilters()
$request = new Sonata_Request();
$response = new Sonata_Response();
$fooFilter = $t->mock('FooFilter');
$fooFilter->execute($request, $response)->once();
$fooFilter->replay();
$barFilter = $t->mock('BarFilter');
$barFilter->execute($request, $response)->once();
$barFilter->replay();
$bazFilter = $t->mock('BazFilter');
$bazFilter->execute($request, $response)->once();
$bazFilter->replay();
$fc = new Sonata_FilterChain();
$fc->addFilter($fooFilter);
$fc->addFilter($barFilter);
示例11: catch
}
try {
$loader->getFilesAsXml(array('parameters.ini'));
$t->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid XML file');
} catch (InvalidArgumentException $e) {
$t->pass('->load() throws an InvalidArgumentException if the loaded file is not a valid XML file');
}
$loader = new ProjectLoader($fixturesPath . '/xml');
try {
$loader->getFilesAsXml(array('nonvalid.xml'));
$t->fail('->load() throws an InvalidArgumentException if the loaded file does not validate the XSD');
} catch (InvalidArgumentException $e) {
$t->pass('->load() throws an InvalidArgumentException if the loaded file does not validate the XSD');
}
$xmls = $loader->getFilesAsXml(array('services1.xml'));
$t->is(count($xmls), 1, '->getFilesAsXml() returns an array of simple xml objects');
$t->is(key($xmls), realpath($fixturesPath . '/xml/services1.xml'), '->getFilesAsXml() returns an array where the keys are absolutes paths to the original XML file');
$t->is(get_class(current($xmls)), 'Symfony\\Components\\DependencyInjection\\SimpleXMLElement', '->getFilesAsXml() returns an array where values are SimpleXMLElement objects');
// ->load() # parameters
$t->diag('->load() # parameters');
$loader = new ProjectLoader($fixturesPath . '/xml');
$config = $loader->load(array('services2.xml'));
$t->is($config->getParameters(), array('a string', 'foo' => 'bar', 'values' => array(0, 'integer' => 4, 100 => null, 'true', true, false, 'on', 'off', 'float' => 1.3, 1000.3, 'a string', array('foo', 'bar')), 'foo_bar' => new Reference('foo_bar')), '->load() converts XML values to PHP ones');
$loader = new ProjectLoader($fixturesPath . '/xml');
$config = $loader->load(array('services2.xml', 'services3.xml'));
$t->is($config->getParameters(), array('a string', 'foo' => 'foo', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar')), '->load() merges the first level of arguments when multiple files are loaded');
// ->load() # imports
$t->diag('->load() # imports');
$config = $loader->load(array('services4.xml'));
$t->is($config->getParameters(), array('a string', 'foo' => 'bar', 'bar' => '%foo%', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar')), '->load() imports and merges imported files');
// ->load() # anonymous services
示例12: fopen
fputs($fh, '<?php class Sonata_Pass {} ?>');
fclose($fh);
mkdir(dirname(__FILE__) . '/../../src/Pass');
$fh = fopen(dirname(__FILE__) . '/../../src/Pass/Nested.class.php', 'wb');
fputs($fh, '<?php class Sonata_Pass_Nested {} ?>');
fclose($fh);
$fh = fopen(dirname(__FILE__) . '/../../src/Fail.php', 'wb');
fputs($fh, '<?php class Sonata_Fail {} ?>');
fclose($fh);
$fh = fopen(dirname(__FILE__) . '/../fixtures/Extra.class.php', 'wb');
fputs($fh, '<?php class Extra {} ?>');
fclose($fh);
// @Before
$autoloader = new Sonata_Autoloader();
// @AfterAll
unlink(dirname(__FILE__) . '/../../src/Foo.class.php');
unlink(dirname(__FILE__) . '/../../src/Pass.class.php');
unlink(dirname(__FILE__) . '/../../src/Pass/Nested.class.php');
rmdir(dirname(__FILE__) . '/../../src/Pass');
unlink(dirname(__FILE__) . '/../../src/Fail.php');
unlink(dirname(__FILE__) . '/../fixtures/Extra.class.php');
// @Test: ->autoload() loads class files by class name
$t->is($autoloader->autoload('Sonata_Pass'), true, 'Returns true if a class can be loaded');
$t->is($autoloader->autoload('Sonata_Pass_Nested'), true, 'Still works for more nested classes');
$t->is($autoloader->autoload('Sonata_Fail'), false, 'Returns false if the class filename does not end with \'.class.php\'');
$t->is($autoloader->autoload('Foo'), false, 'Returns false if the class name does not start with \'Sonata\'');
$t->is($autoloader->autoload('Sonata_Not_Here'), false, 'Returns false for non-existing classes');
// @Test: ::extend() registers extra directories for autoloading
$t->is($autoloader->autoload('Extra'), false, 'The \'Extra\' class cannot be autoloaded because its path isn\'t registered for autoloading');
Sonata_Autoloader::extend(array(dirname(__FILE__) . '/../fixtures'));
$t->is($autoloader->autoload('Extra'), true, 'The \'Extra\' class is now autoloaded correctly');
示例13: foreach
$path = __DIR__ . '/../../../../fixtures/Symfony/Components/Yaml';
$files = $parser->parse(file_get_contents($path . '/index.yml'));
foreach ($files as $file) {
$t->diag($file);
$yamls = file_get_contents($path . '/' . $file . '.yml');
// split YAMLs documents
foreach (preg_split('/^---( %YAML\\:1\\.0)?/m', $yamls) as $yaml) {
if (!$yaml) {
continue;
}
$test = $parser->parse($yaml);
if (isset($test['todo']) && $test['todo']) {
$t->todo($test['test']);
} else {
$expected = var_export(eval('return ' . trim($test['php']) . ';'), true);
$t->is(var_export($parser->parse($test['yaml']), true), $expected, $test['test']);
}
}
}
// test tabs in YAML
$yamls = array("foo:\n\tbar", "foo:\n \tbar", "foo:\n\t bar", "foo:\n \t bar");
foreach ($yamls as $yaml) {
try {
$content = $parser->parse($yaml);
$t->fail('YAML files must not contain tabs');
} catch (ParserException $e) {
$t->pass('YAML files must not contain tabs');
}
}
// objects
$t->diag('Objects support');
示例14: LimeTest
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../bootstrap.php';
use Symfony\Components\DependencyInjection\Reference;
$t = new LimeTest(1);
// __construct() ->__toString()
$t->diag('__construct() ->__toString()');
$ref = new Reference('foo');
$t->is((string) $ref, 'foo', '__construct() sets the id of the reference, which is used for the __toString() method');
示例15: catch
try
{
$loader->loadFile($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');
}
}
// ->load() # parameters
$t->diag('->load() # parameters');
$loader = new ProjectLoader($fixturesPath.'/yaml');
$config = $loader->load('services2.yml');
$t->is($config->getParameters(), array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), '->load() converts YAML keys to lowercase');
// ->load() # imports
$t->diag('->load() # imports');
$config = $loader->load('services4.yml');
$t->is($config->getParameters(), array('foo' => 'bar', 'bar' => '%foo%', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'imported_from_xml' => true, 'imported_from_ini' => true), '->load() imports and merges imported files');
// ->load() # services
$t->diag('->load() # services');
$config = $loader->load('services6.yml');
$services = $config->getDefinitions();
$t->ok(isset($services['foo']), '->load() parses service elements');
$t->is(get_class($services['foo']), 'Symfony\\Components\\DependencyInjection\\Definition', '->load() converts service element to Definition 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');