This commit is contained in:
Fabien Potencier 2012-05-01 14:46:26 +02:00
parent db1d145b35
commit 26f933e7bd
57 changed files with 276 additions and 163 deletions

View File

@ -28,6 +28,7 @@ $finder
->name('*.yml')
->in(__DIR__.'/src')
->notName(basename(__FILE__))
->notName('sfTests.yml')
->exclude('.git')
->exclude('vendor')
;

View File

@ -11,8 +11,6 @@
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
use \PropelPDO;
class ReadOnlyItem extends \BaseObject
{
public function getName()

View File

@ -644,7 +644,7 @@ class FrameworkExtension extends Extension
->replaceArgument(2, $config['debug'])
;
$container->setAlias('annotation_reader', 'annotations.file_cache_reader');
} else if('none' !== $config['cache']) {
} elseif ('none' !== $config['cache']) {
$container
->getDefinition('annotations.cached_reader')
->replaceArgument(1, new Reference($config['cache']))

View File

@ -154,6 +154,7 @@ class ClassCollectionLoader
$inNamespace = false;
--$i;
} else {
$output = rtrim($output);
$output .= "\n{";
$inNamespace = true;
}

View File

@ -11,11 +11,12 @@
namespace Symfony\Component\DependencyInjection\Dumper;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Dumper as YmlDumper;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* YamlDumper dumps a service container as a YAML string.
@ -26,6 +27,22 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
*/
class YamlDumper extends Dumper
{
private $dumper;
/**
* Constructor.
*
* @param ContainerBuilder $container The service container to dump
*
* @api
*/
public function __construct(ContainerBuilder $container)
{
parent::__construct($container);
$this->dumper = new YmlDumper();
}
/**
* Dumps the service container as an YAML string.
*
@ -60,11 +77,11 @@ class YamlDumper extends Dumper
foreach ($tags as $attributes) {
$att = array();
foreach ($attributes as $key => $value) {
$att[] = sprintf('%s: %s', Yaml::dump($key), Yaml::dump($value));
$att[] = sprintf('%s: %s', $this->dumper->dump($key), $this->dumper->dump($value));
}
$att = $att ? ', '.implode(' ', $att) : '';
$tagsCode .= sprintf(" - { name: %s%s }\n", Yaml::dump($name), $att);
$tagsCode .= sprintf(" - { name: %s%s }\n", $this->dumper->dump($name), $att);
}
}
if ($tagsCode) {
@ -84,15 +101,15 @@ class YamlDumper extends Dumper
}
if ($definition->getArguments()) {
$code .= sprintf(" arguments: %s\n", Yaml::dump($this->dumpValue($definition->getArguments()), 0));
$code .= sprintf(" arguments: %s\n", $this->dumper->dump($this->dumpValue($definition->getArguments()), 0));
}
if ($definition->getProperties()) {
$code .= sprintf(" properties: %s\n", Yaml::dump($this->dumpValue($definition->getProperties()), 0));
$code .= sprintf(" properties: %s\n", $this->dumper->dump($this->dumpValue($definition->getProperties()), 0));
}
if ($definition->getMethodCalls()) {
$code .= sprintf(" calls:\n %s\n", str_replace("\n", "\n ", Yaml::dump($this->dumpValue($definition->getMethodCalls()), 1)));
$code .= sprintf(" calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
}
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
@ -108,7 +125,7 @@ class YamlDumper extends Dumper
}
}
$code .= sprintf(" configurator: %s\n", Yaml::dump($callable, 0));
$code .= sprintf(" configurator: %s\n", $this->dumper->dump($callable, 0));
}
return $code;
@ -171,7 +188,7 @@ class YamlDumper extends Dumper
$parameters = $this->container->getParameterBag()->all();
}
return Yaml::dump(array('parameters' => $parameters), 2);
return $this->dumper->dump(array('parameters' => $parameters), 2);
}
/**

View File

@ -104,6 +104,7 @@ class ProjectServiceContainer extends Container
protected function getFooBarService()
{
$class = $this->getParameter('foo_class');
return $this->services['foo_bar'] = new $class();
}

View File

@ -2,8 +2,6 @@
namespace Symfony\Component\Form\Tests\Fixtures;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

View File

@ -120,6 +120,7 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
if (!$this->memcache->replace($this->prefix.$sessionId, $data, 0, $this->memcacheOptions['expiretime'])) {
return $this->memcache->set($this->prefix.$sessionId, $data, 0, $this->memcacheOptions['expiretime']);
}
return true;
}

View File

@ -40,8 +40,10 @@ class MemcacheMock
{
if ('127.0.0.1' == $host && 11211 == $port) {
$this->connected = true;
return true;
}
return false;
}
@ -58,8 +60,10 @@ class MemcacheMock
{
if ('127.0.0.1' == $host && 11211 == $port) {
$this->connected = true;
return true;
}
return false;
}
@ -82,8 +86,10 @@ class MemcacheMock
{
if ('127.0.0.1' == $host && 11211 == $port) {
$this->connected = true;
return true;
}
return false;
}
@ -105,8 +111,10 @@ class MemcacheMock
if (!isset($this->storage[$key])) {
$this->storeData($key, $var);
return true;
}
return false;
}
@ -127,6 +135,7 @@ class MemcacheMock
}
$this->storeData($key, $var);
return true;
}
@ -148,8 +157,10 @@ class MemcacheMock
if (isset($this->storage[$key])) {
$this->storeData($key, $var);
return true;
}
return false;
}
@ -174,6 +185,7 @@ class MemcacheMock
$result[] = $this->getData($k);
}
}
return $result;
}
@ -195,8 +207,10 @@ class MemcacheMock
if (isset($this->storage[$key])) {
unset($this->storage[$key]);
return true;
}
return false;
}
@ -212,6 +226,7 @@ class MemcacheMock
}
$this->storage = array();
return true;
}
@ -223,6 +238,7 @@ class MemcacheMock
public function close()
{
$this->connected = false;
return true;
}
@ -231,12 +247,14 @@ class MemcacheMock
if (isset($this->storage[$key])) {
return unserialize($this->storage[$key]);
}
return false;
}
private function storeData($key, $value)
{
$this->storage[$key] = serialize($value);
return true;
}
}

View File

@ -53,8 +53,10 @@ class MemcachedMock
{
if ('127.0.0.1' == $host && 11211 == $port) {
$this->connected = true;
return true;
}
return false;
}
@ -75,8 +77,10 @@ class MemcachedMock
if (!isset($this->storage[$key])) {
$this->storeData($key, $value);
return true;
}
return false;
}
@ -96,6 +100,7 @@ class MemcachedMock
}
$this->storeData($key, $value);
return true;
}
@ -116,8 +121,10 @@ class MemcachedMock
if (isset($this->storage[$key])) {
$this->storeData($key, $value);
return true;
}
return false;
}
@ -155,8 +162,10 @@ class MemcachedMock
if (isset($this->storage[$key])) {
$this->storeData($key, $this->getData($key).$value);
return true;
}
return false;
}
@ -175,8 +184,10 @@ class MemcachedMock
if (isset($this->storage[$key])) {
unset($this->storage[$key]);
return true;
}
return false;
}
@ -192,6 +203,7 @@ class MemcachedMock
}
$this->storage = array();
return true;
}
@ -200,12 +212,14 @@ class MemcachedMock
if (isset($this->storage[$key])) {
return unserialize($this->storage[$key]);
}
return false;
}
private function storeData($key, $value)
{
$this->storage[$key] = serialize($value);
return true;
}
}

View File

@ -41,8 +41,10 @@ class RedisMock
{
if ('127.0.0.1' == $host && 6379 == $port) {
$this->connected = true;
return true;
}
return false;
}
@ -95,6 +97,7 @@ class RedisMock
}
$this->storeData($key, $value);
return true;
}
@ -115,6 +118,7 @@ class RedisMock
if (isset($this->storage[$key])) {
return true;
}
return false;
}
@ -150,8 +154,10 @@ class RedisMock
if (isset($this->storage[$key])) {
$this->storeData($key, $this->getData($key).$value);
return strlen($this->storage[$key]);
}
return false;
}
@ -176,13 +182,16 @@ class RedisMock
++$result;
}
}
return $result;
}
if (isset($this->storage[$key])) {
unset($this->storage[$key]);
return 1;
}
return 0;
}
@ -198,6 +207,7 @@ class RedisMock
}
$this->storage = array();
return true;
}
@ -209,6 +219,7 @@ class RedisMock
public function close()
{
$this->connected = false;
return true;
}
@ -217,12 +228,14 @@ class RedisMock
if (isset($this->storage[$key])) {
return unserialize($this->storage[$key]);
}
return false;
}
private function storeData($key, $value)
{
$this->storage[$key] = serialize($value);
return true;
}
}

View File

@ -231,6 +231,7 @@ EOF;
goto $gotoname;
}
EOF;
} else {
$methods = implode("', '", $methods);
@ -240,6 +241,7 @@ EOF;
goto $gotoname;
}
EOF;
}
}
@ -250,6 +252,7 @@ EOF;
return \$this->redirect(\$pathinfo.'/', '$name');
}
EOF;
}
@ -263,6 +266,7 @@ EOF;
return \$this->redirect(\$pathinfo, '$name', '$scheme');
}
EOF;
}
@ -271,7 +275,7 @@ EOF;
$code .= sprintf(" return array_merge(\$this->mergeDefaults(\$matches, %s), array('_route' => '%s'));\n"
, str_replace("\n", '', var_export($compiledRoute->getDefaults(), true)), $name);
} elseif (true === $matches) {
$code .= sprintf(" \$matches['_route'] = '%s';\n", $name);
$code .= sprintf(" \$matches['_route'] = '%s';\n\n", $name);
$code .= " return \$matches;\n";
} elseif ($compiledRoute->getDefaults()) {
$code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_merge($compiledRoute->getDefaults(), array('_route' => $name)), true)));

View File

@ -36,7 +36,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_bar;
}
$matches['_route'] = 'bar';
return $matches;
}
not_bar:
@ -47,7 +49,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_barhead;
}
$matches['_route'] = 'barhead';
return $matches;
}
not_barhead:
@ -70,6 +74,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// baz4
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
$matches['_route'] = 'baz4';
return $matches;
}
@ -79,7 +84,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$allow[] = 'POST';
goto not_baz5;
}
$matches['_route'] = 'baz5';
return $matches;
}
not_baz5:
@ -90,7 +97,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$allow[] = 'PUT';
goto not_bazbaz6;
}
$matches['_route'] = 'baz.baz6';
return $matches;
}
not_bazbaz6:
@ -103,6 +112,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// quoter
if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'quoter';
return $matches;
}
@ -116,12 +126,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// foo1
if (preg_match('#^/a/b\'b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo1';
return $matches;
}
// bar1
if (preg_match('#^/a/b\'b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'bar1';
return $matches;
}
@ -130,6 +142,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// overriden
if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'overriden';
return $matches;
}
@ -137,12 +150,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// foo2
if (preg_match('#^/a/b\'b/(?<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo2';
return $matches;
}
// bar2
if (preg_match('#^/a/b\'b/(?<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'bar2';
return $matches;
}
@ -171,12 +186,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// foo3
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo3';
return $matches;
}
// bar3
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'bar3';
return $matches;
}
@ -188,6 +205,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// foo4
if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo4';
return $matches;
}
@ -201,12 +219,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// b
if (preg_match('#^/a/b/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'b';
return $matches;
}
// c
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'c';
return $matches;
}

View File

@ -36,7 +36,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_bar;
}
$matches['_route'] = 'bar';
return $matches;
}
not_bar:
@ -47,7 +49,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_barhead;
}
$matches['_route'] = 'barhead';
return $matches;
}
not_barhead:
@ -67,6 +71,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'baz3');
}
return array('_route' => 'baz3');
}
@ -75,7 +80,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'baz4');
}
$matches['_route'] = 'baz4';
return $matches;
}
@ -85,7 +92,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$allow[] = 'POST';
goto not_baz5;
}
$matches['_route'] = 'baz5';
return $matches;
}
not_baz5:
@ -96,7 +105,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$allow[] = 'PUT';
goto not_bazbaz6;
}
$matches['_route'] = 'baz.baz6';
return $matches;
}
not_bazbaz6:
@ -109,6 +120,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// quoter
if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'quoter';
return $matches;
}
@ -122,12 +134,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// foo1
if (preg_match('#^/a/b\'b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo1';
return $matches;
}
// bar1
if (preg_match('#^/a/b\'b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'bar1';
return $matches;
}
@ -136,6 +150,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// overriden
if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'overriden';
return $matches;
}
@ -143,12 +158,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// foo2
if (preg_match('#^/a/b\'b/(?<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo2';
return $matches;
}
// bar2
if (preg_match('#^/a/b\'b/(?<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'bar2';
return $matches;
}
@ -172,6 +189,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'hey');
}
return array('_route' => 'hey');
}
@ -180,12 +198,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// foo3
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo3';
return $matches;
}
// bar3
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'bar3';
return $matches;
}
@ -197,6 +217,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// foo4
if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'foo4';
return $matches;
}
@ -210,12 +231,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
// b
if (preg_match('#^/a/b/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'b';
return $matches;
}
// c
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'c';
return $matches;
}
@ -228,6 +251,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
if ($this->context->getScheme() !== 'https') {
return $this->redirect($pathinfo, 'secure', 'https');
}
return array('_route' => 'secure');
}
@ -236,6 +260,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
if ($this->context->getScheme() !== 'http') {
return $this->redirect($pathinfo, 'nonsecure', 'http');
}
return array('_route' => 'nonsecure');
}

View File

@ -34,6 +34,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
// dynamic
if (preg_match('#^/rootprefix/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
$matches['_route'] = 'dynamic';
return $matches;
}

View File

@ -134,6 +134,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
foreach ($bars as $bar) {
$foos .= $bar->getFoo();
}
return $foos;
},
),

View File

@ -54,7 +54,7 @@ class EmailValidator extends ConstraintValidator
// Check for host DNS resource records
if ($valid && $constraint->checkMX) {
$valid = $this->checkMX($host);
} else if ($valid && $constraint->checkHost) {
} elseif ($valid && $constraint->checkHost) {
$valid = $this->checkHost($host);
}
}