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 @@ ...@@ -3,35 +3,35 @@
"packages": [ "packages": [
{ {
"package": "doctrine/common", "package": "doctrine/common",
"version": "2.3.0-RC1" "version": "2.3.0-RC2"
}, },
{ {
"package": "symfony/class-loader", "package": "symfony/class-loader",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "symfony/dependency-injection", "package": "symfony/dependency-injection",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "symfony/event-dispatcher", "package": "symfony/event-dispatcher",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "symfony/http-foundation", "package": "symfony/http-foundation",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "symfony/http-kernel", "package": "symfony/http-kernel",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "symfony/routing", "package": "symfony/routing",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "symfony/yaml", "package": "symfony/yaml",
"version": "v2.1.0-RC1" "version": "v2.1.0-RC2"
}, },
{ {
"package": "twig/twig", "package": "twig/twig",
......
# SimpleTest breaks with the following files, so avoid adding them. # SimpleTest breaks with the following files, so avoid adding them.
symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php 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/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/php5.4/traits.php
symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php
<?php <?php
// autoload.php generated by Composer // autoload.php generated by Composer
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
require __DIR__ . '/composer' . '/ClassLoader.php';
}
return call_user_func(function() { require_once __DIR__ . '/composer' . '/autoload_real.php';
$loader = new \Composer\Autoload\ClassLoader();
$composerDir = __DIR__ . '/composer';
$map = require $composerDir . '/autoload_namespaces.php'; return ComposerAutoloaderInit::getLoader();
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
}
$classMap = require $composerDir . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register();
return $loader;
});
...@@ -201,5 +201,7 @@ public function findFile($class) ...@@ -201,5 +201,7 @@ public function findFile($class)
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) { if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
return $file; return $file;
} }
$this->classMap[$class] = false;
} }
} }
<?php <?php
// autoload_namespace.php generated by Composer // autoload_namespaces.php generated by Composer
$vendorDir = dirname(__DIR__); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $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", "name": "doctrine/common",
"type": "library","version":"2.3.0-RC1", "type": "library","version":"2.3.0-RC2",
"description": "Common Library for Doctrine projects", "description": "Common Library for Doctrine projects",
"keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"], "keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"],
"homepage": "http://www.doctrine-project.org", "homepage": "http://www.doctrine-project.org",
......
...@@ -68,7 +68,8 @@ class AnnotationReader implements Reader ...@@ -68,7 +68,8 @@ class AnnotationReader implements Reader
'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true, 'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true,
'Required' => true, 'Attribute' => true, 'Attributes' => true, 'Required' => true, 'Attribute' => true, 'Attributes' => true,
'Target' => true, 'SuppressWarnings' => 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) ...@@ -496,15 +496,5 @@ public function matching(Criteria $criteria)
return new static($filtered); return new static($filtered);
} }
/**
* Return the expression builder.
*
* @return ExpressionBuilder
*/
public function expr()
{
return new ExpressionBuilder();
}
} }
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace Doctrine\Common\Collections; namespace Doctrine\Common\Collections;
use Doctrine\Common\Collections\Expr\Expression; use Doctrine\Common\Collections\Expr\Expression;
use Doctrine\Common\Collections\Expr\CompositeExpression;
/** /**
* Criteria for filtering Selectable collections. * Criteria for filtering Selectable collections.
...@@ -39,6 +40,11 @@ class Criteria ...@@ -39,6 +40,11 @@ class Criteria
*/ */
const DESC = 'DESC'; const DESC = 'DESC';
/**
* @var \Doctrine\Common\Collections\ExpressionBuilder
*/
private static $expressionBuilder;
/** /**
* @var \Doctrine\Common\Collections\Expr\Expression * @var \Doctrine\Common\Collections\Expr\Expression
*/ */
...@@ -59,6 +65,29 @@ class Criteria ...@@ -59,6 +65,29 @@ class Criteria
*/ */
private $maxResults; 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 * Construct new criteria
* *
...@@ -87,6 +116,46 @@ public function where(Expression $expression) ...@@ -87,6 +116,46 @@ public function where(Expression $expression)
return $this; 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. * Get the expression attached to this criteria.
* *
......
...@@ -44,12 +44,5 @@ interface Selectable ...@@ -44,12 +44,5 @@ interface Selectable
* @return Collection * @return Collection
*/ */
function matching(Criteria $criteria); function matching(Criteria $criteria);
/**
* Return the expression builder.
*
* @return \Doctrine\Common\Collections\ExpressionBuilder
*/
function expr();
} }
...@@ -36,7 +36,7 @@ class Version ...@@ -36,7 +36,7 @@ class Version
/** /**
* Current Doctrine Version * Current Doctrine Version
*/ */
const VERSION = '2.3.0-RC1'; const VERSION = '2.3.0-RC2';
/** /**
* Compares a Doctrine version with the current one. * Compares a Doctrine version with the current one.
......
...@@ -212,7 +212,7 @@ public function testMatching() ...@@ -212,7 +212,7 @@ public function testMatching()
{ {
$this->fillMatchingFixture(); $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->assertInstanceOf('Doctrine\Common\Collections\Collection', $col);
$this->assertNotSame($col, $this->_coll); $this->assertNotSame($col, $this->_coll);
$this->assertEquals(1, count($col)); $this->assertEquals(1, count($col));
......
...@@ -3,9 +3,17 @@ ...@@ -3,9 +3,17 @@
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Collections\Expr\Comparison;
use Doctrine\Common\Collections\Expr\CompositeExpression;
class CriteriaTest extends \PHPUnit_Framework_TestCase class CriteriaTest extends \PHPUnit_Framework_TestCase
{ {
public function testCreate()
{
$criteria = Criteria::create();
$this->assertInstanceOf("Doctrine\Common\Collections\Criteria", $criteria);
}
public function testConstructor() public function testConstructor()
{ {
$expr = new Comparison("field", "=", "value"); $expr = new Comparison("field", "=", "value");
...@@ -27,12 +35,48 @@ public function testWhere() ...@@ -27,12 +35,48 @@ public function testWhere()
$this->assertSame($expr, $criteria->getWhereExpression()); $this->assertSame($expr, $criteria->getWhereExpression());
} }
public function testOrderings() public function testAndWhere()
{ {
$expr = new Comparison("field", "=", "value");
$criteria = new Criteria(); $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()); $this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings());
} }
public function testExpr()
{
$this->assertInstanceOf('Doctrine\Common\Collections\ExpressionBuilder', Criteria::expr());
}
} }
...@@ -15,6 +15,28 @@ ...@@ -15,6 +15,28 @@
class ClassLoaderTest extends \PHPUnit_Framework_TestCase 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 * @dataProvider getLoadClassTests
*/ */
...@@ -37,6 +59,35 @@ public function 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() public function testUseIncludePath()
{ {
$loader = new ClassLoader(); $loader = new ClassLoader();
......
...@@ -15,6 +15,50 @@ ...@@ -15,6 +15,50 @@
class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase 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 * @dataProvider getTestCreateMapTests
......
...@@ -56,6 +56,32 @@ public function testUseIncludePath() ...@@ -56,6 +56,32 @@ public function testUseIncludePath()
set_include_path($includePath); 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 * @dataProvider getLoadClassFromFallbackTests
*/ */
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"psr-0": { "Symfony\\Component\\ClassLoader": "" } "psr-0": { "Symfony\\Component\\ClassLoader": "" }
}, },
"target-dir": "Symfony/Component/ClassLoader", "target-dir": "Symfony/Component/ClassLoader",
"minimum-stability": "dev",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.1-dev" "dev-master": "2.1-dev"
......
...@@ -694,7 +694,13 @@ private function addFrozenConstructor() ...@@ -694,7 +694,13 @@ private function addFrozenConstructor()
*/