Commit 90a48a9f authored by webchick's avatar webchick

Issue #1764342 by Rob Loach: Update Symfony and Doctrine to RC2.

parent c69d5cf9
......@@ -3,35 +3,35 @@
"packages": [
{
"package": "doctrine/common",
"version": "2.3.0-RC1"
"version": "2.3.0-RC2"
},
{
"package": "symfony/class-loader",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "symfony/dependency-injection",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "symfony/event-dispatcher",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "symfony/http-foundation",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "symfony/http-kernel",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "symfony/routing",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "symfony/yaml",
"version": "v2.1.0-RC1"
"version": "v2.1.0-RC2"
},
{
"package": "twig/twig",
......
# SimpleTest breaks with the following files, so avoid adding them.
symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php
symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/php5.4/traits.php
symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php
<?php
// autoload.php generated by Composer
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
require __DIR__ . '/composer' . '/ClassLoader.php';
}
return call_user_func(function() {
$loader = new \Composer\Autoload\ClassLoader();
$composerDir = __DIR__ . '/composer';
require_once __DIR__ . '/composer' . '/autoload_real.php';
$map = require $composerDir . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
}
$classMap = require $composerDir . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register();
return $loader;
});
return ComposerAutoloaderInit::getLoader();
......@@ -201,5 +201,7 @@ public function findFile($class)
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
return $file;
}
$this->classMap[$class] = false;
}
}
<?php
// autoload_namespace.php generated by Composer
// autoload_namespaces.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
......
<?php
// autoload_real.php generated by Composer
require __DIR__ . '/ClassLoader.php';
class ComposerAutoloaderInit
{
public static function getLoader()
{
$loader = new \Composer\Autoload\ClassLoader();
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register();
return $loader;
}
}
This diff is collapsed.
{
"name": "doctrine/common",
"type": "library","version":"2.3.0-RC1",
"type": "library","version":"2.3.0-RC2",
"description": "Common Library for Doctrine projects",
"keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"],
"homepage": "http://www.doctrine-project.org",
......
......@@ -68,7 +68,8 @@ class AnnotationReader implements Reader
'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true,
'Required' => true, 'Attribute' => true, 'Attributes' => true,
'Target' => true, 'SuppressWarnings' => true,
'ingroup' => true, 'code' => true, 'endcode' => true
'ingroup' => true, 'code' => true, 'endcode' => true,
'package_version' => true,
);
/**
......
......@@ -496,15 +496,5 @@ public function matching(Criteria $criteria)
return new static($filtered);
}
/**
* Return the expression builder.
*
* @return ExpressionBuilder
*/
public function expr()
{
return new ExpressionBuilder();
}
}
......@@ -20,6 +20,7 @@
namespace Doctrine\Common\Collections;
use Doctrine\Common\Collections\Expr\Expression;
use Doctrine\Common\Collections\Expr\CompositeExpression;
/**
* Criteria for filtering Selectable collections.
......@@ -39,6 +40,11 @@ class Criteria
*/
const DESC = 'DESC';
/**
* @var \Doctrine\Common\Collections\ExpressionBuilder
*/
private static $expressionBuilder;
/**
* @var \Doctrine\Common\Collections\Expr\Expression
*/
......@@ -59,6 +65,29 @@ class Criteria
*/
private $maxResults;
/**
* Creates an instance of the class.
*
* @return Criteria
*/
public static function create()
{
return new static();
}
/**
* Return the expression builder.
*
* @return \Doctrine\Common\Collections\ExpressionBuilder
*/
public static function expr()
{
if (self::$expressionBuilder === null) {
self::$expressionBuilder = new ExpressionBuilder();
}
return self::$expressionBuilder;
}
/**
* Construct new criteria
*
......@@ -87,6 +116,46 @@ public function where(Expression $expression)
return $this;
}
/**
* Append the where expression to evaluate when this criteria is searched for
* using an AND with previous expression.
*
* @param Expression
* @return Criteria
*/
public function andWhere(Expression $expression)
{
if ($this->expression === null) {
return $this->where($expression);
}
$this->expression = new CompositeExpression(CompositeExpression::TYPE_AND, array(
$this->expression, $expression
));
return $this;
}
/**
* Append the where expression to evaluate when this criteria is searched for
* using an OR with previous expression.
*
* @param Expression
* @return Criteria
*/
public function orWhere(Expression $expression)
{
if ($this->expression === null) {
return $this->where($expression);
}
$this->expression = new CompositeExpression(CompositeExpression::TYPE_OR, array(
$this->expression, $expression
));
return $this;
}
/**
* Get the expression attached to this criteria.
*
......
......@@ -44,12 +44,5 @@ interface Selectable
* @return Collection
*/
function matching(Criteria $criteria);
/**
* Return the expression builder.
*
* @return \Doctrine\Common\Collections\ExpressionBuilder
*/
function expr();
}
......@@ -36,7 +36,7 @@ class Version
/**
* Current Doctrine Version
*/
const VERSION = '2.3.0-RC1';
const VERSION = '2.3.0-RC2';
/**
* Compares a Doctrine version with the current one.
......
......@@ -212,7 +212,7 @@ public function testMatching()
{
$this->fillMatchingFixture();
$col = $this->_coll->matching(new Criteria($this->_coll->expr()->eq("foo", "bar")));
$col = $this->_coll->matching(new Criteria(Criteria::expr()->eq("foo", "bar")));
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $col);
$this->assertNotSame($col, $this->_coll);
$this->assertEquals(1, count($col));
......
......@@ -3,9 +3,17 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\Comparison;
use Doctrine\Common\Collections\Expr\CompositeExpression;
class CriteriaTest extends \PHPUnit_Framework_TestCase
{
public function testCreate()
{
$criteria = Criteria::create();
$this->assertInstanceOf("Doctrine\Common\Collections\Criteria", $criteria);
}
public function testConstructor()
{
$expr = new Comparison("field", "=", "value");
......@@ -27,12 +35,48 @@ public function testWhere()
$this->assertSame($expr, $criteria->getWhereExpression());
}
public function testOrderings()
public function testAndWhere()
{
$expr = new Comparison("field", "=", "value");
$criteria = new Criteria();
$criteria->orderBy(array("foo" => "ASC"));
$criteria->where($expr);
$expr = $criteria->getWhereExpression();
$criteria->andWhere($expr);
$where = $criteria->getWhereExpression();
$this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $where);
$this->assertEquals(CompositeExpression::TYPE_AND, $where->getType());
$this->assertSame(array($expr, $expr), $where->getExpressionList());
}
public function testOrWhere()
{
$expr = new Comparison("field", "=", "value");
$criteria = new Criteria();
$criteria->where($expr);
$expr = $criteria->getWhereExpression();
$criteria->orWhere($expr);
$where = $criteria->getWhereExpression();
$this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $where);
$this->assertEquals(CompositeExpression::TYPE_OR, $where->getType());
$this->assertSame(array($expr, $expr), $where->getExpressionList());
}
public function testOrderings()
{
$criteria = Criteria::create()
->orderBy(array("foo" => "ASC"));
$this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings());
}
public function testExpr()
{
$this->assertInstanceOf('Doctrine\Common\Collections\ExpressionBuilder', Criteria::expr());
}
}
......@@ -15,6 +15,28 @@
class ClassLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testGetPrefixes()
{
$loader = new ClassLoader();
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertArrayNotHasKey('Foo1', $prefixes);
$this->assertArrayHasKey('Bar', $prefixes);
$this->assertArrayHasKey('Bas', $prefixes);
}
public function testGetFallbackDirs()
{
$loader = new ClassLoader();
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$fallback_dirs = $loader->getFallbackDirs();
$this->assertCount(2, $fallback_dirs);
}
/**
* @dataProvider getLoadClassTests
*/
......@@ -37,6 +59,35 @@ public function getLoadClassTests()
);
}
/**
* @dataProvider getLoadNonexistentClassTests
*/
public function testLoadNonexistentClass($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->loadClass($testClassName);
$this->assertFalse(class_exists($className), $message);
}
public function getLoadNonexistentClassTests()
{
return array(
array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non exising Pearlike3_Bar class with a leading slash'),
);
}
public function testAddPrefix()
{
$loader = new ClassLoader();
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertCount(2, $prefixes['Foo']);
}
public function testUseIncludePath()
{
$loader = new ClassLoader();
......
......@@ -15,6 +15,50 @@
class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
{
/**
* @var string $workspace
*/
private $workspace = null;
public function prepare_workspace()
{
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
mkdir($this->workspace, 0777, true);
$this->workspace = realpath($this->workspace);
}
/**
* @param string $file
*/
private function clean($file)
{
if (is_dir($file) && !is_link($file)) {
$dir = new \FilesystemIterator($file);
foreach ($dir as $childFile) {
$this->clean($childFile);
}
rmdir($file);
} else {
unlink($file);
}
}
/**
* @dataProvider getTestCreateMapTests
*/
public function testDump($directory, $expected)
{
$this->prepare_workspace();
$file = $this->workspace.'/file';
$generator = new ClassMapGenerator();
$generator->dump($directory, $file);
$this->assertFileExists($file);
$this->clean($this->workspace);
}
/**
* @dataProvider getTestCreateMapTests
......
......@@ -56,6 +56,32 @@ public function testUseIncludePath()
set_include_path($includePath);
}
public function testGetNamespaces()
{
$loader = new UniversalClassLoader();
$loader->registerNamespace('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->registerNamespace('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->registerNamespace('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$namespaces = $loader->getNamespaces();
$this->assertArrayHasKey('Foo', $namespaces);
$this->assertArrayNotHasKey('Foo1', $namespaces);
$this->assertArrayHasKey('Bar', $namespaces);
$this->assertArrayHasKey('Bas', $namespaces);
}
public function testGetPrefixes()
{
$loader = new UniversalClassLoader();
$loader->registerPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->registerPrefix('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->registerPrefix('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertArrayNotHasKey('Foo1', $prefixes);
$this->assertArrayHasKey('Bar', $prefixes);
$this->assertArrayHasKey('Bas', $prefixes);
}
/**
* @dataProvider getLoadClassFromFallbackTests
*/
......
......@@ -26,6 +26,7 @@
"psr-0": { "Symfony\\Component\\ClassLoader": "" }
},
"target-dir": "Symfony/Component/ClassLoader",
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
......
......@@ -694,7 +694,13 @@ private function addFrozenConstructor()
*/
public function __construct()
{
\$this->parameters = \$this->getDefaultParameters();
EOF;
if ($this->container->getParameterBag()->all()) {
$code .= "\n \$this->parameters = \$this->getDefaultParameters();\n";
}
$code .= <<<EOF
\$this->services =
\$this->scopedServices =
......
......@@ -204,14 +204,28 @@ private function parseDefinition($id, $service, $file)
*/
private function parseFile($file)
{
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
libxml_clear_errors();
$dom = new \DOMDocument();
libxml_use_internal_errors(true);
if (!$dom->load($file, defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0)) {
throw new InvalidArgumentException(implode("\n", $this->getXmlErrors()));
}
$dom->validateOnParse = true;
if (!$dom->loadXML(file_get_contents($file), LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
libxml_disable_entity_loader($disableEntities);
throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors($internalErrors)));
}
$dom->normalizeDocument();
libxml_use_internal_errors(false);
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
throw new \InvalidArgumentException('Document types are not allowed.');
}
}
$this->validate($dom, $file);
return simplexml_import_dom($dom, 'Symfony\\Component\\DependencyInjection\\SimpleXMLElement');
......@@ -345,12 +359,15 @@ private function validateSchema(\DOMDocument $dom, $file)
;
$current = libxml_use_internal_errors(true);
libxml_clear_errors();
$valid = @$dom->schemaValidateSource($source);
foreach ($tmpfiles as $tmpfile) {
@unlink($tmpfile);
}
if (!$valid) {
throw new InvalidArgumentException(implode("\n", $this->getXmlErrors()));
throw new InvalidArgumentException(implode("\n", $this->getXmlErrors($current)));
}
libxml_use_internal_errors($current);
}
......@@ -389,7 +406,7 @@ private function validateExtensions(\DOMDocument $dom, $file)
*
* @return array
*/
private function getXmlErrors()
private function getXmlErrors($internalErrors)
{
$errors = array();
foreach (libxml_get_errors() as $error) {
......@@ -404,6 +421,7 @@ private function getXmlErrors()
}
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
return $errors;
}
......
......@@ -44,6 +44,20 @@ public function testDump()
new PhpDumper($container);
}
public function testDumpFrozenContainerWithNoParameter()
{
$container = new ContainerBuilder();
$container->register('foo', 'stdClass');
$container->compile();
$dumper = new PhpDumper($container);
$dumpedString = $dumper->dump();
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.');
$this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.');
}
public function testDumpOptimizationString()
{
$definition = new Definition();
......
......@@ -328,4 +328,16 @@ public function testNoNamingConflictsForAnonymousServices()
$inner2 = $services[(string) $args2[0]];
$this->assertEquals('BarClass2', $inner2->getClass(), '->load() uses the same configuration as for the anonymous ones');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Document types are not allowed.
*/
public function testDocTypeIsNotAllowed()
{
$container = new ContainerBuilder();
$loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$loader1->load('withdoctype.xml');
}
}
......@@ -30,6 +30,7 @@
"psr-0": { "Symfony\\Component\\DependencyInjection": "" }
},
"target-dir": "Symfony/Component/DependencyInjection",
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
......
......@@ -18,7 +18,7 @@
*
* @author Drak <drak@zikula.org>
*/
class GenericEvent extends Event implements \ArrayAccess
class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
{
/**
* Observer pattern subject.
......@@ -177,4 +177,14 @@ public function offsetExists($key)
{
return $this->hasArgument($key);
}
/**
* IteratorAggregate for iterating over the object like an array
*
* @return \ArrayIterator
*/
public function <