From e1421bedb2638e3378fc7264351601223d803f70 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 Mar 2010 05:29:45 +0800 Subject: [PATCH 01/54] [DoctrineBundle] fixed the overridding of an Entity --- .../DependencyInjection/DoctrineExtension.php | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php index f53560582e132..8d5a9cdf28a82 100644 --- a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php +++ b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php @@ -201,7 +201,7 @@ public function ormLoad($config) $bundleEntityMappings = array(); $bundleDirs = $this->bundleDirs; $aliasMap = array(); - foreach ($this->bundles as $className) + foreach (array_reverse($this->bundles) as $className) { $tmp = dirname(str_replace('\\', '/', $className)); $namespace = str_replace('/', '\\', dirname($tmp)); @@ -209,27 +209,29 @@ public function ormLoad($config) if (isset($bundleDirs[$namespace])) { - $type = false; - if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata')) - { - $type = $this->detectMappingType($dir); - } - - if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities')) - { - $type = 'annotation'; - - $aliasMap[$class] = $namespace.'\\'.$class.'\\Entities'; - } - - if (false !== $type) - { - $mappingDriverDef->addMethodCall('addDriver', array( - new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)), - $namespace.'\\'.$class.'\\Entities' - ) - ); - } + continue; + } + + $type = false; + if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata')) + { + $type = $this->detectMappingType($dir); + } + + if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities')) + { + $type = 'annotation'; + + $aliasMap[$class] = $namespace.'\\'.$class.'\\Entities'; + } + + if (false !== $type) + { + $mappingDriverDef->addMethodCall('addDriver', array( + new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)), + $namespace.'\\'.$class.'\\Entities' + ) + ); } } $ormConfigDef->addMethodCall('setEntityNamespaces', array($aliasMap)); From de14a8614c8764fdc9e7188166160971504ade86 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 Mar 2010 05:41:05 +0800 Subject: [PATCH 02/54] [DoctrineBundle] fixed typo --- .../DoctrineBundle/DependencyInjection/DoctrineExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php index 8d5a9cdf28a82..5ba85edf8bf32 100644 --- a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php +++ b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php @@ -207,7 +207,7 @@ public function ormLoad($config) $namespace = str_replace('/', '\\', dirname($tmp)); $class = basename($tmp); - if (isset($bundleDirs[$namespace])) + if (!isset($bundleDirs[$namespace])) { continue; } From 6426441d5943567f88b3a5f22f30a3ea7fa523e1 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Thu, 11 Mar 2010 11:14:55 +0800 Subject: [PATCH 03/54] [DoctrineBundle] Fixing issue with paths not being the realpath and causing issues when comparing string paths in Doctrine --- src/Symfony/Framework/DoctrineBundle/Bundle.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Framework/DoctrineBundle/Bundle.php b/src/Symfony/Framework/DoctrineBundle/Bundle.php index 7b5baa0beee87..01b7b9f845feb 100644 --- a/src/Symfony/Framework/DoctrineBundle/Bundle.php +++ b/src/Symfony/Framework/DoctrineBundle/Bundle.php @@ -43,11 +43,11 @@ public function buildContainer(ContainerInterface $container) { if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata')) { - $metadataDirs[] = $dir; + $metadataDirs[] = realpath($dir); } if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities')) { - $entityDirs[] = $dir; + $entityDirs[] = realpath($dir); } } } From 032752e59565dede50be8f13424f067ce038a849 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Mar 2010 18:22:19 +0800 Subject: [PATCH 04/54] [Foundation] fixed typo --- src/Symfony/Foundation/Kernel.php | 12 ++++++------ src/Symfony/Foundation/bootstrap.php | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 0c521d32cfd51..19c1b10c6d58f 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -281,17 +281,17 @@ protected function buildContainer($class, $file, $parameters) foreach (array('cache', 'logs') as $name) { - $key = sprintf('kernel.%s_dir', $name); - if (!is_dir($parameters[$key])) + $dir = $parameters[sprintf('kernel.%s_dir', $name)]; + if (!is_dir($dir)) { - if (false === @mkdir($parameters[$key], 0777, true)) + if (false === @mkdir($dir, 0777, true)) { - die(sprintf('Unable to create the %s directory (%s)', $name, dirname($parameters['kernel.cache_dir']))); + die(sprintf('Unable to create the %s directory (%s)', $name, dirname($dir))); } } - elseif (!is_writable($parameters[$key])) + elseif (!is_writable($dir)) { - die(sprintf('Unable to write in the %s directory (%s)', $name, $parameters['kernel.cache_dir'])); + die(sprintf('Unable to write in the %s directory (%s)', $name, $dir)); } } diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index f1e3232915335..3fa2f86db3630 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -461,7 +461,7 @@ public function getStartTime() public function getParameters() { - return $parameters; + return $this->parameters; } public function getDefaultParameters() @@ -557,17 +557,17 @@ protected function buildContainer($class, $file, $parameters) foreach (array('cache', 'logs') as $name) { - $key = sprintf('kernel.%s_dir', $name); - if (!is_dir($parameters[$key])) + $dir = $parameters[sprintf('kernel.%s_dir', $name)]; + if (!is_dir($dir)) { - if (false === @mkdir($parameters[$key], 0777, true)) + if (false === @mkdir($dir, 0777, true)) { - die(sprintf('Unable to create the %s directory (%s)', $name, dirname($parameters['kernel.cache_dir']))); + die(sprintf('Unable to create the %s directory (%s)', $name, dirname($dir))); } } - elseif (!is_writable($parameters[$key])) + elseif (!is_writable($dir)) { - die(sprintf('Unable to write in the %s directory (%s)', $name, $parameters['kernel.cache_dir'])); + die(sprintf('Unable to write in the %s directory (%s)', $name, $dir)); } } From 9c4a1f3dded007c1afb34a8769a6bad3970ecc2b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Mar 2010 18:54:22 +0800 Subject: [PATCH 05/54] [Foundation] made some performance optimizations (if you change a parameter in a .htaccess or httpd.conf, you now need to flush the cache - should not be a big deal) --- src/Symfony/Foundation/Kernel.php | 83 +++++++++++++++------------- src/Symfony/Foundation/bootstrap.php | 81 ++++++++++++++------------- 2 files changed, 89 insertions(+), 75 deletions(-) diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 19c1b10c6d58f..9ee03a2156743 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -15,6 +15,7 @@ use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\BuilderConfiguration; use Symfony\Components\DependencyInjection\Dumper\PhpDumper; +use Symfony\Components\DependencyInjection\FileResource; use Symfony\Components\RequestHandler\RequestInterface; /** @@ -34,7 +35,6 @@ abstract class Kernel protected $debug; protected $booted; protected $name; - protected $parameters; protected $startTime; const VERSION = '2.0.0-DEV'; @@ -44,9 +44,8 @@ abstract class Kernel * * @param string $environment The environment * @param Boolean $debug Whether to enable debugging or not - * @param array $parameters An array of parameters to customize the DI container */ - public function __construct($environment, $debug, $parameters = array()) + public function __construct($environment, $debug) { $this->debug = (Boolean) $debug; if ($this->debug) @@ -66,7 +65,6 @@ public function __construct($environment, $debug, $parameters = array()) $this->booted = false; $this->environment = $environment; - $this->parameters = $parameters; $this->bundles = $this->registerBundles(); $this->bundleDirs = $this->registerBundleDirs(); $this->rootDir = realpath($this->registerRootDir()); @@ -183,12 +181,33 @@ public function getStartTime() return $this->debug ? $this->startTime : -INF; } - public function getParameters() + public function getCacheDir() { - return $this->parameters; + return $this->rootDir.'/cache/'.$this->environment; } - public function getDefaultParameters() + public function getLogDir() + { + return $this->rootDir.'/logs'; + } + + protected function initializeContainer() + { + $class = $this->name.'ProjectContainer'; + $location = $this->getCacheDir().'/'.$class; + $reload = $this->debug ? $this->needsReload($class, $location) : false; + + if ($reload || !file_exists($location.'.php')) + { + $this->buildContainer($class, $location.'.php'); + } + + require_once $location.'.php'; + + return new $class(); + } + + public function getKernelParameters() { $bundles = array(); foreach ($this->bundles as $bundle) @@ -202,34 +221,16 @@ public function getDefaultParameters() 'kernel.environment' => $this->environment, 'kernel.debug' => $this->debug, 'kernel.name' => $this->name, - 'kernel.cache_dir' => $this->rootDir.'/cache/'.$this->environment, - 'kernel.logs_dir' => $this->rootDir.'/logs', + 'kernel.cache_dir' => $this->getCacheDir(), + 'kernel.logs_dir' => $this->getLogDir(), 'kernel.bundle_dirs' => $this->bundleDirs, 'kernel.bundles' => $bundles, 'kernel.charset' => 'UTF-8', ), - $this->getEnvParameters(), - $this->parameters + $this->getEnvParameters() ); } - protected function initializeContainer() - { - $parameters = $this->getDefaultParameters(); - $class = $this->name.'ProjectContainer'; - $file = $parameters['kernel.cache_dir'].'/'.$class.'.php'; - $reload = $this->debug ? $this->needsReload($class, $file, $parameters) : false; - - if ($reload || !file_exists($file)) - { - $this->buildContainer($class, $file, $parameters); - } - - require_once $file; - - return new $class(); - } - protected function getEnvParameters() { $parameters = array(); @@ -244,17 +245,15 @@ protected function getEnvParameters() return $parameters; } - protected function needsReload($class, $file, $parameters) + protected function needsReload($class, $location) { - $metadata = $parameters['kernel.cache_dir'].'/'.$class.'.meta'; - - if (!file_exists($metadata) || !file_exists($file)) + if (!file_exists($location.'.meta') || !file_exists($location.'.php')) { return true; } - $meta = unserialize(file_get_contents($metadata)); - $time = filemtime($file); + $meta = unserialize(file_get_contents($location.'.meta')); + $time = filemtime($location.'.php'); foreach ($meta as $resource) { if (!$resource->isUptodate($time)) @@ -266,9 +265,9 @@ protected function needsReload($class, $file, $parameters) return false; } - protected function buildContainer($class, $file, $parameters) + protected function buildContainer($class, $file) { - $container = new Builder($parameters); + $container = new Builder($this->getKernelParameters()); $configuration = new BuilderConfiguration(); foreach ($this->bundles as $bundle) @@ -281,7 +280,7 @@ protected function buildContainer($class, $file, $parameters) foreach (array('cache', 'logs') as $name) { - $dir = $parameters[sprintf('kernel.%s_dir', $name)]; + $dir = $container->getParameter(sprintf('kernel.%s_dir', $name)); if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true)) @@ -306,8 +305,16 @@ protected function buildContainer($class, $file, $parameters) if ($this->debug) { + // add the Kernel class hierachy as resources + $parent = new \ReflectionObject($this); + $configuration->addResource(new FileResource($parent->getFileName())); + while ($parent = $parent->getParentClass()) + { + $configuration->addResource(new FileResource($parent->getFileName())); + } + // save the resources - $this->writeCacheFile($parameters['kernel.cache_dir'].'/'.$class.'.meta', serialize($configuration->getResources())); + $this->writeCacheFile($this->getCacheDir().'/'.$class.'.meta', serialize($configuration->getResources())); } } diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index 3fa2f86db3630..aa0d7ab5026ed 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -316,6 +316,7 @@ static protected function writeCacheFile($file, $content) use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\BuilderConfiguration; use Symfony\Components\DependencyInjection\Dumper\PhpDumper; +use Symfony\Components\DependencyInjection\FileResource; use Symfony\Components\RequestHandler\RequestInterface; @@ -329,13 +330,12 @@ abstract class Kernel protected $debug; protected $booted; protected $name; - protected $parameters; protected $startTime; const VERSION = '2.0.0-DEV'; - public function __construct($environment, $debug, $parameters = array()) + public function __construct($environment, $debug) { $this->debug = (Boolean) $debug; if ($this->debug) @@ -355,7 +355,6 @@ public function __construct($environment, $debug, $parameters = array()) $this->booted = false; $this->environment = $environment; - $this->parameters = $parameters; $this->bundles = $this->registerBundles(); $this->bundleDirs = $this->registerBundleDirs(); $this->rootDir = realpath($this->registerRootDir()); @@ -459,12 +458,33 @@ public function getStartTime() return $this->debug ? $this->startTime : -INF; } - public function getParameters() + public function getCacheDir() { - return $this->parameters; + return $this->rootDir.'/cache/'.$this->environment; } - public function getDefaultParameters() + public function getLogDir() + { + return $this->rootDir.'/logs'; + } + + protected function initializeContainer() + { + $class = $this->name.'ProjectContainer'; + $location = $this->getCacheDir().'/'.$class; + $reload = $this->debug ? $this->needsReload($class, $location) : false; + + if ($reload || !file_exists($location.'.php')) + { + $this->buildContainer($class, $location.'.php'); + } + + require_once $location.'.php'; + + return new $class(); + } + + public function getKernelParameters() { $bundles = array(); foreach ($this->bundles as $bundle) @@ -478,34 +498,16 @@ public function getDefaultParameters() 'kernel.environment' => $this->environment, 'kernel.debug' => $this->debug, 'kernel.name' => $this->name, - 'kernel.cache_dir' => $this->rootDir.'/cache/'.$this->environment, - 'kernel.logs_dir' => $this->rootDir.'/logs', + 'kernel.cache_dir' => $this->getCacheDir(), + 'kernel.logs_dir' => $this->getLogDir(), 'kernel.bundle_dirs' => $this->bundleDirs, 'kernel.bundles' => $bundles, 'kernel.charset' => 'UTF-8', ), - $this->getEnvParameters(), - $this->parameters + $this->getEnvParameters() ); } - protected function initializeContainer() - { - $parameters = $this->getDefaultParameters(); - $class = $this->name.'ProjectContainer'; - $file = $parameters['kernel.cache_dir'].'/'.$class.'.php'; - $reload = $this->debug ? $this->needsReload($class, $file, $parameters) : false; - - if ($reload || !file_exists($file)) - { - $this->buildContainer($class, $file, $parameters); - } - - require_once $file; - - return new $class(); - } - protected function getEnvParameters() { $parameters = array(); @@ -520,17 +522,15 @@ protected function getEnvParameters() return $parameters; } - protected function needsReload($class, $file, $parameters) + protected function needsReload($class, $location) { - $metadata = $parameters['kernel.cache_dir'].'/'.$class.'.meta'; - - if (!file_exists($metadata) || !file_exists($file)) + if (!file_exists($location.'.meta') || !file_exists($location.'.php')) { return true; } - $meta = unserialize(file_get_contents($metadata)); - $time = filemtime($file); + $meta = unserialize(file_get_contents($location.'.meta')); + $time = filemtime($location.'.php'); foreach ($meta as $resource) { if (!$resource->isUptodate($time)) @@ -542,9 +542,9 @@ protected function needsReload($class, $file, $parameters) return false; } - protected function buildContainer($class, $file, $parameters) + protected function buildContainer($class, $file) { - $container = new Builder($parameters); + $container = new Builder($this->getKernelParameters()); $configuration = new BuilderConfiguration(); foreach ($this->bundles as $bundle) @@ -557,7 +557,7 @@ protected function buildContainer($class, $file, $parameters) foreach (array('cache', 'logs') as $name) { - $dir = $parameters[sprintf('kernel.%s_dir', $name)]; + $dir = $container->getParameter(sprintf('kernel.%s_dir', $name)); if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true)) @@ -581,7 +581,14 @@ protected function buildContainer($class, $file, $parameters) if ($this->debug) { - $this->writeCacheFile($parameters['kernel.cache_dir'].'/'.$class.'.meta', serialize($configuration->getResources())); + $parent = new \ReflectionObject($this); + $configuration->addResource(new FileResource($parent->getFileName())); + while ($parent = $parent->getParentClass()) + { + $configuration->addResource(new FileResource($parent->getFileName())); + } + + $this->writeCacheFile($this->getCacheDir().'/'.$class.'.meta', serialize($configuration->getResources())); } } From c6bef5b491efa63c61c36601c1f915f59080003d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Mar 2010 22:55:55 +0800 Subject: [PATCH 06/54] [Yaml] fixed parsing of folded scalars when a # sign starts a line --- src/Symfony/Components/Yaml/Parser.php | 7 ++--- .../Symfony/Components/Yaml/sfTests.yml | 28 +++++++++++++++++++ .../Symfony/Components/Yaml/DumperTest.php | 2 +- .../Symfony/Components/Yaml/ParserTest.php | 2 +- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index 3873c6b4d3967..4ae02e31a27c4 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -300,12 +300,9 @@ protected function getNextEmbedBlock() while ($this->moveToNextLine()) { - if ($this->isCurrentLineEmpty()) + if ($this->isCurrentLineBlank()) { - if ($this->isCurrentLineBlank()) - { - $data[] = substr($this->currentLine, $newIndent); - } + $data[] = substr($this->currentLine, $newIndent); continue; } diff --git a/tests/fixtures/Symfony/Components/Yaml/sfTests.yml b/tests/fixtures/Symfony/Components/Yaml/sfTests.yml index 8eff31c60a282..29c6100a9f420 100644 --- a/tests/fixtures/Symfony/Components/Yaml/sfTests.yml +++ b/tests/fixtures/Symfony/Components/Yaml/sfTests.yml @@ -143,3 +143,31 @@ yaml: | 0123 php: | array('foo' => "0123\n") +--- +test: Comments in folded scalars +brief: Comments in folded scalars should be kept as is +yaml: | + # comment + foo: | + # comment + bar + bar: + # comment + foo: bar # comment + bar: | + # comment + foo + foobar: + foo: | + # comment + bar + # comment +php: | + array( + 'foo' => "# comment\nbar\n", + 'bar' => array( + 'foo' => 'bar', + 'bar' => "# comment\nfoo\n", + 'foobar' => array('foo' => "# comment\nbar\n") + ) + ) diff --git a/tests/unit/Symfony/Components/Yaml/DumperTest.php b/tests/unit/Symfony/Components/Yaml/DumperTest.php index e0643ef3d47b8..bdb7514e42517 100644 --- a/tests/unit/Symfony/Components/Yaml/DumperTest.php +++ b/tests/unit/Symfony/Components/Yaml/DumperTest.php @@ -16,7 +16,7 @@ Yaml::setSpecVersion('1.1'); -$t = new LimeTest(150); +$t = new LimeTest(151); $parser = new Parser(); $dumper = new Dumper(); diff --git a/tests/unit/Symfony/Components/Yaml/ParserTest.php b/tests/unit/Symfony/Components/Yaml/ParserTest.php index ead30c7c3cebf..b5b8c7f668194 100644 --- a/tests/unit/Symfony/Components/Yaml/ParserTest.php +++ b/tests/unit/Symfony/Components/Yaml/ParserTest.php @@ -16,7 +16,7 @@ Yaml::setSpecVersion('1.1'); -$t = new LimeTest(150); +$t = new LimeTest(151); $parser = new Parser(); From 72201ac735606e3d3c6e65f3d27bdd0c1b442ff9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 13 Mar 2010 04:03:03 +0800 Subject: [PATCH 07/54] [Console] fixed fixtures --- .../Components/Console/application_astext1.txt | 12 ++++++------ .../Components/Console/application_astext2.txt | 12 ++++++------ .../Components/Console/application_gethelp.txt | 12 ++++++------ .../Symfony/Components/Console/application_run1.txt | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/fixtures/Symfony/Components/Console/application_astext1.txt b/tests/fixtures/Symfony/Components/Console/application_astext1.txt index f0b85705f0d8f..67f522a43833d 100644 --- a/tests/fixtures/Symfony/Components/Console/application_astext1.txt +++ b/tests/fixtures/Symfony/Components/Console/application_astext1.txt @@ -4,12 +4,12 @@ [options] command [arguments] Options: - --help -h Display this help message. - --quiet -q Do not output any message. - --verbose -v Increase verbosity of messages. - --version -V Display this program version. - --color -c Force ANSI color output. - --no-interaction -n Do not ask any interactive question. + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v Increase verbosity of messages. + --version -V Display this program version. + --color -c Force ANSI color output. + --no-interaction -n Do not ask any interactive question. Available commands: help Displays help for a command (?) diff --git a/tests/fixtures/Symfony/Components/Console/application_astext2.txt b/tests/fixtures/Symfony/Components/Console/application_astext2.txt index a402c66a9fb92..b4eb5b008db04 100644 --- a/tests/fixtures/Symfony/Components/Console/application_astext2.txt +++ b/tests/fixtures/Symfony/Components/Console/application_astext2.txt @@ -4,12 +4,12 @@ [options] command [arguments] Options: - --help -h Display this help message. - --quiet -q Do not output any message. - --verbose -v Increase verbosity of messages. - --version -V Display this program version. - --color -c Force ANSI color output. - --no-interaction -n Do not ask any interactive question. + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v Increase verbosity of messages. + --version -V Display this program version. + --color -c Force ANSI color output. + --no-interaction -n Do not ask any interactive question. Available commands for the "foo" namespace: :bar The foo:bar command (afoobar) \ No newline at end of file diff --git a/tests/fixtures/Symfony/Components/Console/application_gethelp.txt b/tests/fixtures/Symfony/Components/Console/application_gethelp.txt index f640ee70dc63c..10dfb7bfd1736 100644 --- a/tests/fixtures/Symfony/Components/Console/application_gethelp.txt +++ b/tests/fixtures/Symfony/Components/Console/application_gethelp.txt @@ -4,9 +4,9 @@ [options] command [arguments] Options: - --help -h Display this help message. - --quiet -q Do not output any message. - --verbose -v Increase verbosity of messages. - --version -V Display this program version. - --color -c Force ANSI color output. - --no-interaction -n Do not ask any interactive question. \ No newline at end of file + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v Increase verbosity of messages. + --version -V Display this program version. + --color -c Force ANSI color output. + --no-interaction -n Do not ask any interactive question. \ No newline at end of file diff --git a/tests/fixtures/Symfony/Components/Console/application_run1.txt b/tests/fixtures/Symfony/Components/Console/application_run1.txt index 4c7e4204fb31f..e258207fad918 100644 --- a/tests/fixtures/Symfony/Components/Console/application_run1.txt +++ b/tests/fixtures/Symfony/Components/Console/application_run1.txt @@ -4,12 +4,12 @@ Usage: [options] command [arguments] Options: - --help -h Display this help message. - --quiet -q Do not output any message. - --verbose -v Increase verbosity of messages. - --version -V Display this program version. - --color -c Force ANSI color output. - --no-interaction -n Do not ask any interactive question. + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v Increase verbosity of messages. + --version -V Display this program version. + --color -c Force ANSI color output. + --no-interaction -n Do not ask any interactive question. Available commands: help Displays help for a command (?) From 071ef702389115064ea3d355ef57d7bf5d213f05 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 13 Mar 2010 21:29:56 +0800 Subject: [PATCH 08/54] [Templating] added missing use statement --- src/Symfony/Components/Templating/Engine.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Components/Templating/Engine.php b/src/Symfony/Components/Templating/Engine.php index 8fff1dcf96b6f..75a332d2a7819 100644 --- a/src/Symfony/Components/Templating/Engine.php +++ b/src/Symfony/Components/Templating/Engine.php @@ -5,6 +5,7 @@ use Symfony\Components\Templating\Loader\LoaderInterface; use Symfony\Components\Templating\Renderer\PhpRenderer; use Symfony\Components\Templating\Renderer\RendererInterface; +use Symfony\Components\Templating\Helper\HelperInterface; /* * This file is part of the symfony package. @@ -171,7 +172,7 @@ public function addHelpers(array $helpers = array()) * Sets a helper. * * @param HelperInterface $value The helper instance - * @param string $alias An alias + * @param string $alias An alias */ public function set(HelperInterface $helper, $alias = null) { From f3d30865591a849e4435cb408c717b3cf66ac83a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 13 Mar 2010 21:42:33 +0800 Subject: [PATCH 09/54] [Templating] remove Engine as a dependency for the Helper objects --- src/Symfony/Components/Templating/Engine.php | 2 +- .../Components/Templating/Helper/Helper.php | 20 +++++++++---------- .../Templating/Helper/HelperInterface.php | 14 ++++++------- .../Templating/Helper/JavascriptsHelper.php | 15 ++++++++++++-- .../Templating/Helper/StylesheetsHelper.php | 15 ++++++++++++-- .../Framework/WebBundle/Templating/Engine.php | 2 +- 6 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Components/Templating/Engine.php b/src/Symfony/Components/Templating/Engine.php index 75a332d2a7819..0baf4485d97a9 100644 --- a/src/Symfony/Components/Templating/Engine.php +++ b/src/Symfony/Components/Templating/Engine.php @@ -182,7 +182,7 @@ public function set(HelperInterface $helper, $alias = null) $this->helpers[$alias] = $helper; } - $helper->setEngine($this); + $helper->setCharset($this->charset); } /** diff --git a/src/Symfony/Components/Templating/Helper/Helper.php b/src/Symfony/Components/Templating/Helper/Helper.php index 7b99c7364e0a9..c1d65bb32019e 100644 --- a/src/Symfony/Components/Templating/Helper/Helper.php +++ b/src/Symfony/Components/Templating/Helper/Helper.php @@ -2,8 +2,6 @@ namespace Symfony\Components\Templating\Helper; -use Symfony\Components\Templating\Engine; - /* * This file is part of the symfony package. * @@ -22,25 +20,25 @@ */ abstract class Helper implements HelperInterface { - protected $engine; + protected $charset = 'UTF-8'; /** - * Sets the engine associated with this helper. + * Sets the default charset. * - * @param Engine $engine A Engine instance + * @param string $charset The charset */ - public function setEngine(Engine $engine = null) + public function setCharset($charset) { - $this->engine = $engine; + $this->charset = $charset; } /** - * Gets the engine associated with this helper. + * Gets the default charset. * - * @return Engine A Engine instance + * @return string The default charset */ - public function getEngine() + public function getCharset() { - return $this->engine; + return $this->charset; } } diff --git a/src/Symfony/Components/Templating/Helper/HelperInterface.php b/src/Symfony/Components/Templating/Helper/HelperInterface.php index 389abc51938c1..a2570cad17c86 100644 --- a/src/Symfony/Components/Templating/Helper/HelperInterface.php +++ b/src/Symfony/Components/Templating/Helper/HelperInterface.php @@ -2,8 +2,6 @@ namespace Symfony\Components\Templating\Helper; -use Symfony\Components\Templating\Engine; - /* * This file is part of the symfony package. * @@ -30,16 +28,16 @@ interface HelperInterface function getName(); /** - * Sets the engine associated with this helper. + * Sets the default charset. * - * @param Engine $engine A Engine instance + * @param string $charset The charset */ - function setEngine(Engine $engine = null); + function setCharset($charset); /** - * Gets the engine associated with this helper. + * Gets the default charset. * - * @return Engine A Engine instance + * @return string The default charset */ - function getEngine(); + function getCharset(); } diff --git a/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php b/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php index fcacd03cfec9b..8480b8e5cabeb 100644 --- a/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php +++ b/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php @@ -28,6 +28,17 @@ class JavascriptsHelper extends Helper { protected $javascripts = array(); + protected $assetHelper; + + /** + * Constructor. + * + * @param AssetsHelper $assetHelper A AssetsHelper instance + */ + public function __construct(AssetsHelper $assetHelper) + { + $this->assetHelper = $assetHelper; + } /** * Adds a JavaScript file. @@ -37,7 +48,7 @@ class JavascriptsHelper extends Helper */ public function add($javascript, $attributes = array()) { - $this->javascripts[$this->engine->get('assets')->getUrl($javascript)] = $attributes; + $this->javascripts[$this->assetHelper->getUrl($javascript)] = $attributes; } /** @@ -63,7 +74,7 @@ public function render() $atts = ''; foreach ($attributes as $key => $value) { - $atts .= ' '.sprintf('%s="%s"', $key, $this->engine->escape($value)); + $atts .= ' '.sprintf('%s="%s"', $key, htmlspecialchars($value, ENT_QUOTES, $this->charset)); } $html .= sprintf('', $path, $atts)."\n"; diff --git a/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php b/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php index 900d8254c9450..94d4cf3c8c53c 100644 --- a/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php +++ b/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php @@ -28,6 +28,17 @@ class StylesheetsHelper extends Helper { protected $stylesheets = array(); + protected $assetHelper; + + /** + * Constructor. + * + * @param AssetsHelper $assetHelper A AssetsHelper instance + */ + public function __construct(AssetsHelper $assetHelper) + { + $this->assetHelper = $assetHelper; + } /** * Adds a stylesheets file. @@ -37,7 +48,7 @@ class StylesheetsHelper extends Helper */ public function add($stylesheet, $attributes = array()) { - $this->stylesheets[$this->engine->get('assets')->getUrl($stylesheet)] = $attributes; + $this->stylesheets[$this->assetHelper->getUrl($stylesheet)] = $attributes; } /** @@ -63,7 +74,7 @@ public function render() $atts = ''; foreach ($attributes as $key => $value) { - $atts .= ' '.sprintf('%s="%s"', $key, $this->engine->escape($value)); + $atts .= ' '.sprintf('%s="%s"', $key, htmlspecialchars($value, ENT_QUOTES, $this->charset)); } $html .= sprintf('', $path, $atts)."\n"; diff --git a/src/Symfony/Framework/WebBundle/Templating/Engine.php b/src/Symfony/Framework/WebBundle/Templating/Engine.php index d6b8fcecacc91..e4f6126df8b15 100644 --- a/src/Symfony/Framework/WebBundle/Templating/Engine.php +++ b/src/Symfony/Framework/WebBundle/Templating/Engine.php @@ -87,7 +87,7 @@ public function get($name) if (is_string($this->helpers[$name])) { $this->helpers[$name] = $this->container->getService('templating.helper.'.$name); - $this->helpers[$name]->setEngine($this); + $this->helpers[$name]->setCharset($this->charset); } return $this->helpers[$name]; From 0f5df8af99754a65aa679e1c9e670753ec7617df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 13 Mar 2010 21:43:06 +0800 Subject: [PATCH 10/54] [WebBundle] changed the helper configuration to match the latest version of the Templating component --- src/Symfony/Framework/WebBundle/Resources/config/templating.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Framework/WebBundle/Resources/config/templating.xml b/src/Symfony/Framework/WebBundle/Resources/config/templating.xml index c8c1d1d3bed52..41ab8211f9cfe 100644 --- a/src/Symfony/Framework/WebBundle/Resources/config/templating.xml +++ b/src/Symfony/Framework/WebBundle/Resources/config/templating.xml @@ -45,10 +45,12 @@ + + From e83a3a55a85ef994422bd4420ad574e525186a4e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Mar 2010 15:48:03 +0800 Subject: [PATCH 11/54] converted unit tests from lime to PHPUnit for the following components: Console, DependencyInjection, EventDispatcher, OutputEscaper, and Yaml --- .../Components/Console/ApplicationTest.php | 330 ++++++++++++++++ .../Console/Command/CommandTest.php | 242 ++++++++++++ .../Console/Command/HelpCommandTest.php | 42 ++ .../Console/Command/ListCommandTest.php | 31 ++ .../Console/Helper/FormatterHelperTest.php | 35 ++ .../Console/Input/ArgvInputTest.php | 175 +++++++++ .../Console/Input/ArrayInputTest.php | 95 +++++ .../Console/Input/InputArgumentTest.php | 102 +++++ .../Console/Input/InputDefinitionTest.php | 368 ++++++++++++++++++ .../Console/Input/InputOptionTest.php | 142 +++++++ .../Components/Console/Input/InputTest.php | 126 ++++++ .../Console/Input/StringInputTest.php | 98 +++++ .../Console/Output/ConsoleOutputTest.php | 25 ++ .../Console/Output/NullOutputTest.php | 25 ++ .../Components/Console/Output/OutputTest.php | 107 +++++ .../Console/Output/StreamOutputTest.php | 56 +++ .../Console/Tester/ApplicationTesterTest.php | 60 +++ .../Console/Tester/CommandTesterTest.php | 57 +++ .../BuilderConfigurationTest.php | 205 ++++++++++ .../DependencyInjection/BuilderTest.php | 328 ++++++++++++++++ .../DependencyInjection/ContainerTest.php | 208 ++++++++++ .../DependencyInjection/CrossCheckTest.php | 88 +++++ .../DependencyInjection/DefinitionTest.php | 95 +++++ .../DependencyInjection/Dumper/DumperTest.php | 37 ++ .../Dumper/GraphvizDumperTest.php | 55 +++ .../Dumper/PhpDumperTest.php | 62 +++ .../Dumper/XmlDumperTest.php | 61 +++ .../Dumper/YamlDumperTest.php | 61 +++ .../DependencyInjection/FileResourceTest.php | 47 +++ .../Loader/FileLoaderTest.php | 57 +++ .../Loader/IniFileLoaderTest.php | 51 +++ .../Loader/LoaderExtensionTest.php | 35 ++ .../DependencyInjection/Loader/LoaderTest.php | 22 +- .../Loader/XmlFileLoaderTest.php | 203 ++++++++++ .../Loader/YamlFileLoaderTest.php | 145 +++++++ .../DependencyInjection/ParameterTest.php | 24 ++ .../DependencyInjection/ReferenceTest.php | 24 ++ .../EventDispatcher/EventDispatcherTest.php | 143 +++++++ .../Components/EventDispatcher/EventTest.php | 100 +++++ .../OutputEscaper/ArrayDecoratorTest.php | 90 +++++ .../Components/OutputEscaper/EscaperTest.php | 182 +++++++++ .../OutputEscaper/ObjectDecoratorTest.php | 59 +++ .../OutputEscaper/SafeDecoratorTest.php | 98 +++++ .../Tests/Components/Yaml/DumperTest.php | 173 ++++++++ .../Tests/Components/Yaml/InlineTest.php | 163 ++++++++ .../Tests/Components/Yaml/ParserTest.php | 103 +++++ .../Tests/bootstrap.php} | 14 +- .../Components/Console/ApplicationTest.php | 312 --------------- .../Console/Command/CommandTest.php | 206 ---------- .../Console/Command/HelpCommandTest.php | 39 -- .../Console/Command/ListCommandTest.php | 28 -- .../Console/Helper/FormatterHelperTest.php | 28 -- .../Console/Input/ArgvInputTest.php | 174 --------- .../Console/Input/ArrayInputTest.php | 93 ----- .../Console/Input/InputArgumentTest.php | 97 ----- .../Console/Input/InputDefinitionTest.php | 305 --------------- .../Console/Input/InputOptionTest.php | 138 ------- .../Components/Console/Input/InputTest.php | 124 ------ .../Console/Input/StringInputTest.php | 94 ----- .../Console/Output/ConsoleOutputTest.php | 21 - .../Components/Console/Output/OutputTest.php | 100 ----- .../Console/Output/StreamOutputTest.php | 47 --- .../Console/Tester/ApplicationTesterTest.php | 47 --- .../Console/Tester/CommandTesterTest.php | 44 --- .../BuilderConfigurationTest.php | 192 --------- .../DependencyInjection/BuilderTest.php | 309 --------------- .../DependencyInjection/ContainerTest.php | 207 ---------- .../DependencyInjection/CrossCheckTest.php | 78 ---- .../DependencyInjection/DefinitionTest.php | 84 ---- .../DependencyInjection/Dumper/DumperTest.php | 32 -- .../Dumper/GraphvizDumperTest.php | 46 --- .../Dumper/PhpDumperTest.php | 52 --- .../Dumper/XmlDumperTest.php | 51 --- .../Dumper/YamlDumperTest.php | 51 --- .../DependencyInjection/FileResourceTest.php | 31 -- .../Loader/FileLoaderTest.php | 52 --- .../Loader/IniLoaderTest.php | 42 -- .../Loader/LoaderExtensionTest.php | 32 -- .../Loader/XmlFileLoaderTest.php | 182 --------- .../Loader/YamlFileLoaderTest.php | 134 ------- .../DependencyInjection/ParameterTest.php | 21 - .../DependencyInjection/ReferenceTest.php | 21 - .../EventDispatcher/EventDispatcherTest.php | 134 ------- .../Components/EventDispatcher/EventTest.php | 80 ---- .../OutputEscaper/ArrayDecoratorTest.php | 78 ---- .../Components/OutputEscaper/EscaperTest.php | 154 -------- .../OutputEscaper/ObjectDecoratorTest.php | 47 --- .../OutputEscaper/SafeDecoratorTest.php | 93 ----- .../Symfony/Components/Yaml/DumperTest.php | 153 -------- .../Symfony/Components/Yaml/InlineTest.php | 148 ------- .../Symfony/Components/Yaml/ParserTest.php | 85 ---- 91 files changed, 5032 insertions(+), 4503 deletions(-) create mode 100644 tests/Symfony/Tests/Components/Console/ApplicationTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Command/CommandTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/InputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Input/StringInputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Output/OutputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php create mode 100644 tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php rename tests/{unit/Symfony => Symfony/Tests}/Components/DependencyInjection/Loader/LoaderTest.php (51%) create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php create mode 100644 tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php create mode 100644 tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php create mode 100644 tests/Symfony/Tests/Components/EventDispatcher/EventTest.php create mode 100644 tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php create mode 100644 tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php create mode 100644 tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php create mode 100644 tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php create mode 100644 tests/Symfony/Tests/Components/Yaml/DumperTest.php create mode 100644 tests/Symfony/Tests/Components/Yaml/InlineTest.php create mode 100644 tests/Symfony/Tests/Components/Yaml/ParserTest.php rename tests/{unit/Symfony/Components/Console/Output/NullOutputTest.php => Symfony/Tests/bootstrap.php} (50%) delete mode 100644 tests/unit/Symfony/Components/Console/ApplicationTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Command/CommandTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Command/HelpCommandTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Command/ListCommandTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Helper/FormatterHelperTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/ArgvInputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/ArrayInputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/InputArgumentTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/InputDefinitionTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/InputOptionTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/InputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Input/StringInputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Output/ConsoleOutputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Output/OutputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php delete mode 100644 tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/BuilderConfigurationTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/BuilderTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/ContainerTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/CrossCheckTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/DefinitionTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Dumper/DumperTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Dumper/GraphvizDumperTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Dumper/PhpDumperTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Dumper/XmlDumperTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Dumper/YamlDumperTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/FileResourceTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Loader/FileLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Loader/IniLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderExtensionTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Loader/XmlFileLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/Loader/YamlFileLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/ParameterTest.php delete mode 100644 tests/unit/Symfony/Components/DependencyInjection/ReferenceTest.php delete mode 100644 tests/unit/Symfony/Components/EventDispatcher/EventDispatcherTest.php delete mode 100644 tests/unit/Symfony/Components/EventDispatcher/EventTest.php delete mode 100644 tests/unit/Symfony/Components/OutputEscaper/ArrayDecoratorTest.php delete mode 100644 tests/unit/Symfony/Components/OutputEscaper/EscaperTest.php delete mode 100644 tests/unit/Symfony/Components/OutputEscaper/ObjectDecoratorTest.php delete mode 100644 tests/unit/Symfony/Components/OutputEscaper/SafeDecoratorTest.php delete mode 100644 tests/unit/Symfony/Components/Yaml/DumperTest.php delete mode 100644 tests/unit/Symfony/Components/Yaml/InlineTest.php delete mode 100644 tests/unit/Symfony/Components/Yaml/ParserTest.php diff --git a/tests/Symfony/Tests/Components/Console/ApplicationTest.php b/tests/Symfony/Tests/Components/Console/ApplicationTest.php new file mode 100644 index 0000000000000..9084040943d83 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/ApplicationTest.php @@ -0,0 +1,330 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\Console\Application; +use Symfony\Components\Console\Input\ArrayInput; +use Symfony\Components\Console\Output\Output; +use Symfony\Components\Console\Output\StreamOutput; +use Symfony\Components\Console\Tester\ApplicationTester; + +class ApplicationTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../fixtures/Symfony/Components/Console/'); + require_once self::$fixturesPath.'/FooCommand.php'; + require_once self::$fixturesPath.'/Foo1Command.php'; + require_once self::$fixturesPath.'/Foo2Command.php'; + } + + public function testConstructor() + { + $application = new Application('foo', 'bar'); + $this->assertEquals($application->getName(), 'foo', '__construct() takes the application name as its first argument'); + $this->assertEquals($application->getVersion(), 'bar', '__construct() takes the application version as its first argument'); + $this->assertEquals(array_keys($application->getCommands()), array('help', 'list'), '__construct() registered the help and list commands by default'); + } + + public function testSetGetName() + { + $application = new Application(); + $application->setName('foo'); + $this->assertEquals($application->getName(), 'foo', '->setName() sets the name of the application'); + } + + public function testSetGetVersion() + { + $application = new Application(); + $application->setVersion('bar'); + $this->assertEquals($application->getVersion(), 'bar', '->setVersion() sets the version of the application'); + } + + public function testGetLongVersion() + { + $application = new Application('foo', 'bar'); + $this->assertEquals($application->getLongVersion(), 'foo version bar', '->getLongVersion() returns the long version of the application'); + } + + public function testHelp() + { + $application = new Application(); + $this->assertEquals($application->getHelp(), file_get_contents(self::$fixturesPath.'/application_gethelp.txt'), '->setHelp() returns a help message'); + } + + public function testGetCommands() + { + $application = new Application(); + $commands = $application->getCommands(); + $this->assertEquals(get_class($commands['help']), 'Symfony\\Components\\Console\\Command\\HelpCommand', '->getCommands() returns the registered commands'); + + $application->addCommand(new \FooCommand()); + $commands = $application->getCommands('foo'); + $this->assertEquals(count($commands), 1, '->getCommands() takes a namespace as its first argument'); + } + + public function testRegister() + { + $application = new Application(); + $command = $application->register('foo'); + $this->assertEquals($command->getName(), 'foo', '->register() regiters a new command'); + } + + public function testAddCommand() + { + $application = new Application(); + $application->addCommand($foo = new \FooCommand()); + $commands = $application->getCommands(); + $this->assertEquals($commands['foo:bar'], $foo, '->addCommand() registers a command'); + + $application = new Application(); + $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command())); + $commands = $application->getCommands(); + $this->assertEquals(array($commands['foo:bar'], $commands['foo:bar1']), array($foo, $foo1), '->addCommands() registers an array of commands'); + } + + public function testHasGetCommand() + { + $application = new Application(); + $this->assertTrue($application->hasCommand('list'), '->hasCommand() returns true if a named command is registered'); + $this->assertTrue(!$application->hasCommand('afoobar'), '->hasCommand() returns false if a named command is not registered'); + + $application->addCommand($foo = new \FooCommand()); + $this->assertTrue($application->hasCommand('afoobar'), '->hasCommand() returns true if an alias is registered'); + $this->assertEquals($application->getCommand('foo:bar'), $foo, '->getCommand() returns a command by name'); + $this->assertEquals($application->getCommand('afoobar'), $foo, '->getCommand() returns a command by alias'); + + try + { + $application->getCommand('foofoo'); + $this->fail('->getCommand() throws an \InvalidArgumentException if the command does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + $application = new TestApplication(); + $application->addCommand($foo = new \FooCommand()); + $application->setWantHelps(); + $command = $application->getCommand('foo:bar'); + $this->assertEquals(get_class($command), 'Symfony\Components\Console\Command\HelpCommand', '->getCommand() returns the help command if --help is provided as the input'); + } + + public function testGetNamespaces() + { + $application = new TestApplication(); + $application->addCommand(new \FooCommand()); + $application->addCommand(new \Foo1Command()); + $this->assertEquals($application->getNamespaces(), array('foo'), '->getNamespaces() returns an array of unique used namespaces'); + } + + public function testFindNamespace() + { + $application = new TestApplication(); + $application->addCommand(new \FooCommand()); + $this->assertEquals($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); + $this->assertEquals($application->findNamespace('f'), 'foo', '->findNamespace() finds a namespace given an abbreviation'); + $application->addCommand(new \Foo2Command()); + $this->assertEquals($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); + try + { + $application->findNamespace('f'); + $this->fail('->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $application->findNamespace('bar'); + $this->fail('->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testFindCommand() + { + $application = new TestApplication(); + $application->addCommand(new \FooCommand()); + $this->assertEquals(get_class($application->findCommand('foo:bar')), 'FooCommand', '->findCommand() returns a command if its name exists'); + $this->assertEquals(get_class($application->findCommand('h')), 'Symfony\Components\Console\Command\HelpCommand', '->findCommand() returns a command if its name exists'); + $this->assertEquals(get_class($application->findCommand('f:bar')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace exists'); + $this->assertEquals(get_class($application->findCommand('f:b')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertEquals(get_class($application->findCommand('a')), 'FooCommand', '->findCommand() returns a command if the abbreviation exists for an alias'); + + $application->addCommand(new \Foo1Command()); + $application->addCommand(new \Foo2Command()); + + try + { + $application->findCommand('f'); + $this->fail('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $application->findCommand('a'); + $this->fail('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $application->findCommand('foo:b'); + $this->fail('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testSetCatchExceptions() + { + $application = new Application(); + $application->setAutoExit(false); + $tester = new ApplicationTester($application); + + $application->setCatchExceptions(true); + $tester->run(array('command' => 'foo')); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_renderexception1.txt'), '->setCatchExceptions() sets the catch exception flag'); + + $application->setCatchExceptions(false); + try + { + $tester->run(array('command' => 'foo')); + $this->fail('->setCatchExceptions() sets the catch exception flag'); + } + catch (\Exception $e) + { + } + } + + public function testAsText() + { + $application = new Application(); + $application->addCommand(new \FooCommand); + $this->assertEquals($application->asText(), file_get_contents(self::$fixturesPath.'/application_astext1.txt'), '->asText() returns a text representation of the application'); + $this->assertEquals($application->asText('foo'), file_get_contents(self::$fixturesPath.'/application_astext2.txt'), '->asText() returns a text representation of the application'); + } + + public function testAsXml() + { + $application = new Application(); + $application->addCommand(new \FooCommand); + $this->assertEquals($application->asXml(), file_get_contents(self::$fixturesPath.'/application_asxml1.txt'), '->asXml() returns an XML representation of the application'); + $this->assertEquals($application->asXml('foo'), file_get_contents(self::$fixturesPath.'/application_asxml2.txt'), '->asXml() returns an XML representation of the application'); + } + + public function testRenderException() + { + $application = new Application(); + $application->setAutoExit(false); + $tester = new ApplicationTester($application); + + $tester->run(array('command' => 'foo')); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_renderexception1.txt'), '->renderException() renders a pretty exception'); + + $tester->run(array('command' => 'foo'), array('verbosity' => Output::VERBOSITY_VERBOSE)); + $this->assertRegExp('/Exception trace/', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); + + $tester->run(array('command' => 'list', '--foo' => true)); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_renderexception2.txt'), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); + } + + public function testRun() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->addCommand($command = new \Foo1Command()); + $_SERVER['argv'] = array('cli.php', 'foo:bar1'); + + ob_start(); + $application->run(); + ob_end_clean(); + + $this->assertEquals(get_class($command->input), 'Symfony\Components\Console\Input\ArgvInput', '->run() creates an ArgvInput by default if none is given'); + $this->assertEquals(get_class($command->output), 'Symfony\Components\Console\Output\ConsoleOutput', '->run() creates a ConsoleOutput by default if none is given'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $tester = new ApplicationTester($application); + $tester->run(array()); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run1.txt'), '->run() runs the list command if no argument is passed'); + + $tester->run(array('--help' => true)); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run2.txt'), '->run() runs the help command if --help is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'list', '--help' => true)); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run3.txt'), '->run() displays the help if --help is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $tester = new ApplicationTester($application); + $tester->run(array('--color' => true)); + $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --color is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $tester = new ApplicationTester($application); + $tester->run(array('--version' => true)); + $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run4.txt'), '->run() displays the program version if --version is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'list', '--quiet' => true)); + $this->assertEquals($tester->getDisplay(), '', '->run() removes all output if --quiet is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'list', '--verbose' => true)); + $this->assertEquals($tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->run() sets the output to verbose is --verbose is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->addCommand(new \FooCommand()); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo:bar', '--no-interaction' => true)); + $this->assertEquals($tester->getDisplay(), "called\n", '->run() does not called interact() if --no-interaction is passed'); + } +} + +class TestApplication extends Application +{ + public function setWantHelps() + { + $this->wantHelps = true; + } +} diff --git a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php new file mode 100644 index 0000000000000..dbb7e321417ab --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php @@ -0,0 +1,242 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Command; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Command\Command; +use Symfony\Components\Console\Application; +use Symfony\Components\Console\Input\InputDefinition; +use Symfony\Components\Console\Input\InputArgument; +use Symfony\Components\Console\Input\InputOption; +use Symfony\Components\Console\Input\InputInterface; +use Symfony\Components\Console\Input\StringInput; +use Symfony\Components\Console\Output\OutputInterface; +use Symfony\Components\Console\Output\NullOutput; +use Symfony\Components\Console\Output\StreamOutput; +use Symfony\Components\Console\Tester\CommandTester; + +class CommandTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../../../../../fixtures/Symfony/Components/Console/'; + require_once self::$fixturesPath.'/TestCommand.php'; + } + + public function testConstructor() + { + $application = new Application(); + try + { + $command = new Command(); + $this->fail('__construct() throws a \LogicException if the name is null'); + } + catch (\LogicException $e) + { + } + $command = new Command('foo:bar'); + $this->assertEquals($command->getFullName(), 'foo:bar', '__construct() takes the command name as its first argument'); + } + + public function testSetApplication() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $this->assertEquals($command->getApplication(), $application, '->setApplication() sets the current application'); + } + + public function testSetGetDefinition() + { + $command = new \TestCommand(); + $ret = $command->setDefinition($definition = new InputDefinition()); + $this->assertEquals($ret, $command, '->setDefinition() implements a fluent interface'); + $this->assertEquals($command->getDefinition(), $definition, '->setDefinition() sets the current InputDefinition instance'); + $command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); + $command->setDefinition(new InputDefinition()); + } + + public function testAddArgument() + { + $command = new \TestCommand(); + $ret = $command->addArgument('foo'); + $this->assertEquals($ret, $command, '->addArgument() implements a fluent interface'); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command'); + } + + public function testAddOption() + { + $command = new \TestCommand(); + $ret = $command->addOption('foo'); + $this->assertEquals($ret, $command, '->addOption() implements a fluent interface'); + $this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command'); + } + + public function testgetNamespaceGetNameGetFullNameSetName() + { + $command = new \TestCommand(); + $this->assertEquals($command->getNamespace(), 'namespace', '->getNamespace() returns the command namespace'); + $this->assertEquals($command->getName(), 'name', '->getName() returns the command name'); + $this->assertEquals($command->getFullName(), 'namespace:name', '->getNamespace() returns the full command name'); + $command->setName('foo'); + $this->assertEquals($command->getName(), 'foo', '->setName() sets the command name'); + + $command->setName(':bar'); + $this->assertEquals($command->getName(), 'bar', '->setName() sets the command name'); + $this->assertEquals($command->getNamespace(), '', '->setName() can set the command namespace'); + + $ret = $command->setName('foobar:bar'); + $this->assertEquals($ret, $command, '->setName() implements a fluent interface'); + $this->assertEquals($command->getName(), 'bar', '->setName() sets the command name'); + $this->assertEquals($command->getNamespace(), 'foobar', '->setName() can set the command namespace'); + + try + { + $command->setName(''); + $this->fail('->setName() throws an \InvalidArgumentException if the name is empty'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $command->setName('foo:'); + $this->fail('->setName() throws an \InvalidArgumentException if the name is empty'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testGetSetDescription() + { + $command = new \TestCommand(); + $this->assertEquals($command->getDescription(), 'description', '->getDescription() returns the description'); + $ret = $command->setDescription('description1'); + $this->assertEquals($ret, $command, '->setDescription() implements a fluent interface'); + $this->assertEquals($command->getDescription(), 'description1', '->setDescription() sets the description'); + } + + public function testGetSetHelp() + { + $command = new \TestCommand(); + $this->assertEquals($command->getHelp(), 'help', '->getHelp() returns the help'); + $ret = $command->setHelp('help1'); + $this->assertEquals($ret, $command, '->setHelp() implements a fluent interface'); + $this->assertEquals($command->getHelp(), 'help1', '->setHelp() sets the help'); + } + + public function testGetSetAliases() + { + $command = new \TestCommand(); + $this->assertEquals($command->getAliases(), array('name'), '->getAliases() returns the aliases'); + $ret = $command->setAliases(array('name1')); + $this->assertEquals($ret, $command, '->setAliases() implements a fluent interface'); + $this->assertEquals($command->getAliases(), array('name1'), '->setAliases() sets the aliases'); + } + + public function testGetSynopsis() + { + $command = new \TestCommand(); + $command->addOption('foo'); + $command->addArgument('foo'); + $this->assertEquals($command->getSynopsis(), 'namespace:name [--foo] [foo]', '->getSynopsis() returns the synopsis'); + } + + public function testMergeApplicationDefinition() + { + $application1 = new Application(); + $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); + $application1->getDefinition()->addOptions(array(new InputOption('bar'))); + $command = new \TestCommand(); + $command->setApplication($application1); + $command->setDefinition($definition = new InputDefinition(array(new InputArgument('bar'), new InputOption('foo')))); + $command->mergeApplicationDefinition(); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); + $this->assertTrue($command->getDefinition()->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); + $this->assertTrue($command->getDefinition()->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options'); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options'); + + $command->mergeApplicationDefinition(); + $this->assertEquals($command->getDefinition()->getArgumentCount(), 3, '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); + + $command = new \TestCommand(); + $command->mergeApplicationDefinition(); + } + + public function testRun() + { + $command = new \TestCommand(); + $application = new Application(); + $command->setApplication($application); + $tester = new CommandTester($command); + try + { + $tester->execute(array('--bar' => true)); + $this->fail('->run() throws a \RuntimeException when the input does not validate the current InputDefinition'); + } + catch (\RuntimeException $e) + { + } + + $this->assertEquals($tester->execute(array(), array('interactive' => true)), "interact called\nexecute called\n", '->run() calls the interact() method if the input is interactive'); + $this->assertEquals($tester->execute(array(), array('interactive' => false)), "execute called\n", '->run() does not call the interact() method if the input is not interactive'); + + $command = new Command('foo'); + try + { + $command->run(new StringInput(''), new NullOutput()); + $this->fail('->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided'); + } + catch (\LogicException $e) + { + } + } + + public function testSetCode() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) + { + $output->writeln('from the code...'); + }); + $this->assertEquals($ret, $command, '->setCode() implements a fluent interface'); + $tester = new CommandTester($command); + $tester->execute(array()); + $this->assertEquals($tester->getDisplay(), "interact called\nfrom the code...\n"); + } + + public function testAsText() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $tester = new CommandTester($command); + $tester->execute(array()); + $this->assertEquals($command->asText(), file_get_contents(self::$fixturesPath.'/command_astext.txt'), '->asText() returns a text representation of the command'); + } + + public function testAsXml() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $tester = new CommandTester($command); + $tester->execute(array()); + $this->assertEquals($command->asXml(), file_get_contents(self::$fixturesPath.'/command_asxml.txt'), '->asXml() returns an XML representation of the command'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php b/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php new file mode 100644 index 0000000000000..2c61f4472769f --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Command; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Tester\CommandTester; +use Symfony\Components\Console\Command\HelpCommand; +use Symfony\Components\Console\Command\ListCommand; +use Symfony\Components\Console\Application; + +class HelpCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testExecute() + { + $command = new HelpCommand(); + $command->setCommand(new ListCommand()); + + $commandTester = new CommandTester($command); + $commandTester->execute(array()); + $this->assertRegExp('/list \[--xml\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + + $commandTester->execute(array('--xml' => true)); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); + + $application = new Application(); + $commandTester = new CommandTester($application->getCommand('help')); + $commandTester->execute(array('command_name' => 'list')); + $this->assertRegExp('/list \[--xml\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + + $commandTester->execute(array('command_name' => 'list', '--xml' => true)); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php b/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php new file mode 100644 index 0000000000000..e7c81b41f3e81 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Command; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Tester\CommandTester; +use Symfony\Components\Console\Application; + +class ListCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testExecute() + { + $application = new Application(); + + $commandTester = new CommandTester($application->getCommand('list')); + $commandTester->execute(array()); + $this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); + + $commandTester->execute(array('--xml' => true)); + $this->assertRegExp('//', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php b/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php new file mode 100644 index 0000000000000..7d237c13ed032 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Formatter; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Helper\FormatterHelper; + +class FormatterHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testFormatSection() + { + $formatter = new FormatterHelper(); + + $this->assertEquals($formatter->formatSection('cli', 'Some text to display'), '[cli] Some text to display', '::formatSection() formats a message in a section'); + } + + public function testFormatBlock() + { + $formatter = new FormatterHelper(); + + $this->assertEquals($formatter->formatBlock('Some text to display', 'error'), ' Some text to display ', '::formatBlock() formats a message in a block'); + $this->assertEquals($formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), " Some text to display \n foo bar ", '::formatBlock() formats a message in a block'); + + $this->assertEquals($formatter->formatBlock('Some text to display', 'error', true), " \n Some text to display \n ", '::formatBlock() formats a message in a block'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php b/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php new file mode 100644 index 0000000000000..40864fba334f3 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php @@ -0,0 +1,175 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\ArgvInput; +use Symfony\Components\Console\Input\InputDefinition; +use Symfony\Components\Console\Input\InputArgument; +use Symfony\Components\Console\Input\InputOption; + +class ArgvInputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $_SERVER['argv'] = array('cli.php', 'foo'); + $input = new TestInput(); + $this->assertEquals($input->getTokens(), array('foo'), '__construct() automatically get its input from the argv server variable'); + } + + public function testParser() + { + $input = new TestInput(array('cli.php', 'foo')); + $input->bind(new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments'); + + $input->bind(new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals($input->getArguments(), array('name' => 'foo'), '->parse() is stateless'); + + $input = new TestInput(array('cli.php', '--foo')); + $input->bind(new InputDefinition(array(new InputOption('foo')))); + $this->assertEquals($input->getOptions(), array('foo' => true), '->parse() parses long options without parameter'); + + $input = new TestInput(array('cli.php', '--foo=bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a = separator)'); + + $input = new TestInput(array('cli.php', '--foo', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a space separator)'); + + try + { + $input = new TestInput(array('cli.php', '--foo')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->fail('->parse() throws a \RuntimeException if no parameter is passed to an option when it is required'); + } + catch (\RuntimeException $e) + { + } + + $input = new TestInput(array('cli.php', '-f')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f')))); + $this->assertEquals($input->getOptions(), array('foo' => true), '->parse() parses short options without parameter'); + + $input = new TestInput(array('cli.php', '-fbar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with no separator)'); + + $input = new TestInput(array('cli.php', '-f', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with a space separator)'); + + $input = new TestInput(array('cli.php', '-f', '-b', 'foo')); + $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL), new InputOption('bar', 'b')))); + $this->assertEquals($input->getOptions(), array('foo' => null, 'bar' => true), '->parse() parses short options with an optional parameter which is not present'); + + try + { + $input = new TestInput(array('cli.php', '-f')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->fail('->parse() throws a \RuntimeException if no parameter is passed to an option when it is required'); + } + catch (\RuntimeException $e) + { + } + + try + { + $input = new TestInput(array('cli.php', '-ffoo')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_NONE)))); + $this->fail('->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); + } + catch (\RuntimeException $e) + { + } + + try + { + $input = new TestInput(array('cli.php', 'foo', 'bar')); + $input->bind(new InputDefinition()); + $this->fail('->parse() throws a \RuntimeException if too many arguments are passed'); + } + catch (\RuntimeException $e) + { + } + + try + { + $input = new TestInput(array('cli.php', '--foo')); + $input->bind(new InputDefinition()); + $this->fail('->parse() throws a \RuntimeException if an unknown long option is passed'); + } + catch (\RuntimeException $e) + { + } + + try + { + $input = new TestInput(array('cli.php', '-f')); + $input->bind(new InputDefinition()); + $this->fail('->parse() throws a \RuntimeException if an unknown short option is passed'); + } + catch (\RuntimeException $e) + { + } + + $input = new TestInput(array('cli.php', '-fb')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b')))); + $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => true), '->parse() parses short options when they are aggregated as a single one'); + + $input = new TestInput(array('cli.php', '-fb', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_REQUIRED)))); + $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has a required parameter'); + + $input = new TestInput(array('cli.php', '-fb', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); + $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter'); + + $input = new TestInput(array('cli.php', '-fbbar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); + $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter with no separator'); + + $input = new TestInput(array('cli.php', '-fbbar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); + $this->assertEquals($input->getOptions(), array('foo' => 'bbar', 'bar' => null), '->parse() parses short options when they are aggregated as a single one and one of them takes a parameter'); + } + + public function testGetFirstArgument() + { + $input = new TestInput(array('cli.php', '-fbbar')); + $this->assertEquals($input->getFirstArgument(), '', '->getFirstArgument() returns the first argument from the raw input'); + + $input = new TestInput(array('cli.php', '-fbbar', 'foo')); + $this->assertEquals($input->getFirstArgument(), 'foo', '->getFirstArgument() returns the first argument from the raw input'); + } + + public function testHasParameterOption() + { + $input = new TestInput(array('cli.php', '-f', 'foo')); + $this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input'); + + $input = new TestInput(array('cli.php', '--foo', 'foo')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input'); + + $input = new TestInput(array('cli.php', 'foo')); + $this->assertTrue(!$input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input'); + } +} + +class TestInput extends ArgvInput +{ + public function getTokens() + { + return $this->tokens; + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php b/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php new file mode 100644 index 0000000000000..f75f66219d559 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\ArrayInput; +use Symfony\Components\Console\Input\InputDefinition; +use Symfony\Components\Console\Input\InputArgument; +use Symfony\Components\Console\Input\InputOption; + +class ArrayInputTest extends \PHPUnit_Framework_TestCase +{ + public function testGetFirstArgument() + { + $input = new ArrayInput(array()); + $this->assertEquals($input->getFirstArgument(), null, '->getFirstArgument() returns null if no argument were passed'); + $input = new ArrayInput(array('name' => 'Fabien')); + $this->assertEquals($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument'); + $input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien')); + $this->assertEquals($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument'); + } + + public function testHasParameterOption() + { + $input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); + $this->assertTrue(!$input->hasParameterOption('--bar'), '->hasParameterOption() returns false if an option is not present in the passed parameters'); + + $input = new ArrayInput(array('--foo')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); + } + + public function testParse() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments'); + + try + { + $input = new ArrayInput(array('foo' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); + } + catch (\RuntimeException $e) + { + } + + $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo')))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options'); + + $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL, '', 'default')))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a default value'); + + $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL, '', 'default')))); + $this->assertEquals($input->getOptions(), array('foo' => 'default'), '->parse() parses long options with a default value'); + + try + { + $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); + $this->fail('->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); + } + catch (\RuntimeException $e) + { + } + + try + { + $input = new ArrayInput(array('--foo' => 'foo'), new InputDefinition()); + $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); + } + catch (\RuntimeException $e) + { + } + + $input = new ArrayInput(array('-f' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f')))); + $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options'); + + try + { + $input = new ArrayInput(array('-o' => 'foo'), new InputDefinition()); + $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); + } + catch (\RuntimeException $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php b/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php new file mode 100644 index 0000000000000..5e0964551d95c --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\InputArgument; +use Symfony\Components\Console\Exception; + +class InputArgumentTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $argument = new InputArgument('foo'); + $this->assertEquals($argument->getName(), 'foo', '__construct() takes a name as its first argument'); + + // mode argument + $argument = new InputArgument('foo'); + $this->assertEquals($argument->isRequired(), false, '__construct() gives a "Argument::OPTIONAL" mode by default'); + + $argument = new InputArgument('foo', null); + $this->assertEquals($argument->isRequired(), false, '__construct() can take "Argument::OPTIONAL" as its mode'); + + $argument = new InputArgument('foo', InputArgument::OPTIONAL); + $this->assertEquals($argument->isRequired(), false, '__construct() can take "Argument::PARAMETER_OPTIONAL" as its mode'); + + $argument = new InputArgument('foo', InputArgument::REQUIRED); + $this->assertEquals($argument->isRequired(), true, '__construct() can take "Argument::PARAMETER_REQUIRED" as its mode'); + + try + { + $argument = new InputArgument('foo', 'ANOTHER_ONE'); + $this->fail('__construct() throws an Exception if the mode is not valid'); + } + catch (\Exception $e) + { + } + } + + public function testIsArray() + { + $argument = new InputArgument('foo', InputArgument::IS_ARRAY); + $this->assertTrue($argument->isArray(), '->isArray() returns true if the argument can be an array'); + $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); + $this->assertTrue($argument->isArray(), '->isArray() returns true if the argument can be an array'); + $argument = new InputArgument('foo', InputArgument::OPTIONAL); + $this->assertTrue(!$argument->isArray(), '->isArray() returns false if the argument can not be an array'); + } + + public function testGetDescription() + { + $argument = new InputArgument('foo', null, 'Some description'); + $this->assertEquals($argument->getDescription(), 'Some description', '->getDescription() return the message description'); + } + + public function testGetDefault() + { + $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); + $this->assertEquals($argument->getDefault(), 'default', '->getDefault() return the default value'); + } + + public function testSetDefault() + { + $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); + $argument->setDefault(null); + $this->assertTrue(is_null($argument->getDefault()), '->setDefault() can reset the default value by passing null'); + $argument->setDefault('another'); + $this->assertEquals($argument->getDefault(), 'another', '->setDefault() changes the default value'); + + $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); + $argument->setDefault(array(1, 2)); + $this->assertEquals($argument->getDefault(), array(1, 2), '->setDefault() changes the default value'); + + try + { + $argument = new InputArgument('foo', InputArgument::REQUIRED); + $argument->setDefault('default'); + $this->fail('->setDefault() throws an Exception if you give a default value for a required argument'); + } + catch (\Exception $e) + { + } + + try + { + $argument = new InputArgument('foo', InputArgument::IS_ARRAY); + $argument->setDefault('default'); + $this->fail('->setDefault() throws an Exception if you give a default value which is not an array for a IS_ARRAY option'); + } + catch (\Exception $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php b/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php new file mode 100644 index 0000000000000..6f19f2b05b8bb --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php @@ -0,0 +1,368 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\InputDefinition; +use Symfony\Components\Console\Input\InputArgument; +use Symfony\Components\Console\Input\InputOption; +use Symfony\Components\Console\Exception; + +class InputDefinitionTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixtures; + + protected $foo, $bar, $foo1, $foo2; + + static public function setUpBeforeClass() + { + self::$fixtures = __DIR__.'/../../../../../fixtures/Symfony/Components/Console'; + } + + public function testConstructor() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $this->assertEquals($definition->getArguments(), array(), '__construct() creates a new InputDefinition object'); + + $definition = new InputDefinition(array($this->foo, $this->bar)); + $this->assertEquals($definition->getArguments(), array('foo' => $this->foo, 'bar' => $this->bar), '__construct() takes an array of InputArgument objects as its first argument'); + + $this->initializeOptions(); + + $definition = new InputDefinition(); + $this->assertEquals($definition->getOptions(), array(), '__construct() creates a new InputDefinition object'); + + $definition = new InputDefinition(array($this->foo, $this->bar)); + $this->assertEquals($definition->getOptions(), array('foo' => $this->foo, 'bar' => $this->bar), '__construct() takes an array of InputOption objects as its first argument'); + } + + public function testSetArguments() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->setArguments(array($this->foo)); + $this->assertEquals($definition->getArguments(), array('foo' => $this->foo), '->setArguments() sets the array of InputArgument objects'); + $definition->setArguments(array($this->bar)); + + $this->assertEquals($definition->getArguments(), array('bar' => $this->bar), '->setArguments() clears all InputArgument objects'); + } + + public function testAddArguments() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $this->assertEquals($definition->getArguments(), array('foo' => $this->foo), '->addArguments() adds an array of InputArgument objects'); + $definition->addArguments(array($this->bar)); + $this->assertEquals($definition->getArguments(), array('foo' => $this->foo, 'bar' => $this->bar), '->addArguments() does not clear existing InputArgument objects'); + } + + public function testAddArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + $this->assertEquals($definition->getArguments(), array('foo' => $this->foo), '->addArgument() adds a InputArgument object'); + $definition->addArgument($this->bar); + $this->assertEquals($definition->getArguments(), array('foo' => $this->foo, 'bar' => $this->bar), '->addArgument() adds a InputArgument object'); + + // arguments must have different names + try + { + $definition->addArgument($this->foo1); + $this->fail('->addArgument() throws a Exception if another argument is already registered with the same name'); + } + catch (\Exception $e) + { + } + + // cannot add a parameter after an array parameter + $definition->addArgument(new InputArgument('fooarray', InputArgument::IS_ARRAY)); + try + { + $definition->addArgument(new InputArgument('anotherbar')); + $this->fail('->addArgument() throws a Exception if there is an array parameter already registered'); + } + catch (\Exception $e) + { + } + + // cannot add a required argument after an optional one + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + try + { + $definition->addArgument($this->foo2); + $this->fail('->addArgument() throws an exception if you try to add a required argument after an optional one'); + } + catch (\Exception $e) + { + } + } + + public function testGetArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $this->assertEquals($definition->getArgument('foo'), $this->foo, '->getArgument() returns a InputArgument by its name'); + try + { + $definition->getArgument('bar'); + $this->fail('->getArgument() throws an exception if the InputArgument name does not exist'); + } + catch (\Exception $e) + { + } + } + + public function testHasArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $this->assertEquals($definition->hasArgument('foo'), true, '->hasArgument() returns true if a InputArgument exists for the given name'); + $this->assertEquals($definition->hasArgument('bar'), false, '->hasArgument() returns false if a InputArgument exists for the given name'); + } + + public function testGetArgumentRequiredCount() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo2); + $this->assertEquals($definition->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); + $definition->addArgument($this->foo); + $this->assertEquals($definition->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); + } + + public function testGetArgumentCount() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo2); + $this->assertEquals($definition->getArgumentCount(), 1, '->getArgumentCount() returns the number of arguments'); + $definition->addArgument($this->foo); + $this->assertEquals($definition->getArgumentCount(), 2, '->getArgumentCount() returns the number of arguments'); + } + + public function testGetArgumentDefaults() + { + $definition = new InputDefinition(array( + new InputArgument('foo1', InputArgument::OPTIONAL), + new InputArgument('foo2', InputArgument::OPTIONAL, '', 'default'), + new InputArgument('foo3', InputArgument::OPTIONAL | InputArgument::IS_ARRAY), + // new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), + )); + $this->assertEquals($definition->getArgumentDefaults(), array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), '->getArgumentDefaults() return the default values for each argument'); + + $definition = new InputDefinition(array( + new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), + )); + $this->assertEquals($definition->getArgumentDefaults(), array('foo4' => array(1, 2)), '->getArgumentDefaults() return the default values for each argument'); + } + + public function testSetOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($definition->getOptions(), array('foo' => $this->foo), '->setOptions() sets the array of InputOption objects'); + $definition->setOptions(array($this->bar)); + $this->assertEquals($definition->getOptions(), array('bar' => $this->bar), '->setOptions() clears all InputOption objects'); + try + { + $definition->getOptionForShortcut('f'); + $this->fail('->setOptions() clears all InputOption objects'); + } + catch (\Exception $e) + { + } + } + + public function testAddOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($definition->getOptions(), array('foo' => $this->foo), '->addOptions() adds an array of InputOption objects'); + $definition->addOptions(array($this->bar)); + $this->assertEquals($definition->getOptions(), array('foo' => $this->foo, 'bar' => $this->bar), '->addOptions() does not clear existing InputOption objects'); + } + + public function testAddOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $this->assertEquals($definition->getOptions(), array('foo' => $this->foo), '->addOption() adds a InputOption object'); + $definition->addOption($this->bar); + $this->assertEquals($definition->getOptions(), array('foo' => $this->foo, 'bar' => $this->bar), '->addOption() adds a InputOption object'); + try + { + $definition->addOption($this->foo2); + $this->fail('->addOption() throws a Exception if the another option is already registered with the same name'); + } + catch (\Exception $e) + { + } + try + { + $definition->addOption($this->foo1); + $this->fail('->addOption() throws a Exception if the another option is already registered with the same shortcut'); + } + catch (\Exception $e) + { + } + } + + public function testGetOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($definition->getOption('foo'), $this->foo, '->getOption() returns a InputOption by its name'); + try + { + $definition->getOption('bar'); + $this->fail('->getOption() throws an exception if the option name does not exist'); + } + catch (\Exception $e) + { + } + } + + public function testHasOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($definition->hasOption('foo'), true, '->hasOption() returns true if a InputOption exists for the given name'); + $this->assertEquals($definition->hasOption('bar'), false, '->hasOption() returns false if a InputOption exists for the given name'); + } + + public function testHasShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($definition->hasShortcut('f'), true, '->hasShortcut() returns true if a InputOption exists for the given shortcut'); + $this->assertEquals($definition->hasShortcut('b'), false, '->hasShortcut() returns false if a InputOption exists for the given shortcut'); + } + + public function testGetOptionForShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($definition->getOptionForShortcut('f'), $this->foo, '->getOptionForShortcut() returns a InputOption by its shortcut'); + try + { + $definition->getOptionForShortcut('l'); + $this->fail('->getOption() throws an exception if the shortcut does not exist'); + } + catch (\Exception $e) + { + } + } + + public function testGetOptionDefaults() + { + $definition = new InputDefinition(array( + new InputOption('foo1', null, InputOption::PARAMETER_NONE), + new InputOption('foo2', null, InputOption::PARAMETER_REQUIRED), + new InputOption('foo3', null, InputOption::PARAMETER_REQUIRED, '', 'default'), + new InputOption('foo4', null, InputOption::PARAMETER_OPTIONAL), + new InputOption('foo5', null, InputOption::PARAMETER_OPTIONAL, '', 'default'), + new InputOption('foo6', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY), + new InputOption('foo7', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY, '', array(1, 2)), + )); + $defaults = array( + 'foo1' => null, + 'foo2' => null, + 'foo3' => 'default', + 'foo4' => null, + 'foo5' => 'default', + 'foo6' => array(), + 'foo7' => array(1, 2), + ); + $this->assertEquals($definition->getOptionDefaults(), $defaults, '->getOptionDefaults() returns the default values for all options'); + } + + public function testGetSynopsis() + { + $definition = new InputDefinition(array(new InputOption('foo'))); + $this->assertEquals($definition->getSynopsis(), '[--foo]', '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputOption('foo', 'f'))); + $this->assertEquals($definition->getSynopsis(), '[-f|--foo]', '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED))); + $this->assertEquals($definition->getSynopsis(), '[-f|--foo="..."]', '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL))); + $this->assertEquals($definition->getSynopsis(), '[-f|--foo[="..."]]', '->getSynopsis() returns a synopsis of arguments and options'); + + $definition = new InputDefinition(array(new InputArgument('foo'))); + $this->assertEquals($definition->getSynopsis(), '[foo]', '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))); + $this->assertEquals($definition->getSynopsis(), 'foo', '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))); + $this->assertEquals($definition->getSynopsis(), '[foo1] ... [fooN]', '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))); + $this->assertEquals($definition->getSynopsis(), 'foo1 ... [fooN]', '->getSynopsis() returns a synopsis of arguments and options'); + } + + public function testAsText() + { + $definition = new InputDefinition(array( + new InputArgument('foo', InputArgument::OPTIONAL, 'The bar argument'), + new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The foo argument', array('bar')), + new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED, 'The foo option'), + new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL, 'The foo option', 'bar'), + )); + $this->assertEquals($definition->asText(), file_get_contents(self::$fixtures.'/definition_astext.txt'), '->asText() returns a textual representation of the InputDefinition'); + } + + public function testAsXml() + { + $definition = new InputDefinition(array( + new InputArgument('foo', InputArgument::OPTIONAL, 'The bar argument'), + new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The foo argument', array('bar')), + new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED, 'The foo option'), + new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL, 'The foo option', 'bar'), + )); + $this->assertEquals($definition->asXml(), file_get_contents(self::$fixtures.'/definition_asxml.txt'), '->asText() returns a textual representation of the InputDefinition'); + } + + protected function initializeArguments() + { + $this->foo = new InputArgument('foo'); + $this->bar = new InputArgument('bar'); + $this->foo1 = new InputArgument('foo'); + $this->foo2 = new InputArgument('foo2', InputArgument::REQUIRED); + } + + protected function initializeOptions() + { + $this->foo = new InputOption('foo', 'f'); + $this->bar = new InputOption('bar', 'b'); + $this->foo1 = new InputOption('fooBis', 'f'); + $this->foo2 = new InputOption('foo', 'p'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php b/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php new file mode 100644 index 0000000000000..ac650854cca51 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\InputOption; +use Symfony\Components\Console\Exception; + +class InputOptionTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $option = new InputOption('foo'); + $this->assertEquals($option->getName(), 'foo', '__construct() takes a name as its first argument'); + $option = new InputOption('--foo'); + $this->assertEquals($option->getName(), 'foo', '__construct() removes the leading -- of the option name'); + + try + { + $option = new InputOption('foo', 'f', InputOption::PARAMETER_IS_ARRAY); + $this->fail('->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value'); + } + catch (\Exception $e) + { + } + + // shortcut argument + $option = new InputOption('foo', 'f'); + $this->assertEquals($option->getShortcut(), 'f', '__construct() can take a shortcut as its second argument'); + $option = new InputOption('foo', '-f'); + $this->assertEquals($option->getShortcut(), 'f', '__construct() removes the leading - of the shortcut'); + + // mode argument + $option = new InputOption('foo', 'f'); + $this->assertEquals($option->acceptParameter(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); + $this->assertEquals($option->isParameterRequired(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); + $this->assertEquals($option->isParameterOptional(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); + + $option = new InputOption('foo', 'f', null); + $this->assertEquals($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::PARAMETER_NONE); + $this->assertEquals($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED); + $this->assertEquals($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); + $this->assertEquals($option->isParameterRequired(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); + $this->assertEquals($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL); + $this->assertEquals($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); + $this->assertEquals($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); + $this->assertEquals($option->isParameterOptional(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); + + try + { + $option = new InputOption('foo', 'f', 'ANOTHER_ONE'); + $this->fail('__construct() throws an Exception if the mode is not valid'); + } + catch (\Exception $e) + { + } + } + + public function testIsArray() + { + $option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); + $this->assertTrue($option->isArray(), '->isArray() returns true if the option can be an array'); + $option = new InputOption('foo', null, InputOption::PARAMETER_NONE); + $this->assertTrue(!$option->isArray(), '->isArray() returns false if the option can not be an array'); + } + + public function testGetDescription() + { + $option = new InputOption('foo', 'f', null, 'Some description'); + $this->assertEquals($option->getDescription(), 'Some description', '->getDescription() returns the description message'); + } + + public function testGetDefault() + { + $option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL, '', 'default'); + $this->assertEquals($option->getDefault(), 'default', '->getDefault() returns the default value'); + + $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED, '', 'default'); + $this->assertEquals($option->getDefault(), 'default', '->getDefault() returns the default value'); + + $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED); + $this->assertTrue(is_null($option->getDefault()), '->getDefault() returns null if no default value is configured'); + + $option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); + $this->assertEquals($option->getDefault(), array(), '->getDefault() returns an empty array if option is an array'); + + $option = new InputOption('foo', null, InputOption::PARAMETER_NONE); + $this->assertTrue($option->getDefault() === false, '->getDefault() returns false if the option does not take a parameter'); + } + + public function testSetDefault() + { + $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED, '', 'default'); + $option->setDefault(null); + $this->assertTrue(is_null($option->getDefault()), '->setDefault() can reset the default value by passing null'); + $option->setDefault('another'); + $this->assertEquals($option->getDefault(), 'another', '->setDefault() changes the default value'); + + $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED | InputOption::PARAMETER_IS_ARRAY); + $option->setDefault(array(1, 2)); + $this->assertEquals($option->getDefault(), array(1, 2), '->setDefault() changes the default value'); + + $option = new InputOption('foo', 'f', InputOption::PARAMETER_NONE); + try + { + $option->setDefault('default'); + $this->fail('->setDefault() throws an Exception if you give a default value for a PARAMETER_NONE option'); + } + catch (\Exception $e) + { + } + + $option = new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); + try + { + $option->setDefault('default'); + $this->fail('->setDefault() throws an Exception if you give a default value which is not an array for a PARAMETER_IS_ARRAY option'); + } + catch (\Exception $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/InputTest.php b/tests/Symfony/Tests/Components/Console/Input/InputTest.php new file mode 100644 index 0000000000000..467ce0427c458 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/InputTest.php @@ -0,0 +1,126 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\ArrayInput; +use Symfony\Components\Console\Input\InputDefinition; +use Symfony\Components\Console\Input\InputArgument; +use Symfony\Components\Console\Input\InputOption; + +class InputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals($input->getArgument('name'), 'foo', '->__construct() takes a InputDefinition as an argument'); + } + + public function testOptions() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name')))); + $this->assertEquals($input->getOption('name'), 'foo', '->getOption() returns the value for the given option'); + + $input->setOption('name', 'bar'); + $this->assertEquals($input->getOption('name'), 'bar', '->setOption() sets the value for a given option'); + $this->assertEquals($input->getOptions(), array('name' => 'bar'), '->getOptions() returns all option values'); + + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::PARAMETER_OPTIONAL, '', 'default')))); + $this->assertEquals($input->getOption('bar'), 'default', '->getOption() returns the default value for optional options'); + $this->assertEquals($input->getOptions(), array('name' => 'foo', 'bar' => 'default'), '->getOptions() returns all option values, even optional ones'); + + try + { + $input->setOption('foo', 'bar'); + $this->fail('->setOption() throws a \InvalidArgumentException if the option does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $input->getOption('foo'); + $this->fail('->getOption() throws a \InvalidArgumentException if the option does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testArguments() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals($input->getArgument('name'), 'foo', '->getArgument() returns the value for the given argument'); + + $input->setArgument('name', 'bar'); + $this->assertEquals($input->getArgument('name'), 'bar', '->setArgument() sets the value for a given argument'); + $this->assertEquals($input->getArguments(), array('name' => 'bar'), '->getArguments() returns all argument values'); + + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $this->assertEquals($input->getArgument('bar'), 'default', '->getArgument() returns the default value for optional arguments'); + $this->assertEquals($input->getArguments(), array('name' => 'foo', 'bar' => 'default'), '->getArguments() returns all argument values, even optional ones'); + + try + { + $input->setArgument('foo', 'bar'); + $this->fail('->setArgument() throws a \InvalidArgumentException if the argument does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $input->getArgument('foo'); + $this->fail('->getArgument() throws a \InvalidArgumentException if the argument does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testValidate() + { + $input = new ArrayInput(array()); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); + + try + { + $input->validate(); + $this->fail('->validate() throws a \RuntimeException if not enough arguments are given'); + } + catch (\RuntimeException $e) + { + } + + $input = new ArrayInput(array('name' => 'foo')); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); + + try + { + $input->validate(); + } + catch (\RuntimeException $e) + { + $this->fail('->validate() does not throw a \RuntimeException if enough arguments are given'); + } + } + + public function testSetFetInteractive() + { + $input = new ArrayInput(array()); + $this->assertTrue($input->isInteractive(), '->isInteractive() returns whether the input should be interactive or not'); + $input->setInteractive(false); + $this->assertTrue(!$input->isInteractive(), '->setInteractive() changes the interactive flag'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php b/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php new file mode 100644 index 0000000000000..e2dbc73b02b34 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Input; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Input\StringInput; + +class StringInputTest extends \PHPUnit_Framework_TestCase +{ + public function testTokenize() + { + $input = new TestInput1(''); + $this->assertEquals($input->getTokens(), array(), '->tokenize() parses an empty string'); + + $input = new TestInput1('foo'); + $this->assertEquals($input->getTokens(), array('foo'), '->tokenize() parses arguments'); + + $input = new TestInput1(' foo bar '); + $this->assertEquals($input->getTokens(), array('foo', 'bar'), '->tokenize() ignores whitespaces between arguments'); + + $input = new TestInput1('"quoted"'); + $this->assertEquals($input->getTokens(), array('quoted'), '->tokenize() parses quoted arguments'); + + $input = new TestInput1("'quoted'"); + $this->assertEquals($input->getTokens(), array('quoted'), '->tokenize() parses quoted arguments'); + + $input = new TestInput1('\"quoted\"'); + $this->assertEquals($input->getTokens(), array('"quoted"'), '->tokenize() parses escaped-quoted arguments'); + + $input = new TestInput1("\'quoted\'"); + $this->assertEquals($input->getTokens(), array('\'quoted\''), '->tokenize() parses escaped-quoted arguments'); + + $input = new TestInput1('-a'); + $this->assertEquals($input->getTokens(), array('-a'), '->tokenize() parses short options'); + + $input = new TestInput1('-azc'); + $this->assertEquals($input->getTokens(), array('-azc'), '->tokenize() parses aggregated short options'); + + $input = new TestInput1('-awithavalue'); + $this->assertEquals($input->getTokens(), array('-awithavalue'), '->tokenize() parses short options with a value'); + + $input = new TestInput1('-a"foo bar"'); + $this->assertEquals($input->getTokens(), array('-afoo bar'), '->tokenize() parses short options with a value'); + + $input = new TestInput1('-a"foo bar""foo bar"'); + $this->assertEquals($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); + + $input = new TestInput1('-a\'foo bar\''); + $this->assertEquals($input->getTokens(), array('-afoo bar'), '->tokenize() parses short options with a value'); + + $input = new TestInput1('-a\'foo bar\'\'foo bar\''); + $this->assertEquals($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); + + $input = new TestInput1('-a\'foo bar\'"foo bar"'); + $this->assertEquals($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); + + $input = new TestInput1('--long-option'); + $this->assertEquals($input->getTokens(), array('--long-option'), '->tokenize() parses long options'); + + $input = new TestInput1('--long-option=foo'); + $this->assertEquals($input->getTokens(), array('--long-option=foo'), '->tokenize() parses long options with a value'); + + $input = new TestInput1('--long-option="foo bar"'); + $this->assertEquals($input->getTokens(), array('--long-option=foo bar'), '->tokenize() parses long options with a value'); + + $input = new TestInput1('--long-option="foo bar""another"'); + $this->assertEquals($input->getTokens(), array('--long-option=foo baranother'), '->tokenize() parses long options with a value'); + + $input = new TestInput1('--long-option=\'foo bar\''); + $this->assertEquals($input->getTokens(), array('--long-option=foo bar'), '->tokenize() parses long options with a value'); + + $input = new TestInput1("--long-option='foo bar''another'"); + $this->assertEquals($input->getTokens(), array("--long-option=foo baranother"), '->tokenize() parses long options with a value'); + + $input = new TestInput1("--long-option='foo bar'\"another\""); + $this->assertEquals($input->getTokens(), array("--long-option=foo baranother"), '->tokenize() parses long options with a value'); + + $input = new TestInput1('foo -a -ffoo --long bar'); + $this->assertEquals($input->getTokens(), array('foo', '-a', '-ffoo', '--long', 'bar'), '->tokenize() parses when several arguments and options'); + } +} + +class TestInput1 extends StringInput +{ + public function getTokens() + { + return $this->tokens; + } +} diff --git a/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php new file mode 100644 index 0000000000000..1d34aaa0c10e4 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Output; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Output\ConsoleOutput; +use Symfony\Components\Console\Output\Output; + +class ConsoleOutputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); + $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php new file mode 100644 index 0000000000000..62ce474f821b8 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Output; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Output\NullOutput; + +class NullOutputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $output = new NullOutput(); + $output->write('foo'); + $this->assertTrue(true, '->write() does nothing'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Output/OutputTest.php b/tests/Symfony/Tests/Components/Console/Output/OutputTest.php new file mode 100644 index 0000000000000..16749a2479dcf --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Output/OutputTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Output; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Output\Output; + +class OutputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $output = new TestOutput(Output::VERBOSITY_QUIET, true); + $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); + $this->assertEquals($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument'); + } + + public function testSetIsDecorated() + { + $output = new TestOutput(); + $output->setDecorated(true); + $this->assertEquals($output->isDecorated(), true, 'setDecorated() sets the decorated flag'); + } + + public function testSetGetVerbosity() + { + $output = new TestOutput(); + $output->setVerbosity(Output::VERBOSITY_QUIET); + $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '->setVerbosity() sets the verbosity'); + } + + public function testSetStyle() + { + Output::setStyle('FOO', array('bg' => 'red', 'fg' => 'yellow', 'blink' => true)); + $this->assertEquals(TestOutput::getStyle('foo'), array('bg' => 'red', 'fg' => 'yellow', 'blink' => true), '::setStyle() sets a new style'); + } + + public function testWrite() + { + $output = new TestOutput(Output::VERBOSITY_QUIET); + $output->writeln('foo'); + $this->assertEquals($output->output, '', '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); + + $output = new TestOutput(); + $output->writeln(array('foo', 'bar')); + $this->assertEquals($output->output, "foo\nbar\n", '->writeln() can take an array of messages to output'); + + $output = new TestOutput(); + $output->writeln('foo', Output::OUTPUT_RAW); + $this->assertEquals($output->output, "foo\n", '->writeln() outputs the raw message if OUTPUT_RAW is specified'); + + $output = new TestOutput(); + $output->writeln('foo', Output::OUTPUT_PLAIN); + $this->assertEquals($output->output, "foo\n", '->writeln() strips decoration tags if OUTPUT_PLAIN is specified'); + + $output = new TestOutput(); + $output->setDecorated(false); + $output->writeln('foo'); + $this->assertEquals($output->output, "foo\n", '->writeln() strips decoration tags if decoration is set to false'); + + $output = new TestOutput(); + $output->setDecorated(true); + $output->writeln('foo'); + $this->assertEquals($output->output, "\033[33;41;5mfoo\033[0m\n", '->writeln() decorates the output'); + + try + { + $output->writeln('foo', 24); + $this->fail('->writeln() throws an \InvalidArgumentException when the type does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $output->writeln('foo'); + $this->fail('->writeln() throws an \InvalidArgumentException when a style does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } +} + +class TestOutput extends Output +{ + public $output = ''; + + static public function getStyle($name) + { + return static::$styles[$name]; + } + + public function doWrite($message, $newline) + { + $this->output .= $message.($newline ? "\n" : ''); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php new file mode 100644 index 0000000000000..20a81b1731068 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Output; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Output\Output; +use Symfony\Components\Console\Output\StreamOutput; + +class StreamOutputTest extends \PHPUnit_Framework_TestCase +{ + protected $stream; + + public function setUp() + { + $this->stream = fopen('php://memory', 'a', false); + } + + public function testConstructor() + { + try + { + $output = new StreamOutput('foo'); + $this->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream'); + } + catch (\InvalidArgumentException $e) + { + } + + $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true); + $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); + $this->assertEquals($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument'); + } + + public function testGetStream() + { + $output = new StreamOutput($this->stream); + $this->assertEquals($output->getStream(), $this->stream, '->getStream() returns the current stream'); + } + + public function testDoWrite() + { + $output = new StreamOutput($this->stream); + $output->writeln('foo'); + rewind($output->getStream()); + $this->assertEquals(stream_get_contents($output->getStream()), "foo\n", '->doWrite() writes to the stream'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php b/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php new file mode 100644 index 0000000000000..efe8aa229e202 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Tester; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Application; +use Symfony\Components\Console\Output\Output; +use Symfony\Components\Console\Tester\ApplicationTester; + +class ApplicationTesterTest extends \PHPUnit_Framework_TestCase +{ + protected $application; + protected $tester; + + public function setUp() + { + $this->application = new Application(); + $this->application->setAutoExit(false); + $this->application->register('foo') + ->addArgument('command') + ->addArgument('foo') + ->setCode(function ($input, $output) { $output->writeln('foo'); }) + ; + + $this->tester = new ApplicationTester($this->application); + $this->tester->run(array('command' => 'foo', 'foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); + } + + public function testRun() + { + $this->assertEquals($this->tester->getInput()->isInteractive(), false, '->execute() takes an interactive option'); + $this->assertEquals($this->tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option'); + $this->assertEquals($this->tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option'); + } + + public function testGetInput() + { + $this->assertEquals($this->tester->getInput()->getArgument('foo'), 'bar', '->getInput() returns the current input instance'); + } + + public function testGetOutput() + { + rewind($this->tester->getOutput()->getStream()); + $this->assertEquals(stream_get_contents($this->tester->getOutput()->getStream()), "foo\n", '->getOutput() returns the current output instance'); + } + + public function testGetDisplay() + { + $this->assertEquals($this->tester->getDisplay(), "foo\n", '->getDisplay() returns the display of the last execution'); + } +} diff --git a/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php b/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php new file mode 100644 index 0000000000000..ab52cec481c96 --- /dev/null +++ b/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Console\Tester; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Console\Command\Command; +use Symfony\Components\Console\Output\Output; +use Symfony\Components\Console\Tester\CommandTester; + +class CommandTesterTest extends \PHPUnit_Framework_TestCase +{ + protected $application; + protected $tester; + + public function setUp() + { + $this->command = new Command('foo'); + $this->command->addArgument('command'); + $this->command->addArgument('foo'); + $this->command->setCode(function ($input, $output) { $output->writeln('foo'); }); + + $this->tester = new CommandTester($this->command); + $this->tester->execute(array('foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); + } + + public function testExecute() + { + $this->assertEquals($this->tester->getInput()->isInteractive(), false, '->execute() takes an interactive option'); + $this->assertEquals($this->tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option'); + $this->assertEquals($this->tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option'); + } + + public function testGetInput() + { + $this->assertEquals($this->tester->getInput()->getArgument('foo'), 'bar', '->getInput() returns the current input instance'); + } + + public function testGetOutput() + { + rewind($this->tester->getOutput()->getStream()); + $this->assertEquals(stream_get_contents($this->tester->getOutput()->getStream()), "foo\n", '->getOutput() returns the current output instance'); + } + + public function testGetDisplay() + { + $this->assertEquals($this->tester->getDisplay(), "foo\n", '->getDisplay() returns the display of the last execution'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php new file mode 100644 index 0000000000000..ee5d227b7a863 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php @@ -0,0 +1,205 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\BuilderConfiguration; +use Symfony\Components\DependencyInjection\Definition; +use Symfony\Components\DependencyInjection\Reference; +use Symfony\Components\DependencyInjection\FileResource; + +class BuilderConfigurationTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../../../../fixtures/Symfony/Components/DependencyInjection/'; + } + + public function testConstructor() + { + $definitions = array( + 'foo' => new Definition('FooClass'), + 'bar' => new Definition('BarClass'), + ); + $parameters = array( + 'foo' => 'foo', + 'bar' => 'bar', + ); + $configuration = new BuilderConfiguration($definitions, $parameters); + $this->assertEquals($configuration->getDefinitions(), $definitions, '__construct() takes an array of definitions as its first argument'); + $this->assertEquals($configuration->getParameters(), $parameters, '__construct() takes an array of parameters as its second argument'); + } + + public function testMerge() + { + $configuration = new BuilderConfiguration(); + $configuration->merge(null); + $this->assertEquals($configuration->getParameters(), array(), '->merge() accepts null as an argument'); + $this->assertEquals($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); + $this->assertEquals($configuration->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones'); + + $configuration = new BuilderConfiguration(array(), array('bar' => 'foo', 'foo' => 'baz')); + $config = new BuilderConfiguration(array(), array('foo' => 'bar')); + $configuration->merge($config); + $this->assertEquals($configuration->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() overrides existing parameters'); + + $configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'), 'bar' => new Definition('BarClass'))); + $config = new BuilderConfiguration(array('baz' => new Definition('BazClass'))); + $config->setAlias('alias_for_foo', 'foo'); + $configuration->merge($config); + $this->assertEquals(array_keys($configuration->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones'); + $this->assertEquals($configuration->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases'); + + $configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'))); + $config->setDefinition('foo', new Definition('BazClass')); + $configuration->merge($config); + $this->assertEquals($configuration->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services'); + + $configuration = new BuilderConfiguration(); + $configuration->addResource($a = new FileResource('foo.xml')); + $config = new BuilderConfiguration(); + $config->addResource($b = new FileResource('foo.yml')); + $configuration->merge($config); + $this->assertEquals($configuration->getResources(), array($a, $b), '->merge() merges resources'); + } + + public function testSetGetParameters() + { + $configuration = new BuilderConfiguration(); + $this->assertEquals($configuration->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined'); + + $configuration->setParameters(array('foo' => 'bar')); + $this->assertEquals($configuration->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters'); + + $configuration->setParameters(array('bar' => 'foo')); + $this->assertEquals($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters'); + + $configuration->setParameters(array('Bar' => 'foo')); + $this->assertEquals($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase'); + } + + public function testSetGetParameter() + { + $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); + $configuration->setParameter('bar', 'foo'); + $this->assertEquals($configuration->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter'); + + $configuration->setParameter('foo', 'baz'); + $this->assertEquals($configuration->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter'); + + $configuration->setParameter('Foo', 'baz1'); + $this->assertEquals($configuration->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase'); + $this->assertEquals($configuration->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); + + try + { + $configuration->getParameter('baba'); + $this->fail('->getParameter() throws an \InvalidArgumentException if the key does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testHasParameter() + { + $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); + $this->assertTrue($configuration->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); + $this->assertTrue($configuration->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); + $this->assertTrue(!$configuration->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); + } + + public function testAddParameters() + { + $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); + $configuration->addParameters(array('bar' => 'foo')); + $this->assertEquals($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); + $configuration->addParameters(array('Bar' => 'fooz')); + $this->assertEquals($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); + } + + public function testAliases() + { + $configuration = new BuilderConfiguration(); + $configuration->setAlias('bar', 'foo'); + $this->assertEquals($configuration->getAlias('bar'), 'foo', '->setAlias() defines a new alias'); + $this->assertTrue($configuration->hasAlias('bar'), '->hasAlias() returns true if the alias is defined'); + $this->assertTrue(!$configuration->hasAlias('baba'), '->hasAlias() returns false if the alias is not defined'); + + try + { + $configuration->getAlias('baba'); + $this->fail('->getAlias() throws an \InvalidArgumentException if the alias does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + $configuration->setAlias('barbar', 'foofoo'); + $this->assertEquals($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo'), '->getAliases() returns an array of all defined aliases'); + + $configuration->addAliases(array('foo' => 'bar')); + $this->assertEquals($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo', 'foo' => 'bar'), '->addAliases() adds some aliases'); + } + + public function testDefinitions() + { + $configuration = new BuilderConfiguration(); + $definitions = array( + 'foo' => new Definition('FooClass'), + 'bar' => new Definition('BarClass'), + ); + $configuration->setDefinitions($definitions); + $this->assertEquals($configuration->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions'); + $this->assertTrue($configuration->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists'); + $this->assertTrue(!$configuration->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist'); + + $configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')); + $this->assertEquals($configuration->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined'); + $this->assertTrue($configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); + + $configuration->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); + $this->assertEquals($configuration->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions'); + + try + { + $configuration->getDefinition('baz'); + $this->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testFindDefinition() + { + $configuration = new BuilderConfiguration(array('foo' => $definition = new Definition('FooClass'))); + $configuration->setAlias('bar', 'foo'); + $configuration->setAlias('foobar', 'bar'); + $this->assertEquals($configuration->findDefinition('foobar'), $definition, '->findDefinition() returns a Definition'); + } + + public function testResources() + { + $configuration = new BuilderConfiguration(); + $configuration->addResource($a = new FileResource('foo.xml')); + $configuration->addResource($b = new FileResource('foo.yml')); + $this->assertEquals($configuration->getResources(), array($a, $b), '->getResources() returns an array of resources read for the current configuration'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php new file mode 100644 index 0000000000000..acdb17ad5662e --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php @@ -0,0 +1,328 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\BuilderConfiguration; +use Symfony\Components\DependencyInjection\Definition; +use Symfony\Components\DependencyInjection\Reference; + +class BuilderTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../../../../fixtures/Symfony/Components/DependencyInjection/'; + } + + public function testDefinitions() + { + $builder = new Builder(); + $definitions = array( + 'foo' => new Definition('FooClass'), + 'bar' => new Definition('BarClass'), + ); + $builder->setDefinitions($definitions); + $this->assertEquals($builder->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions'); + $this->assertTrue($builder->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists'); + $this->assertTrue(!$builder->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist'); + + $builder->setDefinition('foobar', $foo = new Definition('FooBarClass')); + $this->assertEquals($builder->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined'); + $this->assertTrue($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); + + $builder->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); + $this->assertEquals($builder->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions'); + + try + { + $builder->getDefinition('baz'); + $this->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testRegister() + { + $builder = new Builder(); + $builder->register('foo', 'FooClass'); + $this->assertTrue($builder->hasDefinition('foo'), '->register() registers a new service definition'); + $this->assertTrue($builder->getDefinition('foo') instanceof Definition, '->register() returns the newly created Definition instance'); + } + + public function testHasService() + { + $builder = new Builder(); + $this->assertTrue(!$builder->hasService('foo'), '->hasService() returns false if the service does not exist'); + $builder->register('foo', 'FooClass'); + $this->assertTrue($builder->hasService('foo'), '->hasService() returns true if a service definition exists'); + $builder->bar = new \stdClass(); + $this->assertTrue($builder->hasService('bar'), '->hasService() returns true if a service exists'); + } + + public function testGetService() + { + $builder = new Builder(); + try + { + $builder->getService('foo'); + $this->fail('->getService() throws an InvalidArgumentException if the service does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + $builder->register('foo', 'stdClass'); + $this->assertTrue(is_object($builder->getService('foo')), '->getService() returns the service definition associated with the id'); + $builder->bar = $bar = new \stdClass(); + $this->assertEquals($builder->getService('bar'), $bar, '->getService() returns the service associated with the id'); + $builder->register('bar', 'stdClass'); + $this->assertEquals($builder->getService('bar'), $bar, '->getService() returns the service associated with the id even if a definition has been defined'); + + $builder->register('baz', 'stdClass')->setArguments(array(new Reference('baz'))); + try + { + @$builder->getService('baz'); + $this->fail('->getService() throws a LogicException if the service has a circular reference to itself'); + } + catch (\LogicException $e) + { + } + + $builder->register('foobar', 'stdClass')->setShared(true); + $this->assertTrue($builder->getService('bar') === $builder->getService('bar'), '->getService() always returns the same instance if the service is shared'); + } + + public function testGetServiceIds() + { + $builder = new Builder(); + $builder->register('foo', 'stdClass'); + $builder->bar = $bar = new \stdClass(); + $builder->register('bar', 'stdClass'); + $this->assertEquals($builder->getServiceIds(), array('foo', 'bar', 'service_container'), '->getServiceIds() returns all defined service ids'); + } + + public function testAliases() + { + $builder = new Builder(); + $builder->register('foo', 'stdClass'); + $builder->setAlias('bar', 'foo'); + $this->assertTrue($builder->hasAlias('bar'), '->hasAlias() returns true if the alias exists'); + $this->assertTrue(!$builder->hasAlias('foobar'), '->hasAlias() returns false if the alias does not exist'); + $this->assertEquals($builder->getAlias('bar'), 'foo', '->getAlias() returns the aliased service'); + $this->assertTrue($builder->hasService('bar'), '->setAlias() defines a new service'); + $this->assertTrue($builder->getService('bar') === $builder->getService('foo'), '->setAlias() creates a service that is an alias to another one'); + + try + { + $builder->getAlias('foobar'); + $this->fail('->getAlias() throws an InvalidArgumentException if the alias does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testGetAliases() + { + $builder = new Builder(); + $builder->setAlias('bar', 'foo'); + $builder->setAlias('foobar', 'foo'); + $this->assertEquals($builder->getAliases(), array('bar' => 'foo', 'foobar' => 'foo'), '->getAliases() returns all service aliases'); + $builder->register('bar', 'stdClass'); + $this->assertEquals($builder->getAliases(), array('foobar' => 'foo'), '->getAliases() does not return aliased services that have been overridden'); + $builder->setService('foobar', 'stdClass'); + $this->assertEquals($builder->getAliases(), array(), '->getAliases() does not return aliased services that have been overridden'); + } + + public function testCreateService() + { + $builder = new Builder(); + $builder->register('foo1', 'FooClass')->setFile(self::$fixturesPath.'/includes/foo.php'); + $this->assertTrue($builder->getService('foo1') instanceof \FooClass, '->createService() requires the file defined by the service definition'); + $builder->register('foo2', 'FooClass')->setFile(self::$fixturesPath.'/includes/%file%.php'); + $builder->setParameter('file', 'foo'); + $this->assertTrue($builder->getService('foo2') instanceof \FooClass, '->createService() replaces parameters in the file provided by the service definition'); + } + + public function testCreateServiceClass() + { + $builder = new Builder(); + $builder->register('foo1', '%class%'); + $builder->setParameter('class', 'stdClass'); + $this->assertTrue($builder->getService('foo1') instanceof \stdClass, '->createService() replaces parameters in the class provided by the service definition'); + } + + public function testCreateServiceArguments() + { + $builder = new Builder(); + $builder->register('bar', 'stdClass'); + $builder->register('foo1', 'FooClass')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); + $builder->setParameter('value', 'bar'); + $this->assertEquals($builder->getService('foo1')->arguments, array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), '->createService() replaces parameters and service references in the arguments provided by the service definition'); + } + + public function testCreateServiceConstructor() + { + $builder = new Builder(); + $builder->register('bar', 'stdClass'); + $builder->register('foo1', 'FooClass')->setConstructor('getInstance')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); + $builder->setParameter('value', 'bar'); + $this->assertTrue($builder->getService('foo1')->called, '->createService() calls the constructor to create the service instance'); + $this->assertEquals($builder->getService('foo1')->arguments, array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), '->createService() passes the arguments to the constructor'); + } + + public function testCreateServiceMethodCalls() + { + $builder = new Builder(); + $builder->register('bar', 'stdClass'); + $builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%value%', new Reference('bar')))); + $builder->setParameter('value', 'bar'); + $this->assertEquals($builder->getService('foo1')->bar, array('bar', $builder->getService('bar')), '->createService() replaces the values in the method calls arguments'); + } + + public function testCreateServiceConfigurator() + { + require_once self::$fixturesPath.'/includes/classes.php'; + + $builder = new Builder(); + $builder->register('foo1', 'FooClass')->setConfigurator('sc_configure'); + $this->assertTrue($builder->getService('foo1')->configured, '->createService() calls the configurator'); + + $builder->register('foo2', 'FooClass')->setConfigurator(array('%class%', 'configureStatic')); + $builder->setParameter('class', 'BazClass'); + $this->assertTrue($builder->getService('foo2')->configured, '->createService() calls the configurator'); + + $builder->register('baz', 'BazClass'); + $builder->register('foo3', 'FooClass')->setConfigurator(array(new Reference('baz'), 'configure')); + $this->assertTrue($builder->getService('foo3')->configured, '->createService() calls the configurator'); + + $builder->register('foo4', 'FooClass')->setConfigurator('foo'); + try + { + $builder->getService('foo4'); + $this->fail('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testResolveValue() + { + $this->assertEquals(Builder::resolveValue('foo', array()), 'foo', '->resolveValue() returns its argument unmodified if no placeholders are found'); + $this->assertEquals(Builder::resolveValue('I\'m a %foo%', array('foo' => 'bar')), 'I\'m a bar', '->resolveValue() replaces placeholders by their values'); + $this->assertTrue(Builder::resolveValue('%foo%', array('foo' => true)) === true, '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); + + $this->assertEquals(Builder::resolveValue(array('%foo%' => '%foo%'), array('foo' => 'bar')), array('bar' => 'bar'), '->resolveValue() replaces placeholders in keys and values of arrays'); + + $this->assertEquals(Builder::resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%'))), array('foo' => 'bar')), array('bar' => array('bar' => array('bar' => 'bar'))), '->resolveValue() replaces placeholders in nested arrays'); + + $this->assertEquals(Builder::resolveValue('I\'m a %%foo%%', array('foo' => 'bar')), 'I\'m a %foo%', '->resolveValue() supports % escaping by doubling it'); + $this->assertEquals(Builder::resolveValue('I\'m a %foo% %%foo %foo%', array('foo' => 'bar')), 'I\'m a bar %foo bar', '->resolveValue() supports % escaping by doubling it'); + + try + { + Builder::resolveValue('%foobar%', array()); + $this->fail('->resolveValue() throws a RuntimeException if a placeholder references a non-existant parameter'); + } + catch (\RuntimeException $e) + { + } + + try + { + Builder::resolveValue('foo %foobar% bar', array()); + $this->fail('->resolveValue() throws a RuntimeException if a placeholder references a non-existant parameter'); + } + catch (\RuntimeException $e) + { + } + } + + public function testResolveServices() + { + $builder = new Builder(); + $builder->register('foo', 'FooClass'); + $this->assertEquals($builder->resolveServices(new Reference('foo')), $builder->getService('foo'), '->resolveServices() resolves service references to service instances'); + $this->assertEquals($builder->resolveServices(array('foo' => array('foo', new Reference('foo')))), array('foo' => array('foo', $builder->getService('foo'))), '->resolveServices() resolves service references to service instances in nested arrays'); + } + + public function testMerge() + { + $container = new Builder(); + $container->merge(null); + $this->assertEquals($container->getParameters(), array(), '->merge() accepts null as an argument'); + $this->assertEquals($container->getDefinitions(), array(), '->merge() accepts null as an argument'); + + $container = new Builder(array('bar' => 'foo')); + $config = new BuilderConfiguration(); + $config->setParameters(array('foo' => 'bar')); + $container->merge($config); + $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones'); + + $container = new Builder(array('bar' => 'foo', 'foo' => 'baz')); + $config = new BuilderConfiguration(); + $config->setParameters(array('foo' => 'bar')); + $container->merge($config); + $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'baz'), '->merge() does not change the already defined parameters'); + + $container = new Builder(array('bar' => 'foo')); + $config = new BuilderConfiguration(); + $config->setParameters(array('foo' => '%bar%')); + $container->merge($config); + $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones'); + + $container = new Builder(array('bar' => 'foo')); + $config = new BuilderConfiguration(); + $config->setParameters(array('foo' => '%bar%', 'baz' => '%foo%')); + $container->merge($config); + $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones'); + + $container = new Builder(); + $container->register('foo', 'FooClass'); + $container->register('bar', 'BarClass'); + $config = new BuilderConfiguration(); + $config->setDefinition('baz', new Definition('BazClass')); + $config->setAlias('alias_for_foo', 'foo'); + $container->merge($config); + $this->assertEquals(array_keys($container->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones'); + $this->assertEquals($container->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases'); + + $container = new Builder(); + $container->register('foo', 'FooClass'); + $config->setDefinition('foo', new Definition('BazClass')); + $container->merge($config); + $this->assertEquals($container->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services'); + } + + public function testFindAnnotatedServiceIds() + { + $builder = new Builder(); + $builder + ->register('foo', 'FooClass') + ->addAnnotation('foo', array('foo' => 'foo')) + ->addAnnotation('bar', array('bar' => 'bar')) + ->addAnnotation('foo', array('foofoo' => 'foofoo')) + ; + $this->assertEquals($builder->findAnnotatedServiceIds('foo'), array( + 'foo' => array( + array('foo' => 'foo'), + array('foofoo' => 'foofoo'), + ) + ), '->findAnnotatedServiceIds() returns an array of service ids and its annotation attributes'); + $this->assertEquals($builder->findAnnotatedServiceIds('foobar'), array(), '->findAnnotatedServiceIds() returns an empty array if there is annotated services'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php new file mode 100644 index 0000000000000..c550b3d4ea18d --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php @@ -0,0 +1,208 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Container; + +class ContainerTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $sc = new Container(); + $this->assertEquals(spl_object_hash($sc->getService('service_container')), spl_object_hash($sc), '__construct() automatically registers itself as a service'); + + $sc = new Container(array('foo' => 'bar')); + $this->assertEquals($sc->getParameters(), array('foo' => 'bar'), '__construct() takes an array of parameters as its first argument'); + } + + public function testGetSetParameters() + { + $sc = new Container(); + $this->assertEquals($sc->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined'); + + $sc->setParameters(array('foo' => 'bar')); + $this->assertEquals($sc->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters'); + + $sc->setParameters(array('bar' => 'foo')); + $this->assertEquals($sc->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters'); + + $sc->setParameters(array('Bar' => 'foo')); + $this->assertEquals($sc->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase'); + } + + public function testGetSetParameter() + { + $sc = new Container(array('foo' => 'bar')); + $sc->setParameter('bar', 'foo'); + $this->assertEquals($sc->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter'); + $this->assertEquals($sc['bar'], 'foo', '->offsetGet() gets the value of a parameter'); + + $sc['bar1'] = 'foo1'; + $this->assertEquals($sc['bar1'], 'foo1', '->offsetset() sets the value of a parameter'); + + unset($sc['bar1']); + $this->assertTrue(!isset($sc['bar1']), '->offsetUnset() removes a parameter'); + + $sc->setParameter('foo', 'baz'); + $this->assertEquals($sc->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter'); + + $sc->setParameter('Foo', 'baz1'); + $this->assertEquals($sc->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase'); + $this->assertEquals($sc->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); + $this->assertEquals($sc['FOO'], 'baz1', '->offsetGet() converts the key to lowercase'); + + try + { + $sc->getParameter('baba'); + $this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $sc['baba']; + $this->fail('->offsetGet() thrown an \InvalidArgumentException if the key does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testHasParameter() + { + $sc = new Container(array('foo' => 'bar')); + $this->assertTrue($sc->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); + $this->assertTrue($sc->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); + $this->assertTrue(isset($sc['Foo']), '->offsetExists() converts the key to lowercase'); + $this->assertTrue(!$sc->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); + $this->assertTrue(isset($sc['foo']), '->offsetExists() returns true if a parameter is defined'); + $this->assertTrue(!isset($sc['bar']), '->offsetExists() returns false if a parameter is not defined'); + } + + public function testAddParameters() + { + $sc = new Container(array('foo' => 'bar')); + $sc->addParameters(array('bar' => 'foo')); + $this->assertEquals($sc->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); + $sc->addParameters(array('Bar' => 'fooz')); + $this->assertEquals($sc->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); + } + + public function testServices() + { + $sc = new Container(); + $sc->setService('foo', $obj = new \stdClass()); + $this->assertEquals(spl_object_hash($sc->getService('foo')), spl_object_hash($obj), '->setService() registers a service under a key name'); + + $sc->foo1 = $obj1 = new \stdClass(); + $this->assertEquals(spl_object_hash($sc->foo1), spl_object_hash($obj1), '->__set() sets a service'); + + $this->assertEquals(spl_object_hash($sc->foo), spl_object_hash($obj), '->__get() gets a service by name'); + $this->assertTrue($sc->hasService('foo'), '->hasService() returns true if the service is defined'); + $this->assertTrue(isset($sc->foo), '->__isset() returns true if the service is defined'); + $this->assertTrue(!$sc->hasService('bar'), '->hasService() returns false if the service is not defined'); + $this->assertTrue(!isset($sc->bar), '->__isset() returns false if the service is not defined'); + } + + public function testGetServiceIds() + { + $sc = new Container(); + $sc->setService('foo', $obj = new \stdClass()); + $sc->setService('bar', $obj = new \stdClass()); + $this->assertEquals($sc->getServiceIds(), array('service_container', 'foo', 'bar'), '->getServiceIds() returns all defined service ids'); + + $sc = new ProjectServiceContainer(); + $this->assertEquals(spl_object_hash($sc->getService('bar')), spl_object_hash($sc->__bar), '->getService() looks for a getXXXService() method'); + $this->assertTrue($sc->hasService('bar'), '->hasService() returns true if the service has been defined as a getXXXService() method'); + + $sc->setService('bar', $bar = new \stdClass()); + $this->assertNotEquals(spl_object_hash($sc->getService('bar')), spl_object_hash($bar), '->getService() prefers to return a service defined with a getXXXService() method than one defined with setService()'); + + try + { + $sc->getService('baba'); + $this->fail('->getService() thrown an \InvalidArgumentException if the service does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $sc->baba; + $this->fail('->__get() thrown an \InvalidArgumentException if the service does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + unset($sc->baba); + $this->fail('->__unset() thrown an LogicException if you try to remove a service'); + } + catch (\LogicException $e) + { + } + + $this->assertEquals(spl_object_hash($sc->getService('foo_bar')), spl_object_hash($sc->__foo_bar), '->getService() camelizes the service id when looking for a method'); + $this->assertEquals(spl_object_hash($sc->getService('foo.baz')), spl_object_hash($sc->__foo_baz), '->getService() camelizes the service id when looking for a method'); + } + + public function testMagicCall() + { + $sc = new Container(); + $sc->setService('foo_bar.foo', $foo = new \stdClass()); + $this->assertEquals($sc->getFooBar_FooService(), $foo, '__call() finds services is the method is getXXXService()'); + + try + { + $sc->getFooBar_Foo(); + $this->fail('__call() throws a \RuntimeException exception if the method is not a service method'); + } + catch (\RuntimeException $e) + { + } + } +} + +class ProjectServiceContainer extends Container +{ + public $__bar, $__foo_bar, $__foo_baz; + + public function __construct() + { + parent::__construct(); + + $this->__bar = new \stdClass(); + $this->__foo_bar = new \stdClass(); + $this->__foo_baz = new \stdClass(); + } + + protected function getBarService() + { + return $this->__bar; + } + + protected function getFooBarService() + { + return $this->__foo_bar; + } + + protected function getFoo_BazService() + { + return $this->__foo_baz; + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php new file mode 100644 index 0000000000000..fc25578598538 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php @@ -0,0 +1,88 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; + +class CrossCheckTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../../../../fixtures/Symfony/Components/DependencyInjection/'; + + require_once self::$fixturesPath.'/includes/classes.php'; + require_once self::$fixturesPath.'/includes/foo.php'; + } + + public function testCrossCheck() + { + // cross-check loaders/dumpers + + $fixtures = array( + 'services1.xml' => 'xml', + 'services2.xml' => 'xml', + 'services6.xml' => 'xml', + 'services8.xml' => 'xml', + 'services9.xml' => 'xml', + + 'services1.yml' => 'yaml', + 'services2.yml' => 'yaml', + 'services6.yml' => 'yaml', + 'services8.yml' => 'yaml', + 'services9.yml' => 'yaml', + ); + + foreach ($fixtures as $fixture => $type) + { + $loaderClass = 'Symfony\\Components\\DependencyInjection\\Loader\\'.ucfirst($type).'FileLoader'; + $dumperClass = 'Symfony\\Components\\DependencyInjection\\Dumper\\'.ucfirst($type).'Dumper'; + + $container1 = new Builder(); + $loader1 = new $loaderClass($container1); + $loader1->load(self::$fixturesPath.'/'.$type.'/'.$fixture); + $container1->setParameter('path', self::$fixturesPath.'/includes'); + + $dumper = new $dumperClass($container1); + $tmp = tempnam('sf_service_container', 'sf'); + file_put_contents($tmp, $dumper->dump()); + + $container2 = new Builder(); + $loader2 = new $loaderClass($container2); + $loader2->load($tmp); + $container2->setParameter('path', self::$fixturesPath.'/includes'); + + unlink($tmp); + + $this->assertEquals(serialize($container1), serialize($container2), 'loading a dump from a previously loaded container returns the same container'); + + $this->assertEquals($container1->getParameters(), $container2->getParameters(), '->getParameters() returns the same value for both containers'); + + $services1 = array(); + foreach ($container1 as $id => $service) + { + $services1[$id] = serialize($service); + } + $services2 = array(); + foreach ($container2 as $id => $service) + { + $services2[$id] = serialize($service); + } + + unset($services1['service_container'], $services2['service_container']); + + $this->assertEquals($services1, $services2, 'Iterator on the containers returns the same services'); + } + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php new file mode 100644 index 0000000000000..d6a948a4a19f6 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Definition; + +class DefinitionTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $def = new Definition('stdClass'); + $this->assertEquals($def->getClass(), 'stdClass', '__construct() takes the class name as its first argument'); + + $def = new Definition('stdClass', array('foo')); + $this->assertEquals($def->getArguments(), array('foo'), '__construct() takes an optional array of arguments as its second argument'); + } + + public function testSetGetConstructor() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->setConstructor('foo')), spl_object_hash($def), '->setConstructor() implements a fluent interface'); + $this->assertEquals($def->getConstructor(), 'foo', '->getConstructor() returns the constructor name'); + } + + public function testSetGetClass() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->setClass('foo')), spl_object_hash($def), '->setClass() implements a fluent interface'); + $this->assertEquals($def->getClass(), 'foo', '->getClass() returns the class name'); + } + + public function testArguments() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->setArguments(array('foo'))), spl_object_hash($def), '->setArguments() implements a fluent interface'); + $this->assertEquals($def->getArguments(), array('foo'), '->getArguments() returns the arguments'); + $this->assertEquals(spl_object_hash($def->addArgument('bar')), spl_object_hash($def), '->addArgument() implements a fluent interface'); + $this->assertEquals($def->getArguments(), array('foo', 'bar'), '->addArgument() adds an argument'); + } + + public function testMethodCalls() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->setMethodCalls(array(array('foo', array('foo'))))), spl_object_hash($def), '->setMethodCalls() implements a fluent interface'); + $this->assertEquals($def->getMethodCalls(), array(array('foo', array('foo'))), '->getMethodCalls() returns the methods to call'); + $this->assertEquals(spl_object_hash($def->addMethodCall('bar', array('bar'))), spl_object_hash($def), '->addMethodCall() implements a fluent interface'); + $this->assertEquals($def->getMethodCalls(), array(array('foo', array('foo')), array('bar', array('bar'))), '->addMethodCall() adds a method to call'); + } + + public function testSetGetFile() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->setFile('foo')), spl_object_hash($def), '->setFile() implements a fluent interface'); + $this->assertEquals($def->getFile(), 'foo', '->getFile() returns the file to include'); + } + + public function testSetIsShared() + { + $def = new Definition('stdClass'); + $this->assertEquals($def->isShared(), true, '->isShared() returns true by default'); + $this->assertEquals(spl_object_hash($def->setShared(false)), spl_object_hash($def), '->setShared() implements a fluent interface'); + $this->assertEquals($def->isShared(), false, '->isShared() returns false if the instance must not be shared'); + } + + public function testSetGetConfigurator() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->setConfigurator('foo')), spl_object_hash($def), '->setConfigurator() implements a fluent interface'); + $this->assertEquals($def->getConfigurator(), 'foo', '->getConfigurator() returns the configurator'); + } + + public function testAnnotations() + { + $def = new Definition('stdClass'); + $this->assertEquals(spl_object_hash($def->addAnnotation('foo')), spl_object_hash($def), '->addAnnotation() implements a fluent interface'); + $this->assertEquals($def->getAnnotation('foo'), array(array()), '->getAnnotation() returns attributes for an annotation name'); + $def->addAnnotation('foo', array('foo' => 'bar')); + $this->assertEquals($def->getAnnotation('foo'), array(array(), array('foo' => 'bar')), '->addAnnotation() can adds the same annotation several times'); + $def->addAnnotation('bar', array('bar' => 'bar')); + $this->assertEquals($def->getAnnotations(), array( + 'foo' => array(array(), array('foo' => 'bar')), + 'bar' => array(array('bar' => 'bar')), + ), '->getAnnotations() returns all annotations'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php new file mode 100644 index 0000000000000..7894a31ae5119 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Dumper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Dumper\Dumper; + +class DumperTest extends \PHPUnit_Framework_TestCase +{ + public function testDump() + { + $builder = new Builder(); + $dumper = new ProjectDumper($builder); + try + { + $dumper->dump(); + $this->fail('->dump() returns a LogicException if the dump() method has not been overriden by a children class'); + } + catch (\LogicException $e) + { + } + } +} + +class ProjectDumper extends Dumper +{ +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php new file mode 100644 index 0000000000000..8863f17886b08 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Dumper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Dumper\GraphvizDumper; + +class GraphvizDumperTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'; + } + + public function testDump() + { + $dumper = new GraphvizDumper($container = new Builder()); + + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/graphviz/services1.dot'), '->dump() dumps an empty container as an empty dot file'); + + $container = new Builder(); + $dumper = new GraphvizDumper($container); + + $container = include self::$fixturesPath.'/containers/container9.php'; + $dumper = new GraphvizDumper($container); + $this->assertEquals($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services9.dot')), '->dump() dumps services'); + + $container = include self::$fixturesPath.'/containers/container10.php'; + $dumper = new GraphvizDumper($container); + $this->assertEquals($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10.dot')), '->dump() dumps services'); + + $container = include self::$fixturesPath.'/containers/container10.php'; + $dumper = new GraphvizDumper($container); + $this->assertEquals($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(self::$fixturesPath.'/graphviz/services10-1.dot')), '->dump() dumps services'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php new file mode 100644 index 0000000000000..8ffca976f8b67 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Dumper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Dumper\PhpDumper; + +class PhpDumperTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); + } + + public function testDump() + { + $dumper = new PhpDumper($container = new Builder()); + + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/php/services1.php'), '->dump() dumps an empty container as an empty PHP class'); + $this->assertEquals($dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer')), file_get_contents(self::$fixturesPath.'/php/services1-1.php'), '->dump() takes a class and a base_class options'); + + $container = new Builder(); + $dumper = new PhpDumper($container); + } + + public function testAddParameters() + { + $container = include self::$fixturesPath.'/containers/container8.php'; + $dumper = new PhpDumper($container); + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/php/services8.php'), '->dump() dumps parameters'); + } + + public function testAddService() + { + $container = include self::$fixturesPath.'/containers/container9.php'; + $dumper = new PhpDumper($container); + $this->assertEquals($dumper->dump(), str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/php/services9.php')), '->dump() dumps services'); + + $dumper = new PhpDumper($container = new Builder()); + $container->register('foo', 'FooClass')->addArgument(new \stdClass()); + try + { + $dumper->dump(); + $this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); + } + catch (\RuntimeException $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php new file mode 100644 index 0000000000000..24f0c7f8d0014 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Dumper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Dumper\XmlDumper; + +class XmlDumperTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); + } + + public function testDump() + { + $dumper = new XmlDumper($container = new Builder()); + + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/xml/services1.xml'), '->dump() dumps an empty container as an empty XML file'); + + $container = new Builder(); + $dumper = new XmlDumper($container); + } + + public function testAddParemeters() + { + $container = include self::$fixturesPath.'//containers/container8.php'; + $dumper = new XmlDumper($container); + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/xml/services8.xml'), '->dump() dumps parameters'); + } + + public function testAddService() + { + $container = include self::$fixturesPath.'/containers/container9.php'; + $dumper = new XmlDumper($container); + $this->assertEquals($dumper->dump(), str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/xml/services9.xml')), '->dump() dumps services'); + + $dumper = new XmlDumper($container = new Builder()); + $container->register('foo', 'FooClass')->addArgument(new \stdClass()); + try + { + $dumper->dump(); + $this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); + } + catch (\RuntimeException $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php new file mode 100644 index 0000000000000..fb8778f55de33 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Dumper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Dumper\YamlDumper; + +class YamlDumperTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); + } + + public function testDump() + { + $dumper = new YamlDumper($container = new Builder()); + + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/yaml/services1.yml'), '->dump() dumps an empty container as an empty YAML file'); + + $container = new Builder(); + $dumper = new YamlDumper($container); + } + + public function testAddParameters() + { + $container = include self::$fixturesPath.'/containers/container8.php'; + $dumper = new YamlDumper($container); + $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/yaml/services8.yml'), '->dump() dumps parameters'); + } + + public function testAddService() + { + $container = include self::$fixturesPath.'/containers/container9.php'; + $dumper = new YamlDumper($container); + $this->assertEquals($dumper->dump(), str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), '->dump() dumps services'); + + $dumper = new YamlDumper($container = new Builder()); + $container->register('foo', 'FooClass')->addArgument(new \stdClass()); + try + { + $dumper->dump(); + $this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); + } + catch (\RuntimeException $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php new file mode 100644 index 0000000000000..f0663126dfd99 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\FileResource; + +class FileResourceTest extends \PHPUnit_Framework_TestCase +{ + protected $resource; + protected $file; + + public function setUp() + { + $this->file = sys_get_temp_dir().'/tmp.xml'; + touch($this->file); + $this->resource = new FileResource($this->file); + } + + public function tearDown() + { + unlink($this->file); + } + + public function testGetResource() + { + $this->assertEquals($this->resource->getResource(), $this->file, '->getResource() returns the path to the resource'); + } + + public function testIsUptodate() + { + $this->assertTrue($this->resource->isUptodate(time() + 10), '->isUptodate() returns true if the resource has not changed'); + $this->assertTrue(!$this->resource->isUptodate(time() - 86400), '->isUptodate() returns false if the resource has been updated'); + + $resource = new FileResource('/____foo/foobar'.rand(1, 999999)); + $this->assertTrue(!$resource->isUptodate(time()), '->isUptodate() returns false if the resource does not exist'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php new file mode 100644 index 0000000000000..c24610b9d4a64 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Loader\FileLoader; + +class XmlDumperTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $loader = new ProjectLoader(__DIR__); + $this->assertEquals($loader->paths, array(__DIR__), '__construct() takes a path as its second argument'); + + $loader = new ProjectLoader(array(__DIR__, __DIR__)); + $this->assertEquals($loader->paths, array(__DIR__, __DIR__), '__construct() takes an array of paths as its second argument'); + } + + public function testGetAbsolutePath() + { + $loader = new ProjectLoader(array(__DIR__.'/../../../../../bin')); + $this->assertEquals($loader->getAbsolutePath('/foo.xml'), '/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals($loader->getAbsolutePath('c:\\\\foo.xml'), 'c:\\\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals($loader->getAbsolutePath('c:/foo.xml'), 'c:/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals($loader->getAbsolutePath('\\server\\foo.xml'), '\\server\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + + $this->assertEquals($loader->getAbsolutePath('FileLoaderTest.php', __DIR__), __DIR__.'/FileLoaderTest.php', '->getAbsolutePath() returns an absolute filename if the file exists in the current path'); + + $this->assertEquals($loader->getAbsolutePath('prove.php', __DIR__), __DIR__.'/../../../../../bin/prove.php', '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor'); + + $this->assertEquals($loader->getAbsolutePath('foo.xml', __DIR__), 'foo.xml', '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths'); + } +} + +class ProjectLoader extends FileLoader +{ + public $paths; + + public function load($resource) + { + } + + public function getAbsolutePath($file, $currentPath = null) + { + return parent::getAbsolutePath($file, $currentPath); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php new file mode 100644 index 0000000000000..579af40af93dd --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Loader\IniFileLoader; + +class IniLoaderTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); + } + + public function testLoader() + { + $loader = new IniFileLoader(self::$fixturesPath.'/ini'); + $config = $loader->load('parameters.ini'); + $this->assertEquals($config->getParameters(), array('foo' => 'bar', 'bar' => '%foo%'), '->load() takes a single file name as its first argument'); + + try + { + $loader->load('foo.ini'); + $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + @$loader->load('nonvalid.ini'); + $this->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable'); + } + catch (\InvalidArgumentException $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php new file mode 100644 index 0000000000000..5ae2a5b15b38f --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +require_once __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php'; + +class LoaderExtensionTest extends \PHPUnit_Framework_TestCase +{ + public function testLoad() + { + $extension = new \ProjectExtension(); + + try + { + $extension->load('foo', array()); + $this->fail('->load() throws an InvalidArgumentException if the tag does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + $config = $extension->load('bar', array('foo' => 'bar')); + $this->assertEquals($config->getParameters(), array('project.parameter.bar' => 'bar'), '->load() calls the method tied to the given tag'); + } +} diff --git a/tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php similarity index 51% rename from tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderTest.php rename to tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php index 59df8aab0ae68..986af5991799c 100644 --- a/tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php @@ -8,22 +8,26 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/../../../../bootstrap.php'; +namespace Symfony\Tests\Components\DependencyInjection\Loader; -use Symfony\Components\DependencyInjection\Loader\Loader; +require_once __DIR__.'/../../../bootstrap.php'; require_once __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php'; -class ProjectLoader extends Loader +use Symfony\Components\DependencyInjection\Loader\Loader; + +class ProjectLoader1 extends Loader { public function load($resource) { } } -$t = new LimeTest(1); - -// ::registerExtension() ::getExtension() -$t->diag('::registerExtension() ::getExtension()'); -ProjectLoader::registerExtension($extension = new ProjectExtension()); -$t->ok(ProjectLoader::getExtension('project') === $extension, '::registerExtension() registers an extension'); +class LoaderTest extends \PHPUnit_Framework_TestCase +{ + public function testExtension() + { + ProjectLoader1::registerExtension($extension = new \ProjectExtension()); + $this->assertTrue(ProjectLoader1::getExtension('project') === $extension, '::registerExtension() registers an extension'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php new file mode 100644 index 0000000000000..94fb11c84b307 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php @@ -0,0 +1,203 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Reference; +use Symfony\Components\DependencyInjection\Definition; +use Symfony\Components\DependencyInjection\Loader\Loader; +use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; + +class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); + require_once self::$fixturesPath.'/includes/ProjectExtension.php'; + } + + public function testLoad() + { + $loader = new ProjectLoader2(self::$fixturesPath.'/ini'); + + try + { + $loader->load('foo.xml'); + $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testParseFile() + { + $loader = new ProjectLoader2(self::$fixturesPath.'/ini'); + + try + { + $loader->parseFile(self::$fixturesPath.'/ini/parameters.ini'); + $this->fail('->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + } + catch (\InvalidArgumentException $e) + { + } + + $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); + + try + { + $loader->parseFile(self::$fixturesPath.'/xml/nonvalid.xml'); + $this->fail('->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + } + catch (\InvalidArgumentException $e) + { + } + + $xml = $loader->parseFile(self::$fixturesPath.'/xml/services1.xml'); + $this->assertEquals(get_class($xml), 'Symfony\\Components\\DependencyInjection\\SimpleXMLElement', '->parseFile() returns an SimpleXMLElement object'); + } + + public function testLoadParameters() + { + $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); + $config = $loader->load('services2.xml'); + + $actual = $config->getParameters(); + $expected = 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')); + + $this->assertEquals($actual, $expected, '->load() converts XML values to PHP ones'); + } + + public function testLoadImports() + { + $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); + $config = $loader->load('services4.xml'); + + $actual = $config->getParameters(); + $expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true); + + $this->assertEquals(array_keys($actual), array_keys($expected), '->load() imports and merges imported files'); + } + + public function testLoadAnonymousServices() + { + $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); + $config = $loader->load('services5.xml'); + $services = $config->getDefinitions(); + $this->assertEquals(count($services), 3, '->load() attributes unique ids to anonymous services'); + $args = $services['foo']->getArguments(); + $this->assertEquals(count($args), 1, '->load() references anonymous services as "normal" ones'); + $this->assertEquals(get_class($args[0]), 'Symfony\\Components\\DependencyInjection\\Reference', '->load() converts anonymous services to references to "normal" services'); + $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); + $inner = $services[(string) $args[0]]; + $this->assertEquals($inner->getClass(), 'BarClass', '->load() uses the same configuration as for the anonymous ones'); + + $args = $inner->getArguments(); + $this->assertEquals(count($args), 1, '->load() references anonymous services as "normal" ones'); + $this->assertEquals(get_class($args[0]), 'Symfony\\Components\\DependencyInjection\\Reference', '->load() converts anonymous services to references to "normal" services'); + $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); + $inner = $services[(string) $args[0]]; + $this->assertEquals($inner->getClass(), 'BazClass', '->load() uses the same configuration as for the anonymous ones'); + } + + public function testLoadServices() + { + $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); + $config = $loader->load('services6.xml'); + $services = $config->getDefinitions(); + $this->assertTrue(isset($services['foo']), '->load() parses elements'); + $this->assertEquals(get_class($services['foo']), 'Symfony\\Components\\DependencyInjection\\Definition', '->load() converts element to Definition instances'); + $this->assertEquals($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute'); + $this->assertTrue($services['shared']->isShared(), '->load() parses the shared attribute'); + $this->assertTrue(!$services['non_shared']->isShared(), '->load() parses the shared attribute'); + $this->assertEquals($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute'); + $this->assertEquals($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag'); + $this->assertEquals($services['arguments']->getArguments(), array('foo', new Reference('foo'), array(true, false)), '->load() parses the argument tags'); + $this->assertEquals($services['configurator1']->getConfigurator(), 'sc_configure', '->load() parses the configurator tag'); + $this->assertEquals($services['configurator2']->getConfigurator(), array(new Reference('baz'), 'configure'), '->load() parses the configurator tag'); + $this->assertEquals($services['configurator3']->getConfigurator(), array('BazClass', 'configureStatic'), '->load() parses the configurator tag'); + $this->assertEquals($services['method_call1']->getMethodCalls(), array(array('setBar', array())), '->load() parses the method_call tag'); + $this->assertEquals($services['method_call2']->getMethodCalls(), array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), '->load() parses the method_call tag'); + $aliases = $config->getAliases(); + $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses elements'); + $this->assertEquals($aliases['alias_for_foo'], 'foo', '->load() parses aliases'); + } + + public function testConvertDomElementToArray() + { + $doc = new \DOMDocument("1.0"); + $doc->loadXML('bar'); + $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), 'bar', '::convertDomElementToArray() converts a \DomElement to an array'); + + $doc = new \DOMDocument("1.0"); + $doc->loadXML(''); + $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => 'bar'), '::convertDomElementToArray() converts a \DomElement to an array'); + + $doc = new \DOMDocument("1.0"); + $doc->loadXML('bar'); + $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => 'bar'), '::convertDomElementToArray() converts a \DomElement to an array'); + + $doc = new \DOMDocument("1.0"); + $doc->loadXML('barbar'); + $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => array('value' => 'bar', 'foo' => 'bar')), '::convertDomElementToArray() converts a \DomElement to an array'); + + $doc = new \DOMDocument("1.0"); + $doc->loadXML(''); + $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => null), '::convertDomElementToArray() converts a \DomElement to an array'); + + $doc = new \DOMDocument("1.0"); + $doc->loadXML(''); + $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => null), '::convertDomElementToArray() converts a \DomElement to an array'); + } + + public function testExtensions() + { + Loader::registerExtension(new \ProjectExtension()); + $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); + + $config = $loader->load('services10.xml'); + $services = $config->getDefinitions(); + $parameters = $config->getParameters(); + $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); + $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); + + try + { + $config = $loader->load('services11.xml'); + $this->fail('->load() throws an InvalidArgumentException if the tag is not valid'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $config = $loader->load('services12.xml'); + $this->fail('->load() throws an InvalidArgumentException if an extension is not loaded'); + } + catch (\InvalidArgumentException $e) + { + } + } +} + +class ProjectLoader2 extends XmlFileLoader +{ + public function parseFile($file) + { + return parent::parseFile($file); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php new file mode 100644 index 0000000000000..6de3e76d0149a --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\Reference; +use Symfony\Components\DependencyInjection\Definition; +use Symfony\Components\DependencyInjection\Loader\Loader; +use Symfony\Components\DependencyInjection\Loader\YamlFileLoader; + +class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); + require_once self::$fixturesPath.'/includes/ProjectExtension.php'; + } + + public function testLoadFile() + { + $loader = new ProjectLoader3(self::$fixturesPath.'/ini'); + + try + { + $loader->loadFile('foo.yml'); + $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $loader->loadFile('parameters.ini'); + $this->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); + } + catch (\InvalidArgumentException $e) + { + } + + $loader = new ProjectLoader3(self::$fixturesPath.'/yaml'); + + foreach (array('nonvalid1', 'nonvalid2') as $fixture) + { + try + { + $loader->loadFile($fixture.'.yml'); + $this->fail('->load() throws an InvalidArgumentException if the loaded file does not validate'); + } + catch (\InvalidArgumentException $e) + { + } + } + } + + public function testLoadParameters() + { + $loader = new ProjectLoader3(self::$fixturesPath.'/yaml'); + $config = $loader->load('services2.yml'); + $this->assertEquals($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'); + } + + public function testLoadImports() + { + $loader = new ProjectLoader3(self::$fixturesPath.'/yaml'); + $config = $loader->load('services4.yml'); + + $actual = $config->getParameters(); + $expected = array('foo' => 'bar', 'values' => array(true, false), 'bar' => '%foo%', 'foo_bar' => new Reference('foo_bar'), 'imported_from_ini' => true, 'imported_from_xml' => true); + $this->assertEquals(array_keys($actual), array_keys($expected), '->load() imports and merges imported files'); + } + + public function testLoadServices() + { + $loader = new ProjectLoader3(self::$fixturesPath.'/yaml'); + $config = $loader->load('services6.yml'); + $services = $config->getDefinitions(); + $this->assertTrue(isset($services['foo']), '->load() parses service elements'); + $this->assertEquals(get_class($services['foo']), 'Symfony\\Components\\DependencyInjection\\Definition', '->load() converts service element to Definition instances'); + $this->assertEquals($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute'); + $this->assertTrue($services['shared']->isShared(), '->load() parses the shared attribute'); + $this->assertTrue(!$services['non_shared']->isShared(), '->load() parses the shared attribute'); + $this->assertEquals($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute'); + $this->assertEquals($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag'); + $this->assertEquals($services['arguments']->getArguments(), array('foo', new Reference('foo'), array(true, false)), '->load() parses the argument tags'); + $this->assertEquals($services['configurator1']->getConfigurator(), 'sc_configure', '->load() parses the configurator tag'); + $this->assertEquals($services['configurator2']->getConfigurator(), array(new Reference('baz'), 'configure'), '->load() parses the configurator tag'); + $this->assertEquals($services['configurator3']->getConfigurator(), array('BazClass', 'configureStatic'), '->load() parses the configurator tag'); + $this->assertEquals($services['method_call1']->getMethodCalls(), array(array('setBar', array())), '->load() parses the method_call tag'); + $this->assertEquals($services['method_call2']->getMethodCalls(), array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), '->load() parses the method_call tag'); + $aliases = $config->getAliases(); + $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses aliases'); + $this->assertEquals($aliases['alias_for_foo'], 'foo', '->load() parses aliases'); + } + + public function testExtensions() + { + Loader::registerExtension(new \ProjectExtension()); + $loader = new ProjectLoader3(self::$fixturesPath.'/yaml'); + + $config = $loader->load('services10.yml'); + $services = $config->getDefinitions(); + $parameters = $config->getParameters(); + $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); + $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); + + try + { + $config = $loader->load('services11.yml'); + $this->fail('->load() throws an InvalidArgumentException if the tag is not valid'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + $config = $loader->load('services12.yml'); + $this->fail('->load() throws an InvalidArgumentException if an extension is not loaded'); + } + catch (\InvalidArgumentException $e) + { + } + } +} + +class ProjectLoader3 extends YamlFileLoader +{ + public function loadFile($file) + { + return parent::loadFile($file); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php new file mode 100644 index 0000000000000..39d79f479f5e0 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Parameter; + +class ParameterTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $ref = new Parameter('foo'); + $this->assertEquals((string) $ref, 'foo', '__construct() sets the id of the parameter, which is used for the __toString() method'); + } +} diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php new file mode 100644 index 0000000000000..2528ae5a3d1e6 --- /dev/null +++ b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\DependencyInjection; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\DependencyInjection\Reference; + +class ReferenceTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $ref = new Reference('foo'); + $this->assertEquals((string) $ref, 'foo', '__construct() sets the id of the reference, which is used for the __toString() method'); + } +} diff --git a/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php b/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php new file mode 100644 index 0000000000000..62892ecb4aaa6 --- /dev/null +++ b/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\EventDispatcher; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\EventDispatcher\Event; +use Symfony\Components\EventDispatcher\EventDispatcher; + +class EventDispatcherTest extends \PHPUnit_Framework_TestCase +{ + public function testConnectAndDisconnect() + { + $dispatcher = new EventDispatcher(); + + $dispatcher->connect('bar', 'listenToBar'); + $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar'), '->connect() connects a listener to an event name'); + $dispatcher->connect('bar', 'listenToBarBar'); + $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar', 'listenToBarBar'), '->connect() can connect several listeners for the same event name'); + + $dispatcher->connect('barbar', 'listenToBarBar'); + $dispatcher->disconnect('bar', 'listenToBarBar'); + $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar'), '->disconnect() disconnects a listener for an event name'); + $this->assertEquals($dispatcher->getListeners('barbar'), array('listenToBarBar'), '->disconnect() disconnects a listener for an event name'); + + $this->assertTrue($dispatcher->disconnect('foobar', 'listen') === false, '->disconnect() returns false if the listener does not exist'); + } + + public function testGetHasListeners() + { + $dispatcher = new EventDispatcher(); + + $this->assertEquals($dispatcher->hasListeners('foo'), false, '->hasListeners() returns false if the event has no listener'); + $dispatcher->connect('foo', 'listenToFoo'); + $this->assertEquals($dispatcher->hasListeners('foo'), true, '->hasListeners() returns true if the event has some listeners'); + $dispatcher->disconnect('foo', 'listenToFoo'); + $this->assertEquals($dispatcher->hasListeners('foo'), false, '->hasListeners() returns false if the event has no listener'); + + $dispatcher->connect('bar', 'listenToBar'); + $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar'), '->getListeners() returns an array of listeners connected to the given event name'); + $this->assertEquals($dispatcher->getListeners('foobar'), array(), '->getListeners() returns an empty array if no listener are connected to the given event name'); + } + + public function testNotify() + { + $listener = new Listener(); + $dispatcher = new EventDispatcher(); + $dispatcher->connect('foo', array($listener, 'listenToFoo')); + $dispatcher->connect('foo', array($listener, 'listenToFooBis')); + $e = $dispatcher->notify($event = new Event(new \stdClass(), 'foo')); + $this->assertEquals($listener->getValue(), 'listenToFoolistenToFooBis', '->notify() notifies all registered listeners in order'); + $this->assertEquals($e, $event, '->notify() returns the event object'); + + $listener->reset(); + $dispatcher = new EventDispatcher(); + $dispatcher->connect('foo', array($listener, 'listenToFooBis')); + $dispatcher->connect('foo', array($listener, 'listenToFoo')); + $dispatcher->notify(new Event(new \stdClass(), 'foo')); + $this->assertEquals($listener->getValue(), 'listenToFooBislistenToFoo', '->notify() notifies all registered listeners in order'); + } + + public function testNotifyUntil() + { + $listener = new Listener(); + $dispatcher = new EventDispatcher(); + $dispatcher->connect('foo', array($listener, 'listenToFoo')); + $dispatcher->connect('foo', array($listener, 'listenToFooBis')); + $e = $dispatcher->notifyUntil($event = new Event(new \stdClass(), 'foo')); + $this->assertEquals($listener->getValue(), 'listenToFoolistenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); + $this->assertEquals($e, $event, '->notifyUntil() returns the event object'); + + $listener->reset(); + $dispatcher = new EventDispatcher(); + $dispatcher->connect('foo', array($listener, 'listenToFooBis')); + $dispatcher->connect('foo', array($listener, 'listenToFoo')); + $e = $dispatcher->notifyUntil($event = new Event(new \stdClass(), 'foo')); + $this->assertEquals($listener->getValue(), 'listenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); + } + + public function testFilter() + { + $listener = new Listener(); + $dispatcher = new EventDispatcher(); + $dispatcher->connect('foo', array($listener, 'filterFoo')); + $dispatcher->connect('foo', array($listener, 'filterFooBis')); + $e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); + $this->assertEquals($e->getReturnValue(), '-*foo*-', '->filter() filters a value'); + $this->assertEquals($e, $event, '->filter() returns the event object'); + + $listener->reset(); + $dispatcher = new EventDispatcher(); + $dispatcher->connect('foo', array($listener, 'filterFooBis')); + $dispatcher->connect('foo', array($listener, 'filterFoo')); + $e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); + $this->assertEquals($e->getReturnValue(), '*-foo-*', '->filter() filters a value'); + } +} + +class Listener +{ + protected + $value = ''; + + function filterFoo(Event $event, $foo) + { + return "*$foo*"; + } + + function filterFooBis(Event $event, $foo) + { + return "-$foo-"; + } + + function listenToFoo(Event $event) + { + $this->value .= 'listenToFoo'; + } + + function listenToFooBis(Event $event) + { + $this->value .= 'listenToFooBis'; + + return true; + } + + function getValue() + { + return $this->value; + } + + function reset() + { + $this->value = ''; + } +} diff --git a/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php b/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php new file mode 100644 index 0000000000000..a1ff17764a4db --- /dev/null +++ b/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\EventDispatcher; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\EventDispatcher\Event; + +class EventTest extends \PHPUnit_Framework_TestCase +{ + protected $subject; + protected $parameters; + + public function testGetSubject() + { + $this->assertEquals($this->createEvent()->getSubject(), $this->subject, '->getSubject() returns the event subject'); + } + + public function testGetName() + { + $this->assertEquals($this->createEvent()->getName(), 'name', '->getName() returns the event name'); + } + + public function testParameters() + { + $event = $this->createEvent(); + + $this->assertEquals($event->getParameters(), $this->parameters, '->getParameters() returns the event parameters'); + $this->assertEquals($event->getParameter('foo'), 'bar', '->getParameter() returns the value of a parameter'); + $event->setParameter('foo', 'foo'); + $this->assertEquals($event->getParameter('foo'), 'foo', '->setParameter() changes the value of a parameter'); + $this->assertTrue($event->hasParameter('foo'), '->hasParameter() returns true if the parameter is defined'); + unset($event['foo']); + $this->assertTrue(!$event->hasParameter('foo'), '->hasParameter() returns false if the parameter is not defined'); + + try + { + $event->getParameter('foobar'); + $this->fail('->getParameter() throws an \InvalidArgumentException exception when the parameter does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + $event = new Event($this->subject, 'name', $this->parameters); + } + + public function testSetGetReturnValue() + { + $event = $this->createEvent(); + $event->setReturnValue('foo'); + $this->assertEquals($event->getReturnValue(), 'foo', '->getReturnValue() returns the return value of the event'); + } + + public function testSetIsProcessed() + { + $event = $this->createEvent(); + $event->setProcessed(true); + $this->assertEquals($event->isProcessed(), true, '->isProcessed() returns true if the event has been processed'); + $event->setProcessed(false); + $this->assertEquals($event->isProcessed(), false, '->setProcessed() changes the processed status'); + } + + public function testArrayAccessInterface() + { + $event = $this->createEvent(); + + $this->assertEquals($event['foo'], 'bar', 'Event implements the ArrayAccess interface'); + $event['foo'] = 'foo'; + $this->assertEquals($event['foo'], 'foo', 'Event implements the ArrayAccess interface'); + + try + { + $event['foobar']; + $this->fail('::offsetGet() throws an \InvalidArgumentException exception when the parameter does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + $this->assertTrue(isset($event['foo']), 'Event implements the ArrayAccess interface'); + unset($event['foo']); + $this->assertTrue(!isset($event['foo']), 'Event implements the ArrayAccess interface'); + } + + protected function createEvent() + { + $this->subject = new \stdClass(); + $this->parameters = array('foo' => 'bar'); + + return new Event($this->subject, 'name', $this->parameters); + } +} diff --git a/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php new file mode 100644 index 0000000000000..e86e6e9d1c051 --- /dev/null +++ b/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\OutputEscaper\Escaper; + +class ArrayDecoratorTest extends \PHPUnit_Framework_TestCase +{ + static protected $escaped; + + static public function setUpBeforeClass() + { + $a = array('escaped!', 1, null, array(2, 'escaped!')); + + self::$escaped = Escaper::escape('entities', $a); + } + + public function testGetRaw() + { + $this->assertEquals(self::$escaped->getRaw(0), 'escaped!', '->getRaw() returns the raw value'); + } + + public function testArrayAccessInterface() + { + $this->assertEquals(self::$escaped[0], '<strong>escaped!</strong>', 'The escaped object behaves like an array'); + $this->assertEquals(self::$escaped[2], null, 'The escaped object behaves like an array'); + $this->assertEquals(self::$escaped[3][1], '<strong>escaped!</strong>', 'The escaped object behaves like an array'); + + $this->assertTrue(isset(self::$escaped[1]), 'The escaped object behaves like an array (isset)'); + + try + { + unset(self::$escaped[0]); + + $this->fail('The escaped object is read only (unset)'); + } + catch (\LogicException $e) + { + } + + try + { + self::$escaped[0] = 12; + + $this->fail('The escaped object is read only (set)'); + } + catch (\LogicException $e) + { + } + } + + public function testIteratorInterface() + { + foreach (self::$escaped as $key => $value) + { + switch ($key) + { + case 0: + $this->assertEquals($value, '<strong>escaped!</strong>', 'The escaped object behaves like an array'); + break; + case 1: + $this->assertEquals($value, 1, 'The escaped object behaves like an array'); + break; + case 2: + $this->assertEquals($value, null, 'The escaped object behaves like an array'); + break; + case 3: + break; + default: + $this->fail('The escaped object behaves like an array'); + } + } + } + + public function testCountableInterface() + { + $this->assertEquals(count(self::$escaped), 4, 'The escaped object implements the Countable interface'); + } +} diff --git a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php new file mode 100644 index 0000000000000..c63cba990fd42 --- /dev/null +++ b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\OutputEscaper\Escaper; +use Symfony\Components\OutputEscaper\SafeDecorator; +use Symfony\Components\OutputEscaper\IteratorDecorator; +use Symfony\Components\OutputEscaper\ArrayDecorator; +use Symfony\Components\OutputEscaper\ObjectDecorator; + +class EscaperTest extends \PHPUnit_Framework_TestCase +{ + public function testEscapeDoesNotEscapeSpecialValues() + { + $this->assertSame(Escaper::escape('entities', null), null, '::escape() returns null if the value to escape is null'); + $this->assertSame(Escaper::escape('entities', false), false, '::escape() returns false if the value to escape is false'); + $this->assertSame(Escaper::escape('entities', true), true, '::escape() returns true if the value to escape is true'); + } + + public function testEscapeDoesNotEscapeAValueWhenEscapingMethodIsRAW() + { + $this->assertEquals(Escaper::escape('raw', 'escaped!'), 'escaped!', '::escape() takes an escaping strategy function name as its first argument'); + } + + public function testEscapeEscapesStrings() + { + $this->assertEquals(Escaper::escape('entities', 'escaped!'), '<strong>escaped!</strong>', '::escape() returns an escaped string if the value to escape is a string'); + $this->assertEquals(Escaper::escape('entities', 'échappé'), '<strong>échappé</strong>', '::escape() returns an escaped string if the value to escape is a string'); + } + + public function testEscapeEscapesArrays() + { + $input = array( + 'foo' => 'escaped!', + 'bar' => array('foo' => 'escaped!'), + ); + $output = Escaper::escape('entities', $input); + $this->assertTrue($output instanceof ArrayDecorator, '::escape() returns a ArrayDecorator object if the value to escape is an array'); + $this->assertEquals($output['foo'], '<strong>escaped!</strong>', '::escape() escapes all elements of the original array'); + $this->assertEquals($output['bar']['foo'], '<strong>escaped!</strong>', '::escape() is recursive'); + $this->assertEquals($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); + } + + public function testEscapeEscapesObjects() + { + $input = new OutputEscaperTestClass(); + $output = Escaper::escape('entities', $input); + $this->assertTrue($output instanceof ObjectDecorator, '::escape() returns a ObjectDecorator object if the value to escape is an object'); + $this->assertEquals($output->getTitle(), '<strong>escaped!</strong>', '::escape() escapes all methods of the original object'); + $this->assertEquals($output->title, '<strong>escaped!</strong>', '::escape() escapes all properties of the original object'); + $this->assertEquals($output->getTitleTitle(), '<strong>escaped!</strong>', '::escape() is recursive'); + $this->assertEquals($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); + + $this->assertEquals(Escaper::escape('entities', $output)->getTitle(), '<strong>escaped!</strong>', '::escape() does not double escape an object'); + $this->assertTrue(Escaper::escape('entities', new \DirectoryIterator('.')) instanceof IteratorDecorator, '::escape() returns a IteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface'); + } + + public function testEscapeDoesNotEscapeObjectMarkedAsBeingSafe() + { + $this->assertTrue(Escaper::escape('entities', new SafeDecorator(new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::escape() returns the original value if it is marked as being safe'); + + Escaper::markClassAsSafe('Symfony\Tests\Components\OutputEscaper\OutputEscaperTestClass'); + $this->assertTrue(Escaper::escape('entities', new OutputEscaperTestClass()) instanceof OutputEscaperTestClass, '::escape() returns the original value if the object class is marked as being safe'); + $this->assertTrue(Escaper::escape('entities', new OutputEscaperTestClassChild()) instanceof OutputEscaperTestClassChild, '::escape() returns the original value if one of the object parent class is marked as being safe'); + } + + public function testEscapeCannotEscapeResources() + { + $fh = fopen(__FILE__, 'r'); + try + { + Escaper::escape('entities', $fh); + + $this->fail('::escape() throws an InvalidArgumentException if the value cannot be escaped'); + } + catch (\InvalidArgumentException $e) + { + } + fclose($fh); + } + + public function testUnescapeDoesNotUnescapeSpecialValues() + { + $this->assertTrue(Escaper::unescape(null) === null, '::unescape() returns null if the value to unescape is null'); + $this->assertTrue(Escaper::unescape(false) === false, '::unescape() returns false if the value to unescape is false'); + $this->assertTrue(Escaper::unescape(true) === true, '::unescape() returns true if the value to unescape is true'); + } + + public function testUnescapeUnescapesStrings() + { + $this->assertEquals(Escaper::unescape('<strong>escaped!</strong>'), 'escaped!', '::unescape() returns an unescaped string if the value to unescape is a string'); + $this->assertEquals(Escaper::unescape('<strong>échappé</strong>'), 'échappé', '::unescape() returns an unescaped string if the value to unescape is a string'); + } + + public function testUnescapeUnescapesArrays() + { + $input = Escaper::escape('entities', array( + 'foo' => 'escaped!', + 'bar' => array('foo' => 'escaped!'), + )); + $output = Escaper::unescape($input); + $this->assertTrue(is_array($output), '::unescape() returns an array if the input is a ArrayDecorator object'); + $this->assertEquals($output['foo'], 'escaped!', '::unescape() unescapes all elements of the original array'); + $this->assertEquals($output['bar']['foo'], 'escaped!', '::unescape() is recursive'); + } + + public function testUnescapeUnescapesObjects() + { + $object = new OutputEscaperTestClass(); + $input = Escaper::escape('entities', $object); + $output = Escaper::unescape($input); + $this->assertTrue($output instanceof OutputEscaperTestClass, '::unescape() returns the original object when a ObjectDecorator object is passed'); + $this->assertEquals($output->getTitle(), 'escaped!', '::unescape() unescapes all methods of the original object'); + $this->assertEquals($output->title, 'escaped!', '::unescape() unescapes all properties of the original object'); + $this->assertEquals($output->getTitleTitle(), 'escaped!', '::unescape() is recursive'); + + $this->assertTrue(IteratorDecorator::unescape(Escaper::escape('entities', new \DirectoryIterator('.'))) instanceof \DirectoryIterator, '::unescape() unescapes IteratorDecorator objects'); + } + + public function testUnescapeDoesNotUnescapeObjectMarkedAsBeingSafe() + { + $this->assertTrue(Escaper::unescape(Escaper::escape('entities', new SafeDecorator(new OutputEscaperTestClass()))) instanceof OutputEscaperTestClass, '::unescape() returns the original value if it is marked as being safe'); + + Escaper::markClassAsSafe('OutputEscaperTestClass'); + $this->assertTrue(Escaper::unescape(Escaper::escape('entities', new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::unescape() returns the original value if the object class is marked as being safe'); + $this->assertTrue(Escaper::unescape(Escaper::escape('entities', new OutputEscaperTestClassChild())) instanceof OutputEscaperTestClassChild, '::unescape() returns the original value if one of the object parent class is marked as being safe'); + } + + public function testUnescapeDoesNothingToResources() + { + $fh = fopen(__FILE__, 'r'); + $this->assertEquals(Escaper::unescape($fh), $fh, '::unescape() do nothing to resources'); + } + + public function testUnescapeUnescapesMixedArrays() + { + $object = new OutputEscaperTestClass(); + $input = array( + 'foo' => 'bar', + 'bar' => Escaper::escape('entities', 'bar'), + 'foobar' => Escaper::escape('entities', $object), + ); + $output = array( + 'foo' => 'bar', + 'bar' => 'bar', + 'foobar' => $object, + ); + $this->assertEquals(Escaper::unescape($input), $output, '::unescape() unescapes values with some escaped and unescaped values'); + } +} + +class OutputEscaperTestClass +{ + public $title = 'escaped!'; + + public function getTitle() + { + return $this->title; + } + + public function getTitleTitle() + { + $o = new self; + + return $o->getTitle(); + } +} + +class OutputEscaperTestClassChild extends OutputEscaperTestClass +{ +} diff --git a/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php new file mode 100644 index 0000000000000..c269ea63e5c0d --- /dev/null +++ b/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\OutputEscaper\Escaper; + +class ObjectDecoratorTest extends \PHPUnit_Framework_TestCase +{ + static protected $escaped; + + static public function setUpBeforeClass() + { + $object = new OutputEscaperTest(); + + self::$escaped = Escaper::escape('entities', $object); + } + + public function testGenericBehavior() + { + $this->assertEquals(self::$escaped->getTitle(), '<strong>escaped!</strong>', 'The escaped object behaves like the real object'); + + $array = self::$escaped->getTitles(); + $this->assertEquals($array[2], '<strong>escaped!</strong>', 'The escaped object behaves like the real object'); + } + + public function testMagicToString() + { + $this->assertEquals(self::$escaped->__toString(), '<strong>escaped!</strong>', 'The escaped object behaves like the real object'); + } +} + +class OutputEscaperTest +{ + public function __toString() + { + return $this->getTitle(); + } + + public function getTitle() + { + return 'escaped!'; + } + + public function getTitles() + { + return array(1, 2, 'escaped!'); + } +} diff --git a/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php new file mode 100644 index 0000000000000..97c91718d6966 --- /dev/null +++ b/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\OutputEscaper\SafeDecorator; + +class SafeDecoratorTest extends \PHPUnit_Framework_TestCase +{ + public function testGetValue() + { + $safe = new SafeDecorator('foo'); + $this->assertEquals($safe->getValue(), 'foo', '->getValue() returns the embedded value'); + } + + public function testMagicGetAndSet() + { + $safe = new SafeDecorator(new TestClass1()); + + $this->assertEquals($safe->foo, 'bar', '->__get() returns the object parameter'); + $safe->foo = 'baz'; + $this->assertEquals($safe->foo, 'baz', '->__set() sets the object parameter'); + } + + public function testMagicCall() + { + $safe = new SafeDecorator(new TestClass2()); + + $this->assertEquals($safe->doSomething(), 'ok', '->__call() invokes the embedded method'); + } + + public function testMagicIssetAndUnset() + { + $safe = new SafeDecorator(new TestClass3()); + + $this->assertEquals(isset($safe->boolValue), true, '->__isset() returns true if the property is not null'); + $this->assertEquals(isset($safe->nullValue), false, '->__isset() returns false if the property is null'); + $this->assertEquals(isset($safe->undefinedValue), false, '->__isset() returns false if the property does not exist'); + + unset($safe->boolValue); + $this->assertEquals(isset($safe->boolValue), false, '->__unset() unsets the embedded property'); + } + + public function testIteratorInterface() + { + $input = array('one' => 1, 'two' => 2, 'three' => 3, 'children' => array(1, 2, 3)); + $output = array(); + + $safe = new SafeDecorator($input); + foreach ($safe as $key => $value) + { + $output[$key] = $value; + } + $this->assertSame($output, $input, '"Iterator" implementation imitates an array'); + } + + public function testArrayAccessIterator() + { + $safe = new SafeDecorator(array('foo' => 'bar')); + + $this->assertEquals($safe['foo'], 'bar', '"ArrayAccess" implementation returns a value from the embedded array'); + $safe['foo'] = 'baz'; + $this->assertEquals($safe['foo'], 'baz', '"ArrayAccess" implementation sets a value on the embedded array'); + $this->assertEquals(isset($safe['foo']), true, '"ArrayAccess" checks if a value is set on the embedded array'); + unset($safe['foo']); + $this->assertEquals(isset($safe['foo']), false, '"ArrayAccess" unsets a value on the embedded array'); + } +} + +class TestClass1 +{ + public $foo = 'bar'; +} + +class TestClass2 +{ + public function doSomething() + { + return 'ok'; + } +} + +class TestClass3 +{ + public + $boolValue = true, + $nullValue = null; +} diff --git a/tests/Symfony/Tests/Components/Yaml/DumperTest.php b/tests/Symfony/Tests/Components/Yaml/DumperTest.php new file mode 100644 index 0000000000000..7220e182dafb1 --- /dev/null +++ b/tests/Symfony/Tests/Components/Yaml/DumperTest.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\Yaml\Yaml; +use Symfony\Components\Yaml\Parser; +use Symfony\Components\Yaml\Dumper; + +class DumperTest extends \PHPUnit_Framework_TestCase +{ + protected $parser; + protected $dumper; + protected $path; + + static public function setUpBeforeClass() + { + Yaml::setSpecVersion('1.1'); + } + + public function setUp() + { + $this->parser = new Parser(); + $this->dumper = new Dumper(); + $this->path = __DIR__.'/../../../../fixtures/Symfony/Components/Yaml'; + } + + public function testSpecifications() + { + $files = $this->parser->parse(file_get_contents($this->path.'/index.yml')); + foreach ($files as $file) + { + $yamls = file_get_contents($this->path.'/'.$file.'.yml'); + + // split YAMLs documents + foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) + { + if (!$yaml) + { + continue; + } + + $test = $this->parser->parse($yaml); + if (isset($test['dump_skip']) && $test['dump_skip']) + { + continue; + } + else if (isset($test['todo']) && $test['todo']) + { + // TODO + } + else + { + $expected = eval('return '.trim($test['php']).';'); + + $this->assertEquals($this->parser->parse($this->dumper->dump($expected, 10)), $expected, $test['test']); + } + } + } + } + + public function testInlineLevel() + { + // inline level + $array = array( + '' => 'bar', + 'foo' => '#bar', + 'foo\'bar' => array(), + 'bar' => array(1, 'foo'), + 'foobar' => array( + 'foo' => 'bar', + 'bar' => array(1, 'foo'), + 'foobar' => array( + 'foo' => 'bar', + 'bar' => array(1, 'foo'), + ), + ), + ); + + $expected = <<assertEquals($this->dumper->dump($array, -10), $expected, '->dump() takes an inline level argument'); +$this->assertEquals($this->dumper->dump($array, 0), $expected, '->dump() takes an inline level argument'); + +$expected = <<assertEquals($this->dumper->dump($array, 1), $expected, '->dump() takes an inline level argument'); + + $expected = <<assertEquals($this->dumper->dump($array, 2), $expected, '->dump() takes an inline level argument'); + + $expected = <<assertEquals($this->dumper->dump($array, 3), $expected, '->dump() takes an inline level argument'); + + $expected = <<assertEquals($this->dumper->dump($array, 4), $expected, '->dump() takes an inline level argument'); + $this->assertEquals($this->dumper->dump($array, 10), $expected, '->dump() takes an inline level argument'); + } + + public function testObjectsSupport() + { + $a = array('foo' => new A(), 'bar' => 1); + + $this->assertEquals($this->dumper->dump($a), '{ foo: !!php/object:O:40:"Symfony\Tests\Components\OutputEscaper\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', '->dump() is able to dump objects'); + } +} + +class A +{ + public $a = 'foo'; +} diff --git a/tests/Symfony/Tests/Components/Yaml/InlineTest.php b/tests/Symfony/Tests/Components/Yaml/InlineTest.php new file mode 100644 index 0000000000000..47501a1f62977 --- /dev/null +++ b/tests/Symfony/Tests/Components/Yaml/InlineTest.php @@ -0,0 +1,163 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\Yaml\Yaml; +use Symfony\Components\Yaml\Inline; + +class InlineTest extends \PHPUnit_Framework_TestCase +{ + static public function setUpBeforeClass() + { + Yaml::setSpecVersion('1.1'); + } + + public function testLoad() + { + foreach ($this->getTestsForLoad() as $yaml => $value) + { + $this->assertEquals(Inline::load($yaml), $value, sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml)); + } + } + + public function testDump() + { + $testsForDump = $this->getTestsForDump(); + + foreach ($testsForDump as $yaml => $value) + { + $this->assertEquals(Inline::dump($value), $yaml, sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); + } + + foreach ($this->getTestsForLoad() as $yaml => $value) + { + if ($value == 1230) + { + continue; + } + + $this->assertEquals(Inline::load(Inline::dump($value)), $value, 'check consistency'); + } + + foreach ($testsForDump as $yaml => $value) + { + if ($value == 1230) + { + continue; + } + + $this->assertEquals(Inline::load(Inline::dump($value)), $value, 'check consistency'); + } + } + + protected function getTestsForLoad() + { + return array( + '' => '', + 'null' => null, + 'false' => false, + 'true' => true, + '12' => 12, + '"quoted string"' => 'quoted string', + "'quoted string'" => 'quoted string', + '12.30e+02' => 12.30e+02, + '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\'', + + // sequences + // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon + '[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'), + + // mappings + '{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'), + + // nested sequences and mappings + '[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'))), + ); + } + + protected function getTestsForDump() + { + return array( + 'null' => null, + 'false' => false, + 'true' => true, + '12' => 12, + "'quoted string'" => 'quoted string', + '12.30e+02' => 12.30e+02, + '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\'', + + // sequences + '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), + '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), + + // mappings + '{ 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'), + + // nested sequences and mappings + '[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'))), + ); + } +} diff --git a/tests/Symfony/Tests/Components/Yaml/ParserTest.php b/tests/Symfony/Tests/Components/Yaml/ParserTest.php new file mode 100644 index 0000000000000..5e1d4ed100853 --- /dev/null +++ b/tests/Symfony/Tests/Components/Yaml/ParserTest.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\OutputEscaper; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\Yaml\Yaml; +use Symfony\Components\Yaml\Parser; +use Symfony\Components\Yaml\ParserException; + +class ParserTest extends \PHPUnit_Framework_TestCase +{ + protected $parser; + protected $path; + + static public function setUpBeforeClass() + { + Yaml::setSpecVersion('1.1'); + } + + public function setUp() + { + $this->parser = new Parser(); + $this->path = __DIR__.'/../../../../fixtures/Symfony/Components/Yaml'; + } + + public function testSpecifications() + { + $files = $this->parser->parse(file_get_contents($this->path.'/index.yml')); + foreach ($files as $file) + { + $yamls = file_get_contents($this->path.'/'.$file.'.yml'); + + // split YAMLs documents + foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) + { + if (!$yaml) + { + continue; + } + + $test = $this->parser->parse($yaml); + if (isset($test['todo']) && $test['todo']) + { + // TODO + } + else + { + $expected = var_export(eval('return '.trim($test['php']).';'), true); + + $this->assertEquals(var_export($this->parser->parse($test['yaml']), true), $expected, $test['test']); + } + } + } + } + + public function testTabsInYaml() + { + // test tabs in YAML + $yamls = array( + "foo:\n bar", + "foo:\n bar", + "foo:\n bar", + "foo:\n bar", + ); + + foreach ($yamls as $yaml) + { + try + { + $content = $this->parser->parse($yaml); + + $this->fail('YAML files must not contain tabs'); + } + catch (ParserException $e) + { + } + } + } + + public function testObjectsSupport() + { + $b = array('foo' => new B(), 'bar' => 1); + $this->assertEquals($this->parser->parse(<<parse() is able to dump objects'); + } +} + +class B +{ + public $b = 'foo'; +} diff --git a/tests/unit/Symfony/Components/Console/Output/NullOutputTest.php b/tests/Symfony/Tests/bootstrap.php similarity index 50% rename from tests/unit/Symfony/Components/Console/Output/NullOutputTest.php rename to tests/Symfony/Tests/bootstrap.php index 096a1cf78f303..5eefbe7ebb22c 100644 --- a/tests/unit/Symfony/Components/Console/Output/NullOutputTest.php +++ b/tests/Symfony/Tests/bootstrap.php @@ -2,18 +2,16 @@ /* * This file is part of the symfony package. + * * (c) Fabien Potencier * * 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\Console\Output\NullOutput; - -$t = new LimeTest(1); +require_once __DIR__.'/../../../src/Symfony/Foundation/ClassLoader.php'; +require_once 'PHPUnit/Framework.php'; -$output = new NullOutput(); -$output->write('foo'); -$t->pass('->write() does nothing'); +$loader = new Symfony\Foundation\ClassLoader(); +$loader->registerNamespace('Symfony', __DIR__.'/../../../src'); +$loader->register(); diff --git a/tests/unit/Symfony/Components/Console/ApplicationTest.php b/tests/unit/Symfony/Components/Console/ApplicationTest.php deleted file mode 100644 index ad5b752266357..0000000000000 --- a/tests/unit/Symfony/Components/Console/ApplicationTest.php +++ /dev/null @@ -1,312 +0,0 @@ - - * - * 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\Console\Application; -use Symfony\Components\Console\Input\ArrayInput; -use Symfony\Components\Console\Output\Output; -use Symfony\Components\Console\Output\StreamOutput; -use Symfony\Components\Console\Tester\ApplicationTester; - -$fixtures = __DIR__.'/../../../../fixtures/Symfony/Components/Console'; - -require_once $fixtures.'/FooCommand.php'; -require_once $fixtures.'/Foo1Command.php'; -require_once $fixtures.'/Foo2Command.php'; - -$t = new LimeTest(52); - -// __construct() -$t->diag('__construct()'); -$application = new Application('foo', 'bar'); -$t->is($application->getName(), 'foo', '__construct() takes the application name as its first argument'); -$t->is($application->getVersion(), 'bar', '__construct() takes the application version as its first argument'); -$t->is(array_keys($application->getCommands()), array('help', 'list'), '__construct() registered the help and list commands by default'); - -// ->setName() ->getName() -$t->diag('->setName() ->getName()'); -$application = new Application(); -$application->setName('foo'); -$t->is($application->getName(), 'foo', '->setName() sets the name of the application'); - -// ->getVersion() ->getVersion() -$t->diag('->getVersion() ->getVersion()'); -$application = new Application(); -$application->setVersion('bar'); -$t->is($application->getVersion(), 'bar', '->setVersion() sets the version of the application'); - -// ->getLongVersion() -$t->diag('->getLongVersion()'); -$application = new Application('foo', 'bar'); -$t->is($application->getLongVersion(), 'foo version bar', '->getLongVersion() returns the long version of the application'); - -// ->getHelp() -$t->diag('->getHelp()'); -$application = new Application(); -$t->is($application->getHelp(), file_get_contents($fixtures.'/application_gethelp.txt'), '->setHelp() returns a help message'); - -// ->getCommands() -$t->diag('->getCommands()'); -$application = new Application(); -$commands = $application->getCommands(); -$t->is(get_class($commands['help']), 'Symfony\\Components\\Console\\Command\\HelpCommand', '->getCommands() returns the registered commands'); - -$application->addCommand(new FooCommand()); -$commands = $application->getCommands('foo'); -$t->is(count($commands), 1, '->getCommands() takes a namespace as its first argument'); - -// ->register() -$t->diag('->register()'); -$application = new Application(); -$command = $application->register('foo'); -$t->is($command->getName(), 'foo', '->register() regiters a new command'); - -// ->addCommand() ->addCommands() -$t->diag('->addCommand() ->addCommands()'); -$application = new Application(); -$application->addCommand($foo = new FooCommand()); -$commands = $application->getCommands(); -$t->is($commands['foo:bar'], $foo, '->addCommand() registers a command'); - -$application = new Application(); -$application->addCommands(array($foo = new FooCommand(), $foo1 = new Foo1Command())); -$commands = $application->getCommands(); -$t->is(array($commands['foo:bar'], $commands['foo:bar1']), array($foo, $foo1), '->addCommands() registers an array of commands'); - -// ->hasCommand() ->getCommand() -$t->diag('->hasCommand() ->getCommand()'); -$application = new Application(); -$t->ok($application->hasCommand('list'), '->hasCommand() returns true if a named command is registered'); -$t->ok(!$application->hasCommand('afoobar'), '->hasCommand() returns false if a named command is not registered'); - -$application->addCommand($foo = new FooCommand()); -$t->ok($application->hasCommand('afoobar'), '->hasCommand() returns true if an alias is registered'); -$t->is($application->getCommand('foo:bar'), $foo, '->getCommand() returns a command by name'); -$t->is($application->getCommand('afoobar'), $foo, '->getCommand() returns a command by alias'); - -try -{ - $application->getCommand('foofoo'); - $t->fail('->getCommand() throws an \InvalidArgumentException if the command does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getCommand() throws an \InvalidArgumentException if the command does not exist'); -} - -class TestApplication extends Application -{ - public function setWantHelps() - { - $this->wantHelps = true; - } -} -$application = new TestApplication(); -$application->addCommand($foo = new FooCommand()); -$application->setWantHelps(); -$command = $application->getCommand('foo:bar'); -$t->is(get_class($command), 'Symfony\Components\Console\Command\HelpCommand', '->getCommand() returns the help command if --help is provided as the input'); - -// ->getNamespaces() -$t->diag('->getNamespaces()'); -$application = new TestApplication(); -$application->addCommand(new FooCommand()); -$application->addCommand(new Foo1Command()); -$t->is($application->getNamespaces(), array('foo'), '->getNamespaces() returns an array of unique used namespaces'); - -// ->findNamespace() -$t->diag('->findNamespace()'); -$application = new TestApplication(); -$application->addCommand(new FooCommand()); -$t->is($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); -$t->is($application->findNamespace('f'), 'foo', '->findNamespace() finds a namespace given an abbreviation'); -$application->addCommand(new Foo2Command()); -$t->is($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); -try -{ - $application->findNamespace('f'); - $t->fail('->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); -} - -try -{ - $application->findNamespace('bar'); - $t->fail('->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); -} - -// ->findCommand() -$t->diag('->findCommand()'); -$application = new TestApplication(); -$application->addCommand(new FooCommand()); -$t->is(get_class($application->findCommand('foo:bar')), 'FooCommand', '->findCommand() returns a command if its name exists'); -$t->is(get_class($application->findCommand('h')), 'Symfony\Components\Console\Command\HelpCommand', '->findCommand() returns a command if its name exists'); -$t->is(get_class($application->findCommand('f:bar')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace exists'); -$t->is(get_class($application->findCommand('f:b')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace and the command name exist'); -$t->is(get_class($application->findCommand('a')), 'FooCommand', '->findCommand() returns a command if the abbreviation exists for an alias'); - -$application->addCommand(new Foo1Command()); -$application->addCommand(new Foo2Command()); - -try -{ - $application->findCommand('f'); - $t->fail('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); -} - -try -{ - $application->findCommand('a'); - $t->fail('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); -} - -try -{ - $application->findCommand('foo:b'); - $t->fail('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a taks'); -} - -// ->setCatchExceptions() -$t->diag('->setCatchExceptions()'); -$application = new Application(); -$application->setAutoExit(false); -$tester = new ApplicationTester($application); - -$application->setCatchExceptions(true); -$tester->run(array('command' => 'foo')); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_renderexception1.txt'), '->setCatchExceptions() sets the catch exception flag'); - -$application->setCatchExceptions(false); -try -{ - $tester->run(array('command' => 'foo')); - $t->fail('->setCatchExceptions() sets the catch exception flag'); -} -catch (\Exception $e) -{ - $t->pass('->setCatchExceptions() sets the catch exception flag'); -} - -// ->asText() -$t->diag('->asText()'); -$application = new Application(); -$application->addCommand(new FooCommand); -$t->is($application->asText(), file_get_contents($fixtures.'/application_astext1.txt'), '->asText() returns a text representation of the application'); -$t->is($application->asText('foo'), file_get_contents($fixtures.'/application_astext2.txt'), '->asText() returns a text representation of the application'); - -// ->asXml() -$t->diag('->asXml()'); -$application = new Application(); -$application->addCommand(new FooCommand); -$t->is($application->asXml(), file_get_contents($fixtures.'/application_asxml1.txt'), '->asXml() returns an XML representation of the application'); -$t->is($application->asXml('foo'), file_get_contents($fixtures.'/application_asxml2.txt'), '->asXml() returns an XML representation of the application'); - -// ->renderException() -$t->diag('->renderException()'); -$application = new Application(); -$application->setAutoExit(false); -$tester = new ApplicationTester($application); - -$tester->run(array('command' => 'foo')); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_renderexception1.txt'), '->renderException() renders a pretty exception'); - -$tester->run(array('command' => 'foo'), array('verbosity' => Output::VERBOSITY_VERBOSE)); -$t->like($tester->getDisplay(), '/Exception trace/', '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); - -$tester->run(array('command' => 'list', '--foo' => true)); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_renderexception2.txt'), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); - -// ->run() -$t->diag('->run()'); -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$application->addCommand($command = new Foo1Command()); -$_SERVER['argv'] = array('cli.php', 'foo:bar1'); - -ob_start(); -$application->run(); -ob_end_clean(); - -$t->is(get_class($command->input), 'Symfony\Components\Console\Input\ArgvInput', '->run() creates an ArgvInput by default if none is given'); -$t->is(get_class($command->output), 'Symfony\Components\Console\Output\ConsoleOutput', '->run() creates a ConsoleOutput by default if none is given'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$tester = new ApplicationTester($application); -$tester->run(array()); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_run1.txt'), '->run() runs the list command if no argument is passed'); - -$tester->run(array('--help' => true)); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_run2.txt'), '->run() runs the help command if --help is passed'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$tester = new ApplicationTester($application); -$tester->run(array('command' => 'list', '--help' => true)); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_run3.txt'), '->run() displays the help if --help is passed'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$tester = new ApplicationTester($application); -$tester->run(array('--color' => true)); -$t->ok($tester->getOutput()->isDecorated(), '->run() forces color output if --color is passed'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$tester = new ApplicationTester($application); -$tester->run(array('--version' => true)); -$t->is($tester->getDisplay(), file_get_contents($fixtures.'/application_run4.txt'), '->run() displays the program version if --version is passed'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$tester = new ApplicationTester($application); -$tester->run(array('command' => 'list', '--quiet' => true)); -$t->is($tester->getDisplay(), '', '->run() removes all output if --quiet is passed'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$tester = new ApplicationTester($application); -$tester->run(array('command' => 'list', '--verbose' => true)); -$t->is($tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->run() sets the output to verbose is --verbose is passed'); - -$application = new Application(); -$application->setAutoExit(false); -$application->setCatchExceptions(false); -$application->addCommand(new FooCommand()); -$tester = new ApplicationTester($application); -$tester->run(array('command' => 'foo:bar', '--no-interaction' => true)); -$t->is($tester->getDisplay(), "called\n", '->run() does not called interact() if --no-interaction is passed'); diff --git a/tests/unit/Symfony/Components/Console/Command/CommandTest.php b/tests/unit/Symfony/Components/Console/Command/CommandTest.php deleted file mode 100644 index 7753969419afd..0000000000000 --- a/tests/unit/Symfony/Components/Console/Command/CommandTest.php +++ /dev/null @@ -1,206 +0,0 @@ - - * - * 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\Console\Command\Command; -use Symfony\Components\Console\Application; -use Symfony\Components\Console\Input\InputDefinition; -use Symfony\Components\Console\Input\InputArgument; -use Symfony\Components\Console\Input\InputOption; -use Symfony\Components\Console\Input\InputInterface; -use Symfony\Components\Console\Input\StringInput; -use Symfony\Components\Console\Output\OutputInterface; -use Symfony\Components\Console\Output\NullOutput; -use Symfony\Components\Console\Output\StreamOutput; -use Symfony\Components\Console\Tester\CommandTester; - -$fixtures = __DIR__.'/../../../../../fixtures/Symfony/Components/Console'; - -$t = new LimeTest(46); - -require_once $fixtures.'/TestCommand.php'; - -$application = new Application(); - -// __construct() -$t->diag('__construct()'); -try -{ - $command = new Command(); - $t->fail('__construct() throws a \LogicException if the name is null'); -} -catch (\LogicException $e) -{ - $t->pass('__construct() throws a \LogicException if the name is null'); -} -$command = new Command('foo:bar'); -$t->is($command->getFullName(), 'foo:bar', '__construct() takes the command name as its first argument'); - -// ->setApplication() -$t->diag('->setApplication()'); -$command = new TestCommand(); -$command->setApplication($application); -$t->is($command->getApplication(), $application, '->setApplication() sets the current application'); - -// ->setDefinition() ->getDefinition() -$t->diag('->setDefinition() ->getDefinition()'); -$ret = $command->setDefinition($definition = new InputDefinition()); -$t->is($ret, $command, '->setDefinition() implements a fluent interface'); -$t->is($command->getDefinition(), $definition, '->setDefinition() sets the current InputDefinition instance'); -$command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); -$t->ok($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); -$t->ok($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); -$command->setDefinition(new InputDefinition()); - -// ->addArgument() -$t->diag('->addArgument()'); -$ret = $command->addArgument('foo'); -$t->is($ret, $command, '->addArgument() implements a fluent interface'); -$t->ok($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command'); - -// ->addOption() -$t->diag('->addOption()'); -$ret = $command->addOption('foo'); -$t->is($ret, $command, '->addOption() implements a fluent interface'); -$t->ok($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command'); - -// ->getNamespace() ->getName() ->getFullName() ->setName() -$t->diag('->getNamespace() ->getName() ->getFullName()'); -$t->is($command->getNamespace(), 'namespace', '->getNamespace() returns the command namespace'); -$t->is($command->getName(), 'name', '->getName() returns the command name'); -$t->is($command->getFullName(), 'namespace:name', '->getNamespace() returns the full command name'); -$command->setName('foo'); -$t->is($command->getName(), 'foo', '->setName() sets the command name'); - -$command->setName(':bar'); -$t->is($command->getName(), 'bar', '->setName() sets the command name'); -$t->is($command->getNamespace(), '', '->setName() can set the command namespace'); - -$ret = $command->setName('foobar:bar'); -$t->is($ret, $command, '->setName() implements a fluent interface'); -$t->is($command->getName(), 'bar', '->setName() sets the command name'); -$t->is($command->getNamespace(), 'foobar', '->setName() can set the command namespace'); - -try -{ - $command->setName(''); - $t->fail('->setName() throws an \InvalidArgumentException if the name is empty'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->setName() throws an \InvalidArgumentException if the name is empty'); -} - -try -{ - $command->setName('foo:'); - $t->fail('->setName() throws an \InvalidArgumentException if the name is empty'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->setName() throws an \InvalidArgumentException if the name is empty'); -} - -// ->getDescription() ->setDescription() -$t->diag('->getDescription() ->setDescription()'); -$t->is($command->getDescription(), 'description', '->getDescription() returns the description'); -$ret = $command->setDescription('description1'); -$t->is($ret, $command, '->setDescription() implements a fluent interface'); -$t->is($command->getDescription(), 'description1', '->setDescription() sets the description'); - -// ->getHelp() ->setHelp() -$t->diag('->getHelp() ->setHelp()'); -$t->is($command->getHelp(), 'help', '->getHelp() returns the help'); -$ret = $command->setHelp('help1'); -$t->is($ret, $command, '->setHelp() implements a fluent interface'); -$t->is($command->getHelp(), 'help1', '->setHelp() sets the help'); - -// ->getAliases() ->setAliases() -$t->diag('->getAliases() ->setAliases()'); -$t->is($command->getAliases(), array('name'), '->getAliases() returns the aliases'); -$ret = $command->setAliases(array('name1')); -$t->is($ret, $command, '->setAliases() implements a fluent interface'); -$t->is($command->getAliases(), array('name1'), '->setAliases() sets the aliases'); - -// ->getSynopsis() -$t->diag('->getSynopsis()'); -$t->is($command->getSynopsis(), 'foobar:bar [--foo] [foo]', '->getSynopsis() returns the synopsis'); - -// ->mergeApplicationDefinition() -$t->diag('->mergeApplicationDefinition()'); -$application1 = new Application(); -$application1->getDefinition()->addArguments(array(new InputArgument('foo'))); -$application1->getDefinition()->addOptions(array(new InputOption('bar'))); -$command = new TestCommand(); -$command->setApplication($application1); -$command->setDefinition($definition = new InputDefinition(array(new InputArgument('bar'), new InputOption('foo')))); -$command->mergeApplicationDefinition(); -$t->ok($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); -$t->ok($command->getDefinition()->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); -$t->ok($command->getDefinition()->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options'); -$t->ok($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options'); - -$command->mergeApplicationDefinition(); -$t->is($command->getDefinition()->getArgumentCount(), 3, '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); - -$command = new TestCommand(); -$command->mergeApplicationDefinition(); -$t->pass('->mergeApplicationDefinition() does nothing if application is not set'); - -// ->run() -$t->diag('->run()'); -$command = new TestCommand(); -$command->setApplication($application); -$tester = new CommandTester($command); -try -{ - $tester->execute(array('--bar' => true)); - $t->fail('->run() throws a \RuntimeException when the input does not validate the current InputDefinition'); -} -catch (\RuntimeException $e) -{ - $t->pass('->run() throws a \RuntimeException when the input does not validate the current InputDefinition'); -} - -$t->is($tester->execute(array(), array('interactive' => true)), "interact called\nexecute called\n", '->run() calls the interact() method if the input is interactive'); -$t->is($tester->execute(array(), array('interactive' => false)), "execute called\n", '->run() does not call the interact() method if the input is not interactive'); - -$command = new Command('foo'); -try -{ - $command->run(new StringInput(''), new NullOutput()); - $t->fail('->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided'); -} -catch (\LogicException $e) -{ - $t->pass('->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided'); -} - -// ->setCode() -$t->diag('->setCode()'); -$command = new TestCommand(); -$command->setApplication($application); -$ret = $command->setCode(function (InputInterface $input, OutputInterface $output) -{ - $output->writeln('from the code...'); -}); -$t->is($ret, $command, '->setCode() implements a fluent interface'); -$tester = new CommandTester($command); -$tester->execute(array()); -$t->is($tester->getDisplay(), "interact called\nfrom the code...\n"); - -// ->asText() -$t->diag('->asText()'); -$t->is($command->asText(), file_get_contents($fixtures.'/command_astext.txt'), '->asText() returns a text representation of the command'); - -// ->asXml() -$t->diag('->asXml()'); -$t->is($command->asXml(), file_get_contents($fixtures.'/command_asxml.txt'), '->asXml() returns an XML representation of the command'); diff --git a/tests/unit/Symfony/Components/Console/Command/HelpCommandTest.php b/tests/unit/Symfony/Components/Console/Command/HelpCommandTest.php deleted file mode 100644 index 8951043ec9619..0000000000000 --- a/tests/unit/Symfony/Components/Console/Command/HelpCommandTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * 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\Console\Tester\CommandTester; -use Symfony\Components\Console\Command\HelpCommand; -use Symfony\Components\Console\Command\ListCommand; -use Symfony\Components\Console\Application; - -$t = new LimeTest(4); - -// ->execute() -$t->diag('->execute()'); - -$command = new HelpCommand(); -$command->setCommand(new ListCommand()); - -$commandTester = new CommandTester($command); -$commandTester->execute(array()); -$t->like($commandTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given command'); - -$commandTester->execute(array('--xml' => true)); -$t->like($commandTester->getDisplay(), '/execute() returns an XML help text if --xml is passed'); - -$application = new Application(); -$commandTester = new CommandTester($application->getCommand('help')); -$commandTester->execute(array('command_name' => 'list')); -$t->like($commandTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given command'); - -$commandTester->execute(array('command_name' => 'list', '--xml' => true)); -$t->like($commandTester->getDisplay(), '/execute() returns an XML help text if --xml is passed'); diff --git a/tests/unit/Symfony/Components/Console/Command/ListCommandTest.php b/tests/unit/Symfony/Components/Console/Command/ListCommandTest.php deleted file mode 100644 index 9ed10cc6f9509..0000000000000 --- a/tests/unit/Symfony/Components/Console/Command/ListCommandTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * 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\Console\Tester\CommandTester; -use Symfony\Components\Console\Application; - -$t = new LimeTest(2); - -$application = new Application(); - -// ->execute() -$t->diag('->execute()'); - -$commandTester = new CommandTester($application->getCommand('list')); -$commandTester->execute(array()); -$t->like($commandTester->getDisplay(), '/help Displays help for a command/', '->execute() returns a list of available commands'); - -$commandTester->execute(array('--xml' => true)); -$t->like($commandTester->getDisplay(), '//', '->execute() returns a list of available commands in XML if --xml is passed'); diff --git a/tests/unit/Symfony/Components/Console/Helper/FormatterHelperTest.php b/tests/unit/Symfony/Components/Console/Helper/FormatterHelperTest.php deleted file mode 100644 index 0fd2199b61564..0000000000000 --- a/tests/unit/Symfony/Components/Console/Helper/FormatterHelperTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * 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\Console\Helper\FormatterHelper; - -$formatter = new FormatterHelper(); - -$t = new LimeTest(4); - -// ::formatSection() -$t->diag('::formatSection()'); -$t->is($formatter->formatSection('cli', 'Some text to display'), '[cli] Some text to display', '::formatSection() formats a message in a section'); - -// ::formatBlock() -$t->diag('::formatBlock()'); -$t->is($formatter->formatBlock('Some text to display', 'error'), ' Some text to display ', '::formatBlock() formats a message in a block'); -$t->is($formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), " Some text to display \n foo bar ", '::formatBlock() formats a message in a block'); - -$t->is($formatter->formatBlock('Some text to display', 'error', true), " \n Some text to display \n ", '::formatBlock() formats a message in a block'); diff --git a/tests/unit/Symfony/Components/Console/Input/ArgvInputTest.php b/tests/unit/Symfony/Components/Console/Input/ArgvInputTest.php deleted file mode 100644 index ee9ebea055d70..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/ArgvInputTest.php +++ /dev/null @@ -1,174 +0,0 @@ - - * - * 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\Console\Input\ArgvInput; -use Symfony\Components\Console\Input\InputDefinition; -use Symfony\Components\Console\Input\InputArgument; -use Symfony\Components\Console\Input\InputOption; - -class TestInput extends ArgvInput -{ - public function getTokens() - { - return $this->tokens; - } -} - -$t = new LimeTest(26); - -// __construct() -$t->diag('__construct()'); -$_SERVER['argv'] = array('cli.php', 'foo'); -$input = new TestInput(); -$t->is($input->getTokens(), array('foo'), '__construct() automatically get its input from the argv server variable'); - -// ->parse() -$t->diag('->parse()'); -$input = new TestInput(array('cli.php', 'foo')); -$input->bind(new InputDefinition(array(new InputArgument('name')))); -$t->is($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments'); - -$input->bind(new InputDefinition(array(new InputArgument('name')))); -$t->is($input->getArguments(), array('name' => 'foo'), '->parse() is stateless'); - -$input = new TestInput(array('cli.php', '--foo')); -$input->bind(new InputDefinition(array(new InputOption('foo')))); -$t->is($input->getOptions(), array('foo' => true), '->parse() parses long options without parameter'); - -$input = new TestInput(array('cli.php', '--foo=bar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a = separator)'); - -$input = new TestInput(array('cli.php', '--foo', 'bar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a space separator)'); - -try -{ - $input = new TestInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $t->fail('->parse() throws a \RuntimeException if no parameter is passed to an option when it is required'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws a \RuntimeException if no parameter is passed to an option when it is required'); -} - -$input = new TestInput(array('cli.php', '-f')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f')))); -$t->is($input->getOptions(), array('foo' => true), '->parse() parses short options without parameter'); - -$input = new TestInput(array('cli.php', '-fbar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with no separator)'); - -$input = new TestInput(array('cli.php', '-f', 'bar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with a space separator)'); - -$input = new TestInput(array('cli.php', '-f', '-b', 'foo')); -$input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL), new InputOption('bar', 'b')))); -$t->is($input->getOptions(), array('foo' => null, 'bar' => true), '->parse() parses short options with an optional parameter which is not present'); - -try -{ - $input = new TestInput(array('cli.php', '-f')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $t->fail('->parse() throws a \RuntimeException if no parameter is passed to an option when it is required'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws a \RuntimeException if no parameter is passed to an option when it is required'); -} - -try -{ - $input = new TestInput(array('cli.php', '-ffoo')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_NONE)))); - $t->fail('->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); -} - -try -{ - $input = new TestInput(array('cli.php', 'foo', 'bar')); - $input->bind(new InputDefinition()); - $t->fail('->parse() throws a \RuntimeException if too many arguments are passed'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws a \RuntimeException if too many arguments are passed'); -} - -try -{ - $input = new TestInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition()); - $t->fail('->parse() throws a \RuntimeException if an unknown long option is passed'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws a \RuntimeException if an unknown long option is passed'); -} - -try -{ - $input = new TestInput(array('cli.php', '-f')); - $input->bind(new InputDefinition()); - $t->fail('->parse() throws a \RuntimeException if an unknown short option is passed'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws a \RuntimeException if an unknown short option is passed'); -} - -$input = new TestInput(array('cli.php', '-fb')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b')))); -$t->is($input->getOptions(), array('foo' => true, 'bar' => true), '->parse() parses short options when they are aggregated as a single one'); - -$input = new TestInput(array('cli.php', '-fb', 'bar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_REQUIRED)))); -$t->is($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has a required parameter'); - -$input = new TestInput(array('cli.php', '-fb', 'bar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); -$t->is($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter'); - -$input = new TestInput(array('cli.php', '-fbbar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); -$t->is($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter with no separator'); - -$input = new TestInput(array('cli.php', '-fbbar')); -$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); -$t->is($input->getOptions(), array('foo' => 'bbar', 'bar' => null), '->parse() parses short options when they are aggregated as a single one and one of them takes a parameter'); - -// ->getFirstArgument() -$t->diag('->getFirstArgument()'); -$input = new TestInput(array('cli.php', '-fbbar')); -$t->is($input->getFirstArgument(), '', '->getFirstArgument() returns the first argument from the raw input'); - -$input = new TestInput(array('cli.php', '-fbbar', 'foo')); -$t->is($input->getFirstArgument(), 'foo', '->getFirstArgument() returns the first argument from the raw input'); - -// ->hasParameterOption() -$t->diag('->hasParameterOption()'); -$input = new TestInput(array('cli.php', '-f', 'foo')); -$t->ok($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input'); - -$input = new TestInput(array('cli.php', '--foo', 'foo')); -$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input'); - -$input = new TestInput(array('cli.php', 'foo')); -$t->ok(!$input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input'); diff --git a/tests/unit/Symfony/Components/Console/Input/ArrayInputTest.php b/tests/unit/Symfony/Components/Console/Input/ArrayInputTest.php deleted file mode 100644 index 2d68a7c660333..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/ArrayInputTest.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * 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\Console\Input\ArrayInput; -use Symfony\Components\Console\Input\InputDefinition; -use Symfony\Components\Console\Input\InputArgument; -use Symfony\Components\Console\Input\InputOption; - -$t = new LimeTest(15); - -// ->getFirstArgument() -$t->diag('->getFirstArgument()'); -$input = new ArrayInput(array()); -$t->is($input->getFirstArgument(), null, '->getFirstArgument() returns null if no argument were passed'); -$input = new ArrayInput(array('name' => 'Fabien')); -$t->is($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument'); -$input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien')); -$t->is($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument'); - -// ->hasParameterOption() -$t->diag('->hasParameterOption()'); -$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar')); -$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); -$t->ok(!$input->hasParameterOption('--bar'), '->hasParameterOption() returns false if an option is not present in the passed parameters'); - -$input = new ArrayInput(array('--foo')); -$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); - -// ->parse() -$t->diag('->parse()'); -$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); -$t->is($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments'); - -try -{ - $input = new ArrayInput(array('foo' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $t->fail('->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); -} - -$input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo')))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options'); - -$input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL, '', 'default')))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a default value'); - -$input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL, '', 'default')))); -$t->is($input->getOptions(), array('foo' => 'default'), '->parse() parses long options with a default value'); - -try -{ - $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $t->fail('->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); -} - -try -{ - $input = new ArrayInput(array('--foo' => 'foo'), new InputDefinition()); - $t->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); -} - -$input = new ArrayInput(array('-f' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f')))); -$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options'); - -try -{ - $input = new ArrayInput(array('-o' => 'foo'), new InputDefinition()); - $t->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); -} -catch (\RuntimeException $e) -{ - $t->pass('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); -} diff --git a/tests/unit/Symfony/Components/Console/Input/InputArgumentTest.php b/tests/unit/Symfony/Components/Console/Input/InputArgumentTest.php deleted file mode 100644 index 07736e39b1a15..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/InputArgumentTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * 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\Console\Input\InputArgument; -use Symfony\Components\Console\Exception; - -$t = new LimeTest(16); - -// __construct() -$t->diag('__construct()'); -$argument = new InputArgument('foo'); -$t->is($argument->getName(), 'foo', '__construct() takes a name as its first argument'); - -// mode argument -$argument = new InputArgument('foo'); -$t->is($argument->isRequired(), false, '__construct() gives a "Argument::OPTIONAL" mode by default'); - -$argument = new InputArgument('foo', null); -$t->is($argument->isRequired(), false, '__construct() can take "Argument::OPTIONAL" as its mode'); - -$argument = new InputArgument('foo', InputArgument::OPTIONAL); -$t->is($argument->isRequired(), false, '__construct() can take "Argument::PARAMETER_OPTIONAL" as its mode'); - -$argument = new InputArgument('foo', InputArgument::REQUIRED); -$t->is($argument->isRequired(), true, '__construct() can take "Argument::PARAMETER_REQUIRED" as its mode'); - -try -{ - $argument = new InputArgument('foo', 'ANOTHER_ONE'); - $t->fail('__construct() throws an Exception if the mode is not valid'); -} -catch (\Exception $e) -{ - $t->pass('__construct() throws an Exception if the mode is not valid'); -} - -// ->isArray() -$t->diag('->isArray()'); -$argument = new InputArgument('foo', InputArgument::IS_ARRAY); -$t->ok($argument->isArray(), '->isArray() returns true if the argument can be an array'); -$argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); -$t->ok($argument->isArray(), '->isArray() returns true if the argument can be an array'); -$argument = new InputArgument('foo', InputArgument::OPTIONAL); -$t->ok(!$argument->isArray(), '->isArray() returns false if the argument can not be an array'); - -// ->getDescription() -$t->diag('->getDescription()'); -$argument = new InputArgument('foo', null, 'Some description'); -$t->is($argument->getDescription(), 'Some description', '->getDescription() return the message description'); - -// ->getDefault() -$t->diag('->getDefault()'); -$argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); -$t->is($argument->getDefault(), 'default', '->getDefault() return the default value'); - -// ->setDefault() -$t->diag('->setDefault()'); -$argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); -$argument->setDefault(null); -$t->ok(is_null($argument->getDefault()), '->setDefault() can reset the default value by passing null'); -$argument->setDefault('another'); -$t->is($argument->getDefault(), 'another', '->setDefault() changes the default value'); - -$argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); -$argument->setDefault(array(1, 2)); -$t->is($argument->getDefault(), array(1, 2), '->setDefault() changes the default value'); - -try -{ - $argument = new InputArgument('foo', InputArgument::REQUIRED); - $argument->setDefault('default'); - $t->fail('->setDefault() throws an Exception if you give a default value for a required argument'); -} -catch (\Exception $e) -{ - $t->pass('->setDefault() throws an Exception if you give a default value for a required argument'); -} - -try -{ - $argument = new InputArgument('foo', InputArgument::IS_ARRAY); - $argument->setDefault('default'); - $t->fail('->setDefault() throws an Exception if you give a default value which is not an array for a IS_ARRAY option'); -} -catch (\Exception $e) -{ - $t->pass('->setDefault() throws an Exception if you give a default value which is not an array for a IS_ARRAY option'); -} diff --git a/tests/unit/Symfony/Components/Console/Input/InputDefinitionTest.php b/tests/unit/Symfony/Components/Console/Input/InputDefinitionTest.php deleted file mode 100644 index 124ddfaa5d175..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/InputDefinitionTest.php +++ /dev/null @@ -1,305 +0,0 @@ - - * - * 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\Console\Input\InputDefinition; -use Symfony\Components\Console\Input\InputArgument; -use Symfony\Components\Console\Input\InputOption; -use Symfony\Components\Console\Exception; - -$fixtures = __DIR__.'/../../../../../fixtures/Symfony/Components/Console'; - -$t = new LimeTest(51); - -$foo = new InputArgument('foo'); -$bar = new InputArgument('bar'); -$foo1 = new InputArgument('foo'); -$foo2 = new InputArgument('foo2', InputArgument::REQUIRED); - -// __construct() -$t->diag('__construct()'); -$definition = new InputDefinition(); -$t->is($definition->getArguments(), array(), '__construct() creates a new InputDefinition object'); - -$definition = new InputDefinition(array($foo, $bar)); -$t->is($definition->getArguments(), array('foo' => $foo, 'bar' => $bar), '__construct() takes an array of InputArgument objects as its first argument'); - -// ->setArguments() -$t->diag('->setArguments()'); -$definition = new InputDefinition(); -$definition->setArguments(array($foo)); -$t->is($definition->getArguments(), array('foo' => $foo), '->setArguments() sets the array of InputArgument objects'); -$definition->setArguments(array($bar)); - -$t->is($definition->getArguments(), array('bar' => $bar), '->setArguments() clears all InputArgument objects'); - -// ->addArguments() -$t->diag('->addArguments()'); -$definition = new InputDefinition(); -$definition->addArguments(array($foo)); -$t->is($definition->getArguments(), array('foo' => $foo), '->addArguments() adds an array of InputArgument objects'); -$definition->addArguments(array($bar)); -$t->is($definition->getArguments(), array('foo' => $foo, 'bar' => $bar), '->addArguments() does not clear existing InputArgument objects'); - -// ->addArgument() -$t->diag('->addArgument()'); -$definition = new InputDefinition(); -$definition->addArgument($foo); -$t->is($definition->getArguments(), array('foo' => $foo), '->addArgument() adds a InputArgument object'); -$definition->addArgument($bar); -$t->is($definition->getArguments(), array('foo' => $foo, 'bar' => $bar), '->addArgument() adds a InputArgument object'); - -// arguments must have different names -try -{ - $definition->addArgument($foo1); - $t->fail('->addArgument() throws a Exception if another argument is already registered with the same name'); -} -catch (\Exception $e) -{ - $t->pass('->addArgument() throws a Exception if another argument is already registered with the same name'); -} - -// cannot add a parameter after an array parameter -$definition->addArgument(new InputArgument('fooarray', InputArgument::IS_ARRAY)); -try -{ - $definition->addArgument(new InputArgument('anotherbar')); - $t->fail('->addArgument() throws a Exception if there is an array parameter already registered'); -} -catch (\Exception $e) -{ - $t->pass('->addArgument() throws a Exception if there is an array parameter already registered'); -} - -// cannot add a required argument after an optional one -$definition = new InputDefinition(); -$definition->addArgument($foo); -try -{ - $definition->addArgument($foo2); - $t->fail('->addArgument() throws an exception if you try to add a required argument after an optional one'); -} -catch (\Exception $e) -{ - $t->pass('->addArgument() throws an exception if you try to add a required argument after an optional one'); -} - -// ->getArgument() -$t->diag('->getArgument()'); -$definition = new InputDefinition(); -$definition->addArguments(array($foo)); -$t->is($definition->getArgument('foo'), $foo, '->getArgument() returns a InputArgument by its name'); -try -{ - $definition->getArgument('bar'); - $t->fail('->getArgument() throws an exception if the InputArgument name does not exist'); -} -catch (\Exception $e) -{ - $t->pass('->getArgument() throws an exception if the InputArgument name does not exist'); -} - -// ->hasArgument() -$t->diag('->hasArgument()'); -$definition = new InputDefinition(); -$definition->addArguments(array($foo)); -$t->is($definition->hasArgument('foo'), true, '->hasArgument() returns true if a InputArgument exists for the given name'); -$t->is($definition->hasArgument('bar'), false, '->hasArgument() returns false if a InputArgument exists for the given name'); - -// ->getArgumentRequiredCount() -$t->diag('->getArgumentRequiredCount()'); -$definition = new InputDefinition(); -$definition->addArgument($foo2); -$t->is($definition->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); -$definition->addArgument($foo); -$t->is($definition->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); - -// ->getArgumentCount() -$t->diag('->getArgumentCount()'); -$definition = new InputDefinition(); -$definition->addArgument($foo2); -$t->is($definition->getArgumentCount(), 1, '->getArgumentCount() returns the number of arguments'); -$definition->addArgument($foo); -$t->is($definition->getArgumentCount(), 2, '->getArgumentCount() returns the number of arguments'); - -// ->getArgumentDefaults() -$t->diag('->getArgumentDefaults()'); -$definition = new InputDefinition(array( - new InputArgument('foo1', InputArgument::OPTIONAL), - new InputArgument('foo2', InputArgument::OPTIONAL, '', 'default'), - new InputArgument('foo3', InputArgument::OPTIONAL | InputArgument::IS_ARRAY), -// new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), -)); -$t->is($definition->getArgumentDefaults(), array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), '->getArgumentDefaults() return the default values for each argument'); - -$definition = new InputDefinition(array( - new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), -)); -$t->is($definition->getArgumentDefaults(), array('foo4' => array(1, 2)), '->getArgumentDefaults() return the default values for each argument'); - -$foo = new InputOption('foo', 'f'); -$bar = new InputOption('bar', 'b'); -$foo1 = new InputOption('fooBis', 'f'); -$foo2 = new InputOption('foo', 'p'); - -// __construct() -$t->diag('__construct()'); -$definition = new InputDefinition(); -$t->is($definition->getOptions(), array(), '__construct() creates a new InputDefinition object'); - -$definition = new InputDefinition(array($foo, $bar)); -$t->is($definition->getOptions(), array('foo' => $foo, 'bar' => $bar), '__construct() takes an array of InputOption objects as its first argument'); - -// ->setOptions() -$t->diag('->setOptions()'); -$definition = new InputDefinition(array($foo)); -$t->is($definition->getOptions(), array('foo' => $foo), '->setOptions() sets the array of InputOption objects'); -$definition->setOptions(array($bar)); -$t->is($definition->getOptions(), array('bar' => $bar), '->setOptions() clears all InputOption objects'); -try -{ - $definition->getOptionForShortcut('f'); - $t->fail('->setOptions() clears all InputOption objects'); -} -catch (\Exception $e) -{ - $t->pass('->setOptions() clears all InputOption objects'); -} - -// ->addOptions() -$t->diag('->addOptions()'); -$definition = new InputDefinition(array($foo)); -$t->is($definition->getOptions(), array('foo' => $foo), '->addOptions() adds an array of InputOption objects'); -$definition->addOptions(array($bar)); -$t->is($definition->getOptions(), array('foo' => $foo, 'bar' => $bar), '->addOptions() does not clear existing InputOption objects'); - -// ->addOption() -$t->diag('->addOption()'); -$definition = new InputDefinition(); -$definition->addOption($foo); -$t->is($definition->getOptions(), array('foo' => $foo), '->addOption() adds a InputOption object'); -$definition->addOption($bar); -$t->is($definition->getOptions(), array('foo' => $foo, 'bar' => $bar), '->addOption() adds a InputOption object'); -try -{ - $definition->addOption($foo2); - $t->fail('->addOption() throws a Exception if the another option is already registered with the same name'); -} -catch (\Exception $e) -{ - $t->pass('->addOption() throws a Exception if the another option is already registered with the same name'); -} -try -{ - $definition->addOption($foo1); - $t->fail('->addOption() throws a Exception if the another option is already registered with the same shortcut'); -} -catch (\Exception $e) -{ - $t->pass('->addOption() throws a Exception if the another option is already registered with the same shortcut'); -} - -// ->getOption() -$t->diag('->getOption()'); -$definition = new InputDefinition(array($foo)); -$t->is($definition->getOption('foo'), $foo, '->getOption() returns a InputOption by its name'); -try -{ - $definition->getOption('bar'); - $t->fail('->getOption() throws an exception if the option name does not exist'); -} -catch (\Exception $e) -{ - $t->pass('->getOption() throws an exception if the option name does not exist'); -} - -// ->hasOption() -$t->diag('->hasOption()'); -$definition = new InputDefinition(array($foo)); -$t->is($definition->hasOption('foo'), true, '->hasOption() returns true if a InputOption exists for the given name'); -$t->is($definition->hasOption('bar'), false, '->hasOption() returns false if a InputOption exists for the given name'); - -// ->hasShortcut() -$t->diag('->hasShortcut()'); -$definition = new InputDefinition(array($foo)); -$t->is($definition->hasShortcut('f'), true, '->hasShortcut() returns true if a InputOption exists for the given shortcut'); -$t->is($definition->hasShortcut('b'), false, '->hasShortcut() returns false if a InputOption exists for the given shortcut'); - -// ->getOptionForShortcut() -$t->diag('->getOptionForShortcut()'); -$definition = new InputDefinition(array($foo)); -$t->is($definition->getOptionForShortcut('f'), $foo, '->getOptionForShortcut() returns a InputOption by its shortcut'); -try -{ - $definition->getOptionForShortcut('l'); - $t->fail('->getOption() throws an exception if the shortcut does not exist'); -} -catch (\Exception $e) -{ - $t->pass('->getOption() throws an exception if the shortcut does not exist'); -} - -// ->getOptionDefaults() -$t->diag('->getOptionDefaults()'); -$definition = new InputDefinition(array( - new InputOption('foo1', null, InputOption::PARAMETER_NONE), - new InputOption('foo2', null, InputOption::PARAMETER_REQUIRED), - new InputOption('foo3', null, InputOption::PARAMETER_REQUIRED, '', 'default'), - new InputOption('foo4', null, InputOption::PARAMETER_OPTIONAL), - new InputOption('foo5', null, InputOption::PARAMETER_OPTIONAL, '', 'default'), - new InputOption('foo6', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY), - new InputOption('foo7', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY, '', array(1, 2)), -)); -$defaults = array( - 'foo1' => null, - 'foo2' => null, - 'foo3' => 'default', - 'foo4' => null, - 'foo5' => 'default', - 'foo6' => array(), - 'foo7' => array(1, 2), -); -$t->is($definition->getOptionDefaults(), $defaults, '->getOptionDefaults() returns the default values for all options'); - -// ->getSynopsis() -$t->diag('->getSynopsis()'); -$definition = new InputDefinition(array(new InputOption('foo'))); -$t->is($definition->getSynopsis(), '[--foo]', '->getSynopsis() returns a synopsis of arguments and options'); -$definition = new InputDefinition(array(new InputOption('foo', 'f'))); -$t->is($definition->getSynopsis(), '[-f|--foo]', '->getSynopsis() returns a synopsis of arguments and options'); -$definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED))); -$t->is($definition->getSynopsis(), '[-f|--foo="..."]', '->getSynopsis() returns a synopsis of arguments and options'); -$definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL))); -$t->is($definition->getSynopsis(), '[-f|--foo[="..."]]', '->getSynopsis() returns a synopsis of arguments and options'); - -$definition = new InputDefinition(array(new InputArgument('foo'))); -$t->is($definition->getSynopsis(), '[foo]', '->getSynopsis() returns a synopsis of arguments and options'); -$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))); -$t->is($definition->getSynopsis(), 'foo', '->getSynopsis() returns a synopsis of arguments and options'); -$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))); -$t->is($definition->getSynopsis(), '[foo1] ... [fooN]', '->getSynopsis() returns a synopsis of arguments and options'); -$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))); -$t->is($definition->getSynopsis(), 'foo1 ... [fooN]', '->getSynopsis() returns a synopsis of arguments and options'); - -// ->asText() -$t->diag('->asText()'); -$definition = new InputDefinition(array( - new InputArgument('foo', InputArgument::OPTIONAL, 'The bar argument'), - new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The foo argument', array('bar')), - new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED, 'The foo option'), - new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL, 'The foo option', 'bar'), -)); -$t->is($definition->asText(), file_get_contents($fixtures.'/definition_astext.txt'), '->asText() returns a textual representation of the InputDefinition'); - -// ->asXml() -$t->diag('->asXml()'); -$t->is($definition->asXml(), file_get_contents($fixtures.'/definition_asxml.txt'), '->asText() returns a textual representation of the InputDefinition'); diff --git a/tests/unit/Symfony/Components/Console/Input/InputOptionTest.php b/tests/unit/Symfony/Components/Console/Input/InputOptionTest.php deleted file mode 100644 index 85509c672da1c..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/InputOptionTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * 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\Console\Input\InputOption; -use Symfony\Components\Console\Exception; - -$t = new LimeTest(34); - -// __construct() -$t->diag('__construct()'); -$option = new InputOption('foo'); -$t->is($option->getName(), 'foo', '__construct() takes a name as its first argument'); -$option = new InputOption('--foo'); -$t->is($option->getName(), 'foo', '__construct() removes the leading -- of the option name'); - -try -{ - $option = new InputOption('foo', 'f', InputOption::PARAMETER_IS_ARRAY); - $t->fail('->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value'); -} -catch (\Exception $e) -{ - $t->pass('->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value'); -} - -// shortcut argument -$option = new InputOption('foo', 'f'); -$t->is($option->getShortcut(), 'f', '__construct() can take a shortcut as its second argument'); -$option = new InputOption('foo', '-f'); -$t->is($option->getShortcut(), 'f', '__construct() removes the leading - of the shortcut'); - -// mode argument -$option = new InputOption('foo', 'f'); -$t->is($option->acceptParameter(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); -$t->is($option->isParameterRequired(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); -$t->is($option->isParameterOptional(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); - -$option = new InputOption('foo', 'f', null); -$t->is($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); -$t->is($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); -$t->is($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); - -$option = new InputOption('foo', 'f', InputOption::PARAMETER_NONE); -$t->is($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); -$t->is($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); -$t->is($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); - -$option = new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED); -$t->is($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); -$t->is($option->isParameterRequired(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); -$t->is($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); - -$option = new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL); -$t->is($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); -$t->is($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); -$t->is($option->isParameterOptional(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); - -try -{ - $option = new InputOption('foo', 'f', 'ANOTHER_ONE'); - $t->fail('__construct() throws an Exception if the mode is not valid'); -} -catch (\Exception $e) -{ - $t->pass('__construct() throws an Exception if the mode is not valid'); -} - -// ->isArray() -$t->diag('->isArray()'); -$option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); -$t->ok($option->isArray(), '->isArray() returns true if the option can be an array'); -$option = new InputOption('foo', null, InputOption::PARAMETER_NONE); -$t->ok(!$option->isArray(), '->isArray() returns false if the option can not be an array'); - -// ->getDescription() -$t->diag('->getDescription()'); -$option = new InputOption('foo', 'f', null, 'Some description'); -$t->is($option->getDescription(), 'Some description', '->getDescription() returns the description message'); - -// ->getDefault() -$t->diag('->getDefault()'); -$option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL, '', 'default'); -$t->is($option->getDefault(), 'default', '->getDefault() returns the default value'); - -$option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED, '', 'default'); -$t->is($option->getDefault(), 'default', '->getDefault() returns the default value'); - -$option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED); -$t->ok(is_null($option->getDefault()), '->getDefault() returns null if no default value is configured'); - -$option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); -$t->is($option->getDefault(), array(), '->getDefault() returns an empty array if option is an array'); - -$option = new InputOption('foo', null, InputOption::PARAMETER_NONE); -$t->ok($option->getDefault() === false, '->getDefault() returns false if the option does not take a parameter'); - -// ->setDefault() -$t->diag('->setDefault()'); -$option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED, '', 'default'); -$option->setDefault(null); -$t->ok(is_null($option->getDefault()), '->setDefault() can reset the default value by passing null'); -$option->setDefault('another'); -$t->is($option->getDefault(), 'another', '->setDefault() changes the default value'); - -$option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED | InputOption::PARAMETER_IS_ARRAY); -$option->setDefault(array(1, 2)); -$t->is($option->getDefault(), array(1, 2), '->setDefault() changes the default value'); - -$option = new InputOption('foo', 'f', InputOption::PARAMETER_NONE); -try -{ - $option->setDefault('default'); - $t->fail('->setDefault() throws an Exception if you give a default value for a PARAMETER_NONE option'); -} -catch (\Exception $e) -{ - $t->pass('->setDefault() throws an Exception if you give a default value for a PARAMETER_NONE option'); -} - -$option = new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); -try -{ - $option->setDefault('default'); - $t->fail('->setDefault() throws an Exception if you give a default value which is not an array for a PARAMETER_IS_ARRAY option'); -} -catch (\Exception $e) -{ - $t->pass('->setDefault() throws an Exception if you give a default value which is not an array for a PARAMETER_IS_ARRAY option'); -} diff --git a/tests/unit/Symfony/Components/Console/Input/InputTest.php b/tests/unit/Symfony/Components/Console/Input/InputTest.php deleted file mode 100644 index cb175feceb888..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/InputTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * 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\Console\Input\ArrayInput; -use Symfony\Components\Console\Input\InputDefinition; -use Symfony\Components\Console\Input\InputArgument; -use Symfony\Components\Console\Input\InputOption; - -$t = new LimeTest(19); - -// __construct() -$t->diag('__construct()'); -$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); -$t->is($input->getArgument('name'), 'foo', '->__construct() takes a InputDefinition as an argument'); - -// ->getOption() ->setOption() ->getOptions() -$t->diag('->getOption() ->setOption() ->getOptions()'); -$input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name')))); -$t->is($input->getOption('name'), 'foo', '->getOption() returns the value for the given option'); - -$input->setOption('name', 'bar'); -$t->is($input->getOption('name'), 'bar', '->setOption() sets the value for a given option'); -$t->is($input->getOptions(), array('name' => 'bar'), '->getOptions() returns all option values'); - -$input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::PARAMETER_OPTIONAL, '', 'default')))); -$t->is($input->getOption('bar'), 'default', '->getOption() returns the default value for optional options'); -$t->is($input->getOptions(), array('name' => 'foo', 'bar' => 'default'), '->getOptions() returns all option values, even optional ones'); - -try -{ - $input->setOption('foo', 'bar'); - $t->fail('->setOption() throws a \InvalidArgumentException if the option does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->setOption() throws a \InvalidArgumentException if the option does not exist'); -} - -try -{ - $input->getOption('foo'); - $t->fail('->getOption() throws a \InvalidArgumentException if the option does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getOption() throws a \InvalidArgumentException if the option does not exist'); -} - -// ->getArgument() ->setArgument() ->getArguments() -$t->diag('->getArgument() ->setArgument() ->getArguments()'); -$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); -$t->is($input->getArgument('name'), 'foo', '->getArgument() returns the value for the given argument'); - -$input->setArgument('name', 'bar'); -$t->is($input->getArgument('name'), 'bar', '->setArgument() sets the value for a given argument'); -$t->is($input->getArguments(), array('name' => 'bar'), '->getArguments() returns all argument values'); - -$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); -$t->is($input->getArgument('bar'), 'default', '->getArgument() returns the default value for optional arguments'); -$t->is($input->getArguments(), array('name' => 'foo', 'bar' => 'default'), '->getArguments() returns all argument values, even optional ones'); - -try -{ - $input->setArgument('foo', 'bar'); - $t->fail('->setArgument() throws a \InvalidArgumentException if the argument does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->setArgument() throws a \InvalidArgumentException if the argument does not exist'); -} - -try -{ - $input->getArgument('foo'); - $t->fail('->getArgument() throws a \InvalidArgumentException if the argument does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getArgument() throws a \InvalidArgumentException if the argument does not exist'); -} - -// ->validate() -$t->diag('->validate()'); -$input = new ArrayInput(array()); -$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); - -try -{ - $input->validate(); - $t->fail('->validate() throws a \RuntimeException if not enough arguments are given'); -} -catch (\RuntimeException $e) -{ - $t->pass('->validate() throws a \RuntimeException if not enough arguments are given'); -} - -$input = new ArrayInput(array('name' => 'foo')); -$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); - -try -{ - $input->validate(); - $t->pass('->validate() does not throw a \RuntimeException if enough arguments are given'); -} -catch (\RuntimeException $e) -{ - $t->fail('->validate() does not throw a \RuntimeException if enough arguments are given'); -} - -// ->setInteractive() ->isInteractive() -$t->diag('->setInteractive() ->isInteractive()'); -$input = new ArrayInput(array()); -$t->ok($input->isInteractive(), '->isInteractive() returns whether the input should be interactive or not'); -$input->setInteractive(false); -$t->ok(!$input->isInteractive(), '->setInteractive() changes the interactive flag'); diff --git a/tests/unit/Symfony/Components/Console/Input/StringInputTest.php b/tests/unit/Symfony/Components/Console/Input/StringInputTest.php deleted file mode 100644 index d5bf981c1394e..0000000000000 --- a/tests/unit/Symfony/Components/Console/Input/StringInputTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * 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\Console\Input\StringInput; - -class TestInput extends StringInput -{ - public function getTokens() - { - return $this->tokens; - } -} - -$t = new LimeTest(23); - -// ->tokenize() -$t->diag('->tokenize()'); -$input = new TestInput(''); -$t->is($input->getTokens(), array(), '->tokenize() parses an empty string'); - -$input = new TestInput('foo'); -$t->is($input->getTokens(), array('foo'), '->tokenize() parses arguments'); - -$input = new TestInput(' foo bar '); -$t->is($input->getTokens(), array('foo', 'bar'), '->tokenize() ignores whitespaces between arguments'); - -$input = new TestInput('"quoted"'); -$t->is($input->getTokens(), array('quoted'), '->tokenize() parses quoted arguments'); - -$input = new TestInput("'quoted'"); -$t->is($input->getTokens(), array('quoted'), '->tokenize() parses quoted arguments'); - -$input = new TestInput('\"quoted\"'); -$t->is($input->getTokens(), array('"quoted"'), '->tokenize() parses escaped-quoted arguments'); - -$input = new TestInput("\'quoted\'"); -$t->is($input->getTokens(), array('\'quoted\''), '->tokenize() parses escaped-quoted arguments'); - -$input = new TestInput('-a'); -$t->is($input->getTokens(), array('-a'), '->tokenize() parses short options'); - -$input = new TestInput('-azc'); -$t->is($input->getTokens(), array('-azc'), '->tokenize() parses aggregated short options'); - -$input = new TestInput('-awithavalue'); -$t->is($input->getTokens(), array('-awithavalue'), '->tokenize() parses short options with a value'); - -$input = new TestInput('-a"foo bar"'); -$t->is($input->getTokens(), array('-afoo bar'), '->tokenize() parses short options with a value'); - -$input = new TestInput('-a"foo bar""foo bar"'); -$t->is($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); - -$input = new TestInput('-a\'foo bar\''); -$t->is($input->getTokens(), array('-afoo bar'), '->tokenize() parses short options with a value'); - -$input = new TestInput('-a\'foo bar\'\'foo bar\''); -$t->is($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); - -$input = new TestInput('-a\'foo bar\'"foo bar"'); -$t->is($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); - -$input = new TestInput('--long-option'); -$t->is($input->getTokens(), array('--long-option'), '->tokenize() parses long options'); - -$input = new TestInput('--long-option=foo'); -$t->is($input->getTokens(), array('--long-option=foo'), '->tokenize() parses long options with a value'); - -$input = new TestInput('--long-option="foo bar"'); -$t->is($input->getTokens(), array('--long-option=foo bar'), '->tokenize() parses long options with a value'); - -$input = new TestInput('--long-option="foo bar""another"'); -$t->is($input->getTokens(), array('--long-option=foo baranother'), '->tokenize() parses long options with a value'); - -$input = new TestInput('--long-option=\'foo bar\''); -$t->is($input->getTokens(), array('--long-option=foo bar'), '->tokenize() parses long options with a value'); - -$input = new TestInput("--long-option='foo bar''another'"); -$t->is($input->getTokens(), array("--long-option=foo baranother"), '->tokenize() parses long options with a value'); - -$input = new TestInput("--long-option='foo bar'\"another\""); -$t->is($input->getTokens(), array("--long-option=foo baranother"), '->tokenize() parses long options with a value'); - -$input = new TestInput('foo -a -ffoo --long bar'); -$t->is($input->getTokens(), array('foo', '-a', '-ffoo', '--long', 'bar'), '->tokenize() parses when several arguments and options'); diff --git a/tests/unit/Symfony/Components/Console/Output/ConsoleOutputTest.php b/tests/unit/Symfony/Components/Console/Output/ConsoleOutputTest.php deleted file mode 100644 index 2c61dde74522a..0000000000000 --- a/tests/unit/Symfony/Components/Console/Output/ConsoleOutputTest.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * 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\Console\Output\ConsoleOutput; -use Symfony\Components\Console\Output\Output; - -$t = new LimeTest(1); - -// __construct() -$t->diag('__construct()'); -$output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); -$t->is($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); diff --git a/tests/unit/Symfony/Components/Console/Output/OutputTest.php b/tests/unit/Symfony/Components/Console/Output/OutputTest.php deleted file mode 100644 index 03bed431b7b6e..0000000000000 --- a/tests/unit/Symfony/Components/Console/Output/OutputTest.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * 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\Console\Output\Output; - -$t = new LimeTest(13); - -class TestOutput extends Output -{ - public $output = ''; - - static public function getStyle($name) - { - return static::$styles[$name]; - } - - public function doWrite($message, $newline) - { - $this->output .= $message.($newline ? "\n" : ''); - } -} - -// __construct() -$t->diag('__construct()'); -$output = new TestOutput(Output::VERBOSITY_QUIET, true); -$t->is($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); -$t->is($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument'); - -// ->setDecorated() ->isDecorated() -$t->diag('->setDecorated() ->isDecorated()'); -$output = new TestOutput(); -$output->setDecorated(true); -$t->is($output->isDecorated(), true, 'setDecorated() sets the decorated flag'); - -// ->setVerbosity() ->getVerbosity() -$t->diag('->setVerbosity() ->getVerbosity()'); -$output->setVerbosity(Output::VERBOSITY_QUIET); -$t->is($output->getVerbosity(), Output::VERBOSITY_QUIET, '->setVerbosity() sets the verbosity'); - -// ::setStyle() -$t->diag('::setStyle()'); -Output::setStyle('FOO', array('bg' => 'red', 'fg' => 'yellow', 'blink' => true)); -$t->is(TestOutput::getStyle('foo'), array('bg' => 'red', 'fg' => 'yellow', 'blink' => true), '::setStyle() sets a new style'); - -// ->writeln() -$t->diag('->writeln()'); -$output = new TestOutput(Output::VERBOSITY_QUIET); -$output->writeln('foo'); -$t->is($output->output, '', '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); - -$output = new TestOutput(); -$output->writeln(array('foo', 'bar')); -$t->is($output->output, "foo\nbar\n", '->writeln() can take an array of messages to output'); - -$output = new TestOutput(); -$output->writeln('foo', Output::OUTPUT_RAW); -$t->is($output->output, "foo\n", '->writeln() outputs the raw message if OUTPUT_RAW is specified'); - -$output = new TestOutput(); -$output->writeln('foo', Output::OUTPUT_PLAIN); -$t->is($output->output, "foo\n", '->writeln() strips decoration tags if OUTPUT_PLAIN is specified'); - -$output = new TestOutput(); -$output->setDecorated(false); -$output->writeln('foo'); -$t->is($output->output, "foo\n", '->writeln() strips decoration tags if decoration is set to false'); - -$output = new TestOutput(); -$output->setDecorated(true); -$output->writeln('foo'); -$t->is($output->output, "\033[33;41;5mfoo\033[0m\n", '->writeln() decorates the output'); - -try -{ - $output->writeln('foo', 24); - $t->fail('->writeln() throws an \InvalidArgumentException when the type does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->writeln() throws an \InvalidArgumentException when the type does not exist'); -} - -try -{ - $output->writeln('foo'); - $t->fail('->writeln() throws an \InvalidArgumentException when a style does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->writeln() throws an \InvalidArgumentException when a style does not exist'); -} diff --git a/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php b/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php deleted file mode 100644 index e8db804a205c3..0000000000000 --- a/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\Console\Output\Output; -use Symfony\Components\Console\Output\StreamOutput; - -$t = new LimeTest(5); - -$stream = fopen('php://memory', 'a', false); - -// __construct() -$t->diag('__construct()'); - -try -{ - $output = new StreamOutput('foo'); - $t->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('__construct() throws an \InvalidArgumentException if the first argument is not a stream'); -} - -$output = new StreamOutput($stream, Output::VERBOSITY_QUIET, true); -$t->is($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); -$t->is($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument'); - -// ->getStream() -$t->diag('->getStream()'); -$output = new StreamOutput($stream); -$t->is($output->getStream(), $stream, '->getStream() returns the current stream'); - -// ->doWrite() -$t->diag('->doWrite()'); -$output = new StreamOutput($stream); -$output->writeln('foo'); -rewind($output->getStream()); -$t->is(stream_get_contents($output->getStream()), "foo\n", '->doWrite() writes to the stream'); diff --git a/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php b/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php deleted file mode 100644 index d2cdb4883fb79..0000000000000 --- a/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\Console\Application; -use Symfony\Components\Console\Output\Output; -use Symfony\Components\Console\Tester\ApplicationTester; - -$t = new LimeTest(6); - -$application = new Application(); -$application->setAutoExit(false); -$application->register('foo') - ->addArgument('command') - ->addArgument('foo') - ->setCode(function ($input, $output) { $output->writeln('foo'); }) -; - -$tester = new ApplicationTester($application); -$tester->run(array('command' => 'foo', 'foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); - -// ->run() -$t->diag('->run()'); -$t->is($tester->getInput()->isInteractive(), false, '->execute() takes an interactive option'); -$t->is($tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option'); -$t->is($tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option'); - -// ->getInput() -$t->diag('->getInput()'); -$t->is($tester->getInput()->getArgument('foo'), 'bar', '->getInput() returns the current input instance'); - -// ->getOutput() -$t->diag('->getOutput()'); -rewind($tester->getOutput()->getStream()); -$t->is(stream_get_contents($tester->getOutput()->getStream()), "foo\n", '->getOutput() returns the current output instance'); - -// ->getDisplay() -$t->diag('->getDisplay()'); -$t->is($tester->getDisplay(), "foo\n", '->getDisplay() returns the display of the last execution'); diff --git a/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php b/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php deleted file mode 100644 index aa48b8336699d..0000000000000 --- a/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * 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\Console\Command\Command; -use Symfony\Components\Console\Output\Output; -use Symfony\Components\Console\Tester\CommandTester; - -$t = new LimeTest(6); - -$command = new Command('foo'); -$command->addArgument('command'); -$command->addArgument('foo'); -$command->setCode(function ($input, $output) { $output->writeln('foo'); }); - -$tester = new CommandTester($command); -$tester->execute(array('foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); - -// ->execute() -$t->diag('->execute()'); -$t->is($tester->getInput()->isInteractive(), false, '->execute() takes an interactive option'); -$t->is($tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option'); -$t->is($tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option'); - -// ->getInput() -$t->diag('->getInput()'); -$t->is($tester->getInput()->getArgument('foo'), 'bar', '->getInput() returns the current input instance'); - -// ->getOutput() -$t->diag('->getOutput()'); -rewind($tester->getOutput()->getStream()); -$t->is(stream_get_contents($tester->getOutput()->getStream()), "foo\n", '->getOutput() returns the current output instance'); - -// ->getDisplay() -$t->diag('->getDisplay()'); -$t->is($tester->getDisplay(), "foo\n", '->getDisplay() returns the display of the last execution'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/BuilderConfigurationTest.php b/tests/unit/Symfony/Components/DependencyInjection/BuilderConfigurationTest.php deleted file mode 100644 index 414b7cdbfdbfc..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/BuilderConfigurationTest.php +++ /dev/null @@ -1,192 +0,0 @@ - - * - * 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\BuilderConfiguration; -use Symfony\Components\DependencyInjection\Definition; -use Symfony\Components\DependencyInjection\Reference; -use Symfony\Components\DependencyInjection\FileResource; - -$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')); -$config = new BuilderConfiguration(array(), array('foo' => 'bar')); -$configuration->merge($config); -$t->is($configuration->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() overrides existing parameters'); - -$configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'), 'bar' => new Definition('BarClass'))); -$config = new BuilderConfiguration(array('baz' => new Definition('BazClass'))); -$config->setAlias('alias_for_foo', 'foo'); -$configuration->merge($config); -$t->is(array_keys($configuration->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones'); -$t->is($configuration->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases'); - -$configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'))); -$config->setDefinition('foo', new Definition('BazClass')); -$configuration->merge($config); -$t->is($configuration->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services'); - -$configuration = new BuilderConfiguration(); -$configuration->addResource($a = new FileResource('foo.xml')); -$config = new BuilderConfiguration(); -$config->addResource($b = new FileResource('foo.yml')); -$configuration->merge($config); -$t->is($configuration->getResources(), array($a, $b), '->merge() merges resources'); - -// ->setParameters() ->getParameters() -$t->diag('->setParameters() ->getParameters()'); - -$configuration = new BuilderConfiguration(); -$t->is($configuration->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined'); - -$configuration->setParameters(array('foo' => 'bar')); -$t->is($configuration->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters'); - -$configuration->setParameters(array('bar' => 'foo')); -$t->is($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters'); - -$configuration->setParameters(array('Bar' => 'foo')); -$t->is($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase'); - -// ->setParameter() ->getParameter() -$t->diag('->setParameter() ->getParameter() '); - -$configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); -$configuration->setParameter('bar', 'foo'); -$t->is($configuration->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter'); - -$configuration->setParameter('foo', 'baz'); -$t->is($configuration->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter'); - -$configuration->setParameter('Foo', 'baz1'); -$t->is($configuration->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase'); -$t->is($configuration->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); - -try -{ - $configuration->getParameter('baba'); - $t->fail('->getParameter() throws an \InvalidArgumentException if the key does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getParameter() throws an \InvalidArgumentException if the key does not exist'); -} - -// ->hasParameter() -$t->diag('->hasParameter()'); -$configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); -$t->ok($configuration->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); -$t->ok($configuration->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); -$t->ok(!$configuration->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); - -// ->addParameters() -$t->diag('->addParameters()'); -$configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); -$configuration->addParameters(array('bar' => 'foo')); -$t->is($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); -$configuration->addParameters(array('Bar' => 'fooz')); -$t->is($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); - -// ->setAlias() ->getAlias() ->hasAlias() ->getAliases() ->addAliases() -$t->diag('->setAlias() ->getAlias() ->hasAlias()'); -$configuration = new BuilderConfiguration(); -$configuration->setAlias('bar', 'foo'); -$t->is($configuration->getAlias('bar'), 'foo', '->setAlias() defines a new alias'); -$t->ok($configuration->hasAlias('bar'), '->hasAlias() returns true if the alias is defined'); -$t->ok(!$configuration->hasAlias('baba'), '->hasAlias() returns false if the alias is not defined'); - -try -{ - $configuration->getAlias('baba'); - $t->fail('->getAlias() throws an \InvalidArgumentException if the alias does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getAlias() throws an \InvalidArgumentException if the alias does not exist'); -} - -$configuration->setAlias('barbar', 'foofoo'); -$t->is($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo'), '->getAliases() returns an array of all defined aliases'); - -$configuration->addAliases(array('foo' => 'bar')); -$t->is($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo', 'foo' => 'bar'), '->addAliases() adds some aliases'); - -// ->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition() -$t->diag('->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition()'); -$configuration = new BuilderConfiguration(); -$definitions = array( - 'foo' => new Definition('FooClass'), - 'bar' => new Definition('BarClass'), -); -$configuration->setDefinitions($definitions); -$t->is($configuration->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions'); -$t->ok($configuration->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists'); -$t->ok(!$configuration->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist'); - -$configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')); -$t->is($configuration->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined'); -$t->ok($configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); - -$configuration->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); -$t->is($configuration->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions'); - -try -{ - $configuration->getDefinition('baz'); - $t->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); -} - -// ->findDefinition() -$t->diag('->findDefinition()'); -$configuration = new BuilderConfiguration(array('foo' => $definition = new Definition('FooClass'))); -$configuration->setAlias('bar', 'foo'); -$configuration->setAlias('foobar', 'bar'); -$t->is($configuration->findDefinition('foobar'), $definition, '->findDefinition() returns a Definition'); - -// ->addResource() ->getResources() -$t->diag('->addResource() ->getResources()'); -$configuration = new BuilderConfiguration(); -$configuration->addResource($a = new FileResource('foo.xml')); -$configuration->addResource($b = new FileResource('foo.yml')); -$t->is($configuration->getResources(), array($a, $b), '->getResources() returns an array of resources read for the current configuration'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/BuilderTest.php b/tests/unit/Symfony/Components/DependencyInjection/BuilderTest.php deleted file mode 100644 index 216082f2a0565..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/BuilderTest.php +++ /dev/null @@ -1,309 +0,0 @@ - - * - * 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\BuilderConfiguration; -use Symfony\Components\DependencyInjection\Definition; -use Symfony\Components\DependencyInjection\Reference; - -$fixturesPath = __DIR__.'/../../../../fixtures/Symfony/Components/DependencyInjection/'; - -$t = new LimeTest(61); - -// ->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition() -$t->diag('->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition()'); -$builder = new Builder(); -$definitions = array( - 'foo' => new Definition('FooClass'), - 'bar' => new Definition('BarClass'), -); -$builder->setDefinitions($definitions); -$t->is($builder->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions'); -$t->ok($builder->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists'); -$t->ok(!$builder->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist'); - -$builder->setDefinition('foobar', $foo = new Definition('FooBarClass')); -$t->is($builder->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined'); -$t->ok($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); - -$builder->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); -$t->is($builder->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions'); - -try -{ - $builder->getDefinition('baz'); - $t->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); -} - -// ->register() -$t->diag('->register()'); -$builder = new Builder(); -$builder->register('foo', 'FooClass'); -$t->ok($builder->hasDefinition('foo'), '->register() registers a new service definition'); -$t->ok($builder->getDefinition('foo') instanceof Definition, '->register() returns the newly created Definition instance'); - -// ->hasService() -$t->diag('->hasService()'); -$builder = new Builder(); -$t->ok(!$builder->hasService('foo'), '->hasService() returns false if the service does not exist'); -$builder->register('foo', 'FooClass'); -$t->ok($builder->hasService('foo'), '->hasService() returns true if a service definition exists'); -$builder->bar = new stdClass(); -$t->ok($builder->hasService('bar'), '->hasService() returns true if a service exists'); - -// ->getService() -$t->diag('->getService()'); -$builder = new Builder(); -try -{ - $builder->getService('foo'); - $t->fail('->getService() throws an InvalidArgumentException if the service does not exist'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->getService() throws an InvalidArgumentException if the service does not exist'); -} -$builder->register('foo', 'stdClass'); -$t->ok(is_object($builder->getService('foo')), '->getService() returns the service definition associated with the id'); -$builder->bar = $bar = new stdClass(); -$t->is($builder->getService('bar'), $bar, '->getService() returns the service associated with the id'); -$builder->register('bar', 'stdClass'); -$t->is($builder->getService('bar'), $bar, '->getService() returns the service associated with the id even if a definition has been defined'); - -$builder->register('baz', 'stdClass')->setArguments(array(new Reference('baz'))); -try -{ - @$builder->getService('baz'); - $t->fail('->getService() throws a LogicException if the service has a circular reference to itself'); -} -catch (\LogicException $e) -{ - $t->pass('->getService() throws a LogicException if the service has a circular reference to itself'); -} - -$builder->register('foobar', 'stdClass')->setShared(true); -$t->ok($builder->getService('bar') === $builder->getService('bar'), '->getService() always returns the same instance if the service is shared'); - -// ->getServiceIds() -$t->diag('->getServiceIds()'); -$builder = new Builder(); -$builder->register('foo', 'stdClass'); -$builder->bar = $bar = new stdClass(); -$builder->register('bar', 'stdClass'); -$t->is($builder->getServiceIds(), array('foo', 'bar', 'service_container'), '->getServiceIds() returns all defined service ids'); - -// ->setAlias() ->getAlias() ->hasAlias() -$t->diag('->setAlias() ->getAlias() ->hasAlias()'); -$builder = new Builder(); -$builder->register('foo', 'stdClass'); -$builder->setAlias('bar', 'foo'); -$t->ok($builder->hasAlias('bar'), '->hasAlias() returns true if the alias exists'); -$t->ok(!$builder->hasAlias('foobar'), '->hasAlias() returns false if the alias does not exist'); -$t->is($builder->getAlias('bar'), 'foo', '->getAlias() returns the aliased service'); -$t->ok($builder->hasService('bar'), '->setAlias() defines a new service'); -$t->ok($builder->getService('bar') === $builder->getService('foo'), '->setAlias() creates a service that is an alias to another one'); - -try -{ - $builder->getAlias('foobar'); - $t->fail('->getAlias() throws an InvalidArgumentException if the alias does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getAlias() throws an InvalidArgumentException if the alias does not exist'); -} - -// ->getAliases() -$t->diag('->getAliases()'); -$builder = new Builder(); -$builder->setAlias('bar', 'foo'); -$builder->setAlias('foobar', 'foo'); -$t->is($builder->getAliases(), array('bar' => 'foo', 'foobar' => 'foo'), '->getAliases() returns all service aliases'); -$builder->register('bar', 'stdClass'); -$t->is($builder->getAliases(), array('foobar' => 'foo'), '->getAliases() does not return aliased services that have been overridden'); -$builder->setService('foobar', 'stdClass'); -$t->is($builder->getAliases(), array(), '->getAliases() does not return aliased services that have been overridden'); - -// ->createService() # file -$t->diag('->createService() # file'); -$builder = new Builder(); -$builder->register('foo1', 'FooClass')->setFile($fixturesPath.'/includes/foo.php'); -$t->ok($builder->getService('foo1'), '->createService() requires the file defined by the service definition'); -$builder->register('foo2', 'FooClass')->setFile($fixturesPath.'/includes/%file%.php'); -$builder->setParameter('file', 'foo'); -$t->ok($builder->getService('foo2'), '->createService() replaces parameters in the file provided by the service definition'); - -// ->createService() # class -$t->diag('->createService() # class'); -$builder = new Builder(); -$builder->register('foo1', '%class%'); -$builder->setParameter('class', 'stdClass'); -$t->ok($builder->getService('foo1') instanceof stdClass, '->createService() replaces parameters in the class provided by the service definition'); - -// ->createService() # arguments -$t->diag('->createService() # arguments'); -$builder = new Builder(); -$builder->register('bar', 'stdClass'); -$builder->register('foo1', 'FooClass')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); -$builder->setParameter('value', 'bar'); -$t->is($builder->getService('foo1')->arguments, array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), '->createService() replaces parameters and service references in the arguments provided by the service definition'); - -// ->createService() # constructor -$t->diag('->createService() # constructor'); -$builder = new Builder(); -$builder->register('bar', 'stdClass'); -$builder->register('foo1', 'FooClass')->setConstructor('getInstance')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); -$builder->setParameter('value', 'bar'); -$t->ok($builder->getService('foo1')->called, '->createService() calls the constructor to create the service instance'); -$t->is($builder->getService('foo1')->arguments, array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), '->createService() passes the arguments to the constructor'); - -// ->createService() # method calls -$t->diag('->createService() # method calls'); -$builder = new Builder(); -$builder->register('bar', 'stdClass'); -$builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%value%', new Reference('bar')))); -$builder->setParameter('value', 'bar'); -$t->is($builder->getService('foo1')->bar, array('bar', $builder->getService('bar')), '->createService() replaces the values in the method calls arguments'); - -// ->createService() # configurator -require_once $fixturesPath.'/includes/classes.php'; -$t->diag('->createService() # configurator'); -$builder = new Builder(); -$builder->register('foo1', 'FooClass')->setConfigurator('sc_configure'); -$t->ok($builder->getService('foo1')->configured, '->createService() calls the configurator'); - -$builder->register('foo2', 'FooClass')->setConfigurator(array('%class%', 'configureStatic')); -$builder->setParameter('class', 'BazClass'); -$t->ok($builder->getService('foo2')->configured, '->createService() calls the configurator'); - -$builder->register('baz', 'BazClass'); -$builder->register('foo3', 'FooClass')->setConfigurator(array(new Reference('baz'), 'configure')); -$t->ok($builder->getService('foo3')->configured, '->createService() calls the configurator'); - -$builder->register('foo4', 'FooClass')->setConfigurator('foo'); -try -{ - $builder->getService('foo4'); - $t->fail('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); -} - -// ::resolveValue() -$t->diag('::resolveValue()'); -$t->is(Builder::resolveValue('foo', array()), 'foo', '->resolveValue() returns its argument unmodified if no placeholders are found'); -$t->is(Builder::resolveValue('I\'m a %foo%', array('foo' => 'bar')), 'I\'m a bar', '->resolveValue() replaces placeholders by their values'); -$t->ok(Builder::resolveValue('%foo%', array('foo' => true)) === true, '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); - -$t->is(Builder::resolveValue(array('%foo%' => '%foo%'), array('foo' => 'bar')), array('bar' => 'bar'), '->resolveValue() replaces placeholders in keys and values of arrays'); - -$t->is(Builder::resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%'))), array('foo' => 'bar')), array('bar' => array('bar' => array('bar' => 'bar'))), '->resolveValue() replaces placeholders in nested arrays'); - -$t->is(Builder::resolveValue('I\'m a %%foo%%', array('foo' => 'bar')), 'I\'m a %foo%', '->resolveValue() supports % escaping by doubling it'); -$t->is(Builder::resolveValue('I\'m a %foo% %%foo %foo%', array('foo' => 'bar')), 'I\'m a bar %foo bar', '->resolveValue() supports % escaping by doubling it'); - -try -{ - Builder::resolveValue('%foobar%', array()); - $t->fail('->resolveValue() throws a RuntimeException if a placeholder references a non-existant parameter'); -} -catch (RuntimeException $e) -{ - $t->pass('->resolveValue() throws a RuntimeException if a placeholder references a non-existant parameter'); -} - -try -{ - Builder::resolveValue('foo %foobar% bar', array()); - $t->fail('->resolveValue() throws a RuntimeException if a placeholder references a non-existant parameter'); -} -catch (RuntimeException $e) -{ - $t->pass('->resolveValue() throws a RuntimeException if a placeholder references a non-existant parameter'); -} - -// ->resolveServices() -$t->diag('->resolveServices()'); -$builder = new Builder(); -$builder->register('foo', 'FooClass'); -$t->is($builder->resolveServices(new Reference('foo')), $builder->getService('foo'), '->resolveServices() resolves service references to service instances'); -$t->is($builder->resolveServices(array('foo' => array('foo', new Reference('foo')))), array('foo' => array('foo', $builder->getService('foo'))), '->resolveServices() resolves service references to service instances in nested arrays'); - -// ->merge() -$t->diag('->merge()'); -$container = new Builder(); -$container->merge(null); -$t->is($container->getParameters(), array(), '->merge() accepts null as an argument'); -$t->is($container->getDefinitions(), array(), '->merge() accepts null as an argument'); - -$container = new Builder(array('bar' => 'foo')); -$config = new BuilderConfiguration(); -$config->setParameters(array('foo' => 'bar')); -$container->merge($config); -$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones'); - -$container = new Builder(array('bar' => 'foo', 'foo' => 'baz')); -$config = new BuilderConfiguration(); -$config->setParameters(array('foo' => 'bar')); -$container->merge($config); -$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'baz'), '->merge() does not change the already defined parameters'); - -$container = new Builder(array('bar' => 'foo')); -$config = new BuilderConfiguration(); -$config->setParameters(array('foo' => '%bar%')); -$container->merge($config); -$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones'); - -$container = new Builder(array('bar' => 'foo')); -$config = new BuilderConfiguration(); -$config->setParameters(array('foo' => '%bar%', 'baz' => '%foo%')); -$container->merge($config); -$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones'); - -$container = new Builder(); -$container->register('foo', 'FooClass'); -$container->register('bar', 'BarClass'); -$config = new BuilderConfiguration(); -$config->setDefinition('baz', new Definition('BazClass')); -$config->setAlias('alias_for_foo', 'foo'); -$container->merge($config); -$t->is(array_keys($container->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones'); -$t->is($container->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases'); - -$container = new Builder(); -$container->register('foo', 'FooClass'); -$config->setDefinition('foo', new Definition('BazClass')); -$container->merge($config); -$t->is($container->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services'); - -// ->findAnnotatedServiceIds() -$t->diag('->findAnnotatedServiceIds()'); -$builder = new Builder(); -$builder - ->register('foo', 'FooClass') - ->addAnnotation('foo', array('foo' => 'foo')) - ->addAnnotation('bar', array('bar' => 'bar')) - ->addAnnotation('foo', array('foofoo' => 'foofoo')) -; -$t->is($builder->findAnnotatedServiceIds('foo'), array( - 'foo' => array( - array('foo' => 'foo'), - array('foofoo' => 'foofoo'), - ) -), '->findAnnotatedServiceIds() returns an array of service ids and its annotation attributes'); -$t->is($builder->findAnnotatedServiceIds('foobar'), array(), '->findAnnotatedServiceIds() returns an empty array if there is annotated services'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/ContainerTest.php b/tests/unit/Symfony/Components/DependencyInjection/ContainerTest.php deleted file mode 100644 index 6cd5bb3373c11..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/ContainerTest.php +++ /dev/null @@ -1,207 +0,0 @@ - - * - * 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')); -$sc->setParameter('bar', 'foo'); -$t->is($sc->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter'); -$t->is($sc['bar'], 'foo', '->offsetGet() gets the value of a parameter'); - -$sc['bar1'] = 'foo1'; -$t->is($sc['bar1'], 'foo1', '->offsetset() sets the value of a parameter'); - -unset($sc['bar1']); -$t->ok(!isset($sc['bar1']), '->offsetUnset() removes a parameter'); - -$sc->setParameter('foo', 'baz'); -$t->is($sc->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter'); - -$sc->setParameter('Foo', 'baz1'); -$t->is($sc->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase'); -$t->is($sc->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); -$t->is($sc['FOO'], 'baz1', '->offsetGet() converts the key to lowercase'); - -try -{ - $sc->getParameter('baba'); - $t->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getParameter() thrown an \InvalidArgumentException if the key does not exist'); -} - -try -{ - $sc['baba']; - $t->fail('->offsetGet() thrown an \InvalidArgumentException if the key does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->offsetGet() thrown an \InvalidArgumentException if the key does not exist'); -} - -// ->hasParameter() -$t->diag('->hasParameter()'); -$sc = new Container(array('foo' => 'bar')); -$t->ok($sc->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); -$t->ok($sc->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); -$t->ok(isset($sc['Foo']), '->offsetExists() converts the key to lowercase'); -$t->ok(!$sc->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); -$t->ok(isset($sc['foo']), '->offsetExists() returns true if a parameter is defined'); -$t->ok(!isset($sc['bar']), '->offsetExists() returns false if a parameter is not defined'); - -// ->addParameters() -$t->diag('->addParameters()'); -$sc = new Container(array('foo' => 'bar')); -$sc->addParameters(array('bar' => 'foo')); -$t->is($sc->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); -$sc->addParameters(array('Bar' => 'fooz')); -$t->is($sc->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); - -// ->setService() ->hasService() ->getService() -$t->diag('->setService() ->hasService() ->getService()'); -$sc = new Container(); -$sc->setService('foo', $obj = new stdClass()); -$t->is(spl_object_hash($sc->getService('foo')), spl_object_hash($obj), '->setService() registers a service under a key name'); - -$sc->foo1 = $obj1 = new stdClass(); -$t->is(spl_object_hash($sc->foo1), spl_object_hash($obj1), '->__set() sets a service'); - -$t->is(spl_object_hash($sc->foo), spl_object_hash($obj), '->__get() gets a service by name'); -$t->ok($sc->hasService('foo'), '->hasService() returns true if the service is defined'); -$t->ok(isset($sc->foo), '->__isset() returns true if the service is defined'); -$t->ok(!$sc->hasService('bar'), '->hasService() returns false if the service is not defined'); -$t->ok(!isset($sc->bar), '->__isset() returns false if the service is not defined'); - -// ->getServiceIds() -$t->diag('->getServiceIds()'); -$sc = new Container(); -$sc->setService('foo', $obj = new stdClass()); -$sc->setService('bar', $obj = new stdClass()); -$t->is($sc->getServiceIds(), array('service_container', 'foo', 'bar'), '->getServiceIds() returns all defined service ids'); - -class ProjectServiceContainer extends Container -{ - public $__bar, $__foo_bar, $__foo_baz; - - public function __construct() - { - parent::__construct(); - - $this->__bar = new stdClass(); - $this->__foo_bar = new stdClass(); - $this->__foo_baz = new stdClass(); - } - - protected function getBarService() - { - return $this->__bar; - } - - protected function getFooBarService() - { - return $this->__foo_bar; - } - - protected function getFoo_BazService() - { - return $this->__foo_baz; - } -} - -$sc = new ProjectServiceContainer(); -$t->is(spl_object_hash($sc->getService('bar')), spl_object_hash($sc->__bar), '->getService() looks for a getXXXService() method'); -$t->ok($sc->hasService('bar'), '->hasService() returns true if the service has been defined as a getXXXService() method'); - -$sc->setService('bar', $bar = new stdClass()); -$t->isnt(spl_object_hash($sc->getService('bar')), spl_object_hash($bar), '->getService() prefers to return a service defined with a getXXXService() method than one defined with setService()'); - -try -{ - $sc->getService('baba'); - $t->fail('->getService() thrown an \InvalidArgumentException if the service does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getService() thrown an \InvalidArgumentException if the service does not exist'); -} - -try -{ - $sc->baba; - $t->fail('->__get() thrown an \InvalidArgumentException if the service does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->__get() thrown an \InvalidArgumentException if the service does not exist'); -} - -try -{ - unset($sc->baba); - $t->fail('->__unset() thrown an LogicException if you try to remove a service'); -} -catch (LogicException $e) -{ - $t->pass('->__unset() thrown an LogicException if you try to remove a service'); -} - -$t->is(spl_object_hash($sc->getService('foo_bar')), spl_object_hash($sc->__foo_bar), '->getService() camelizes the service id when looking for a method'); -$t->is(spl_object_hash($sc->getService('foo.baz')), spl_object_hash($sc->__foo_baz), '->getService() camelizes the service id when looking for a method'); - -// __call() -$t->diag('__call()'); -$sc = new Container(); -$sc->setService('foo_bar.foo', $foo = new stdClass()); -$t->is($sc->getFooBar_FooService(), $foo, '__call() finds services is the method is getXXXService()'); - -try -{ - $sc->getFooBar_Foo(); - $t->fail('__call() throws a \RuntimeException exception if the method is not a service method'); -} -catch (\RuntimeException $e) -{ - $t->pass('__call() throws a \RuntimeException exception if the method is not a service method'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/CrossCheckTest.php b/tests/unit/Symfony/Components/DependencyInjection/CrossCheckTest.php deleted file mode 100644 index 4c55dc08afc3a..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/CrossCheckTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * 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; - -$fixturesPath = realpath(__DIR__.'/../../../../fixtures/Symfony/Components/DependencyInjection/'); - -require_once $fixturesPath.'/includes/classes.php'; -require_once $fixturesPath.'/includes/foo.php'; - -$t = new LimeTest(30); - -// cross-check loaders/dumpers -$t->diag('cross-check loaders/dumpers'); - -$fixtures = array( - 'services1.xml' => 'xml', - 'services2.xml' => 'xml', - 'services6.xml' => 'xml', - 'services8.xml' => 'xml', - 'services9.xml' => 'xml', - - 'services1.yml' => 'yaml', - 'services2.yml' => 'yaml', - 'services6.yml' => 'yaml', - 'services8.yml' => 'yaml', - 'services9.yml' => 'yaml', -); - -foreach ($fixtures as $fixture => $type) -{ - $loaderClass = 'Symfony\\Components\\DependencyInjection\\Loader\\'.ucfirst($type).'FileLoader'; - $dumperClass = 'Symfony\\Components\\DependencyInjection\\Dumper\\'.ucfirst($type).'Dumper'; - - $container1 = new Builder(); - $loader1 = new $loaderClass($container1); - $loader1->load($fixturesPath.'/'.$type.'/'.$fixture); - $container1->setParameter('path', $fixturesPath.'/includes'); - - $dumper = new $dumperClass($container1); - $tmp = tempnam('sf_service_container', 'sf'); - file_put_contents($tmp, $dumper->dump()); - - $container2 = new Builder(); - $loader2 = new $loaderClass($container2); - $loader2->load($tmp); - $container2->setParameter('path', $fixturesPath.'/includes'); - - unlink($tmp); - - $t->is(serialize($container1), serialize($container2), 'loading a dump from a previously loaded container returns the same container'); - - $t->is($container1->getParameters(), $container2->getParameters(), '->getParameters() returns the same value for both containers'); - - $services1 = array(); - foreach ($container1 as $id => $service) - { - $services1[$id] = serialize($service); - } - $services2 = array(); - foreach ($container2 as $id => $service) - { - $services2[$id] = serialize($service); - } - - unset($services1['service_container'], $services2['service_container']); - - $t->is($services1, $services2, 'Iterator on the containers returns the same services'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/DefinitionTest.php b/tests/unit/Symfony/Components/DependencyInjection/DefinitionTest.php deleted file mode 100644 index 1cb1f8d777198..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/DefinitionTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * 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(25); - -// __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'); -$t->is(spl_object_hash($def->setArguments(array('foo'))), spl_object_hash($def), '->setArguments() implements a fluent interface'); -$t->is($def->getArguments(), array('foo'), '->getArguments() returns the arguments'); -$t->is(spl_object_hash($def->addArgument('bar')), spl_object_hash($def), '->addArgument() implements a fluent interface'); -$t->is($def->getArguments(), array('foo', 'bar'), '->addArgument() adds an argument'); - -// ->setMethodCalls() ->getMethodCalls() ->addMethodCall() -$t->diag('->setMethodCalls() ->getMethodCalls() ->addMethodCall()'); -$def = new Definition('stdClass'); -$t->is(spl_object_hash($def->setMethodCalls(array(array('foo', array('foo'))))), spl_object_hash($def), '->setMethodCalls() implements a fluent interface'); -$t->is($def->getMethodCalls(), array(array('foo', array('foo'))), '->getMethodCalls() returns the methods to call'); -$t->is(spl_object_hash($def->addMethodCall('bar', array('bar'))), spl_object_hash($def), '->addMethodCall() implements a fluent interface'); -$t->is($def->getMethodCalls(), array(array('foo', array('foo')), array('bar', array('bar'))), '->addMethodCall() adds a method to call'); - -// ->setFile() ->getFile() -$t->diag('->setFile() ->getFile()'); -$def = new Definition('stdClass'); -$t->is(spl_object_hash($def->setFile('foo')), spl_object_hash($def), '->setFile() implements a fluent interface'); -$t->is($def->getFile(), 'foo', '->getFile() returns the file to include'); - -// ->setShared() ->isShared() -$t->diag('->setShared() ->isShared()'); -$def = new Definition('stdClass'); -$t->is($def->isShared(), true, '->isShared() returns true by default'); -$t->is(spl_object_hash($def->setShared(false)), spl_object_hash($def), '->setShared() implements a fluent interface'); -$t->is($def->isShared(), false, '->isShared() returns false if the instance must not be shared'); - -// ->setConfigurator() ->getConfigurator() -$t->diag('->setConfigurator() ->getConfigurator()'); -$def = new Definition('stdClass'); -$t->is(spl_object_hash($def->setConfigurator('foo')), spl_object_hash($def), '->setConfigurator() implements a fluent interface'); -$t->is($def->getConfigurator(), 'foo', '->getConfigurator() returns the configurator'); - -// ->getAnnotations() ->getAnnotation() ->addAnnotation() -$t->diag('->getAnnotations() ->getAnnotation() ->addAnnotation()'); -$def = new Definition('stdClass'); -$t->is(spl_object_hash($def->addAnnotation('foo')), spl_object_hash($def), '->addAnnotation() implements a fluent interface'); -$t->is($def->getAnnotation('foo'), array(array()), '->getAnnotation() returns attributes for an annotation name'); -$def->addAnnotation('foo', array('foo' => 'bar')); -$t->is($def->getAnnotation('foo'), array(array(), array('foo' => 'bar')), '->addAnnotation() can adds the same annotation several times'); -$def->addAnnotation('bar', array('bar' => 'bar')); -$t->is($def->getAnnotations(), array( - 'foo' => array(array(), array('foo' => 'bar')), - 'bar' => array(array('bar' => 'bar')), -), '->getAnnotations() returns all annotations'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/Dumper/DumperTest.php b/tests/unit/Symfony/Components/DependencyInjection/Dumper/DumperTest.php deleted file mode 100644 index e1b5ac51236ec..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Dumper/DumperTest.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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\Dumper; - -$t = new LimeTest(1); - -class ProjectDumper extends Dumper -{ -} - -$builder = new Builder(); -$dumper = new ProjectDumper($builder); -try -{ - $dumper->dump(); - $t->fail('->dump() returns a LogicException if the dump() method has not been overriden by a children class'); -} -catch (LogicException $e) -{ - $t->pass('->dump() returns a LogicException if the dump() method has not been overriden by a children class'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/Dumper/GraphvizDumperTest.php b/tests/unit/Symfony/Components/DependencyInjection/Dumper/GraphvizDumperTest.php deleted file mode 100644 index a46fa1e7311c0..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Dumper/GraphvizDumperTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * 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'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/Dumper/PhpDumperTest.php b/tests/unit/Symfony/Components/DependencyInjection/Dumper/PhpDumperTest.php deleted file mode 100644 index 326b85c4a3456..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Dumper/PhpDumperTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * 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\PhpDumper; - -$t = new LimeTest(5); - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); - -// ->dump() -$t->diag('->dump()'); -$dumper = new PhpDumper($container = new Builder()); - -$t->is($dumper->dump(), file_get_contents($fixturesPath.'/php/services1.php'), '->dump() dumps an empty container as an empty PHP class'); -$t->is($dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer')), file_get_contents($fixturesPath.'/php/services1-1.php'), '->dump() takes a class and a base_class options'); - -$container = new Builder(); -$dumper = new PhpDumper($container); - -// ->addParameters() -$t->diag('->addParameters()'); -$container = include $fixturesPath.'/containers/container8.php'; -$dumper = new PhpDumper($container); -$t->is($dumper->dump(), file_get_contents($fixturesPath.'/php/services8.php'), '->dump() dumps parameters'); - -// ->addService() -$t->diag('->addService()'); -$container = include $fixturesPath.'/containers/container9.php'; -$dumper = new PhpDumper($container); -$t->is($dumper->dump(), str_replace('%path%', $fixturesPath.'/includes', file_get_contents($fixturesPath.'/php/services9.php')), '->dump() dumps services'); - -$dumper = new PhpDumper($container = new Builder()); -$container->register('foo', 'FooClass')->addArgument(new stdClass()); -try -{ - $dumper->dump(); - $t->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); -} -catch (RuntimeException $e) -{ - $t->pass('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/Dumper/XmlDumperTest.php b/tests/unit/Symfony/Components/DependencyInjection/Dumper/XmlDumperTest.php deleted file mode 100644 index 9f49c8ee54884..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Dumper/XmlDumperTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * 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\XmlDumper; - -$t = new LimeTest(4); - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); - -// ->dump() -$t->diag('->dump()'); -$dumper = new XmlDumper($container = new Builder()); - -$t->is($dumper->dump(), file_get_contents($fixturesPath.'/xml/services1.xml'), '->dump() dumps an empty container as an empty XML file'); - -$container = new Builder(); -$dumper = new XmlDumper($container); - -// ->addParameters() -$t->diag('->addParameters()'); -$container = include $fixturesPath.'//containers/container8.php'; -$dumper = new XmlDumper($container); -$t->is($dumper->dump(), file_get_contents($fixturesPath.'/xml/services8.xml'), '->dump() dumps parameters'); - -// ->addService() -$t->diag('->addService()'); -$container = include $fixturesPath.'/containers/container9.php'; -$dumper = new XmlDumper($container); -$t->is($dumper->dump(), str_replace('%path%', $fixturesPath.'/includes', file_get_contents($fixturesPath.'/xml/services9.xml')), '->dump() dumps services'); - -$dumper = new XmlDumper($container = new Builder()); -$container->register('foo', 'FooClass')->addArgument(new stdClass()); -try -{ - $dumper->dump(); - $t->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); -} -catch (RuntimeException $e) -{ - $t->pass('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/Dumper/YamlDumperTest.php b/tests/unit/Symfony/Components/DependencyInjection/Dumper/YamlDumperTest.php deleted file mode 100644 index 19d5764f37ae6..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Dumper/YamlDumperTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * 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\YamlDumper; - -$t = new LimeTest(4); - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); - -// ->dump() -$t->diag('->dump()'); -$dumper = new YamlDumper($container = new Builder()); - -$t->is($dumper->dump(), file_get_contents($fixturesPath.'/yaml/services1.yml'), '->dump() dumps an empty container as an empty YAML file'); - -$container = new Builder(); -$dumper = new YamlDumper($container); - -// ->addParameters() -$t->diag('->addParameters()'); -$container = include $fixturesPath.'/containers/container8.php'; -$dumper = new YamlDumper($container); -$t->is($dumper->dump(), file_get_contents($fixturesPath.'/yaml/services8.yml'), '->dump() dumps parameters'); - -// ->addService() -$t->diag('->addService()'); -$container = include $fixturesPath.'/containers/container9.php'; -$dumper = new YamlDumper($container); -$t->is($dumper->dump(), str_replace('%path%', $fixturesPath.'/includes', file_get_contents($fixturesPath.'/yaml/services9.yml')), '->dump() dumps services'); - -$dumper = new YamlDumper($container = new Builder()); -$container->register('foo', 'FooClass')->addArgument(new stdClass()); -try -{ - $dumper->dump(); - $t->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); -} -catch (RuntimeException $e) -{ - $t->pass('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/FileResourceTest.php b/tests/unit/Symfony/Components/DependencyInjection/FileResourceTest.php deleted file mode 100644 index 8113de51522b2..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/FileResourceTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * 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\FileResource; - -$t = new LimeTest(4); - -// ->getResource() -$t->diag('->getResource()'); -$file = sys_get_temp_dir().'/tmp.xml'; -touch($file); -$resource = new FileResource($file); -$t->is($resource->getResource(), $file, '->getResource() returns the path to the resource'); - -// ->isUptodate() -$t->diag('->isUptodate()'); -$t->ok($resource->isUptodate(time() + 10), '->isUptodate() returns true if the resource has not changed'); -$t->ok(!$resource->isUptodate(time() - 86400), '->isUptodate() returns false if the resource has been updated'); -unlink($file); - -$resource = new FileResource('/____foo/foobar'.rand(1, 999999)); -$t->ok(!$resource->isUptodate(time()), '->isUptodate() returns false if the resource does not exist'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/Loader/FileLoaderTest.php b/tests/unit/Symfony/Components/DependencyInjection/Loader/FileLoaderTest.php deleted file mode 100644 index b0e6ed5b743e3..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Loader/FileLoaderTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * 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\FileLoader; - -$t = new LimeTest(9); - -class ProjectLoader extends FileLoader -{ - public $paths; - - public function load($resource) - { - } - - public function getAbsolutePath($file, $currentPath = null) - { - return parent::getAbsolutePath($file, $currentPath); - } -} - -// __construct() -$t->diag('__construct()'); -$loader = new ProjectLoader(__DIR__); -$t->is($loader->paths, array(__DIR__), '__construct() takes a path as its second argument'); - -$loader = new ProjectLoader(array(__DIR__, __DIR__)); -$t->is($loader->paths, array(__DIR__, __DIR__), '__construct() takes an array of paths as its second argument'); - -// ->getAbsolutePath() -$t->diag('->getAbsolutePath()'); -$loader = new ProjectLoader(array(__DIR__.'/../../../../../bin')); -$t->is($loader->getAbsolutePath('/foo.xml'), '/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); -$t->is($loader->getAbsolutePath('c:\\\\foo.xml'), 'c:\\\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); -$t->is($loader->getAbsolutePath('c:/foo.xml'), 'c:/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); -$t->is($loader->getAbsolutePath('\\server\\foo.xml'), '\\server\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); - -$t->is($loader->getAbsolutePath('FileLoaderTest.php', __DIR__), __DIR__.'/FileLoaderTest.php', '->getAbsolutePath() returns an absolute filename if the file exists in the current path'); - -$t->is($loader->getAbsolutePath('prove.php', __DIR__), __DIR__.'/../../../../../bin/prove.php', '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor'); - -$t->is($loader->getAbsolutePath('foo.xml', __DIR__), 'foo.xml', '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/Loader/IniLoaderTest.php b/tests/unit/Symfony/Components/DependencyInjection/Loader/IniLoaderTest.php deleted file mode 100644 index 9a44ea9e7fe39..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Loader/IniLoaderTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * 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'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if the loaded file is not parseable'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderExtensionTest.php b/tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderExtensionTest.php deleted file mode 100644 index 3f0361d4d93ad..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Loader/LoaderExtensionTest.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../../bootstrap.php'; - -require_once __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php'; - -$t = new LimeTest(2); - -// ->load() -$t->diag('->load()'); -$extension = new ProjectExtension(); - -try -{ - $extension->load('foo', array()); - $t->fail('->load() throws an InvalidArgumentException if the tag does not exist'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if the tag does not exist'); -} - -$config = $extension->load('bar', array('foo' => 'bar')); -$t->is($config->getParameters(), array('project.parameter.bar' => 'bar'), '->load() calls the method tied to the given tag'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/Loader/XmlFileLoaderTest.php b/tests/unit/Symfony/Components/DependencyInjection/Loader/XmlFileLoaderTest.php deleted file mode 100644 index 19aabf02480ee..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Loader/XmlFileLoaderTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * 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\Reference; -use Symfony\Components\DependencyInjection\Definition; -use Symfony\Components\DependencyInjection\Loader\Loader; -use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; - -$t = new LimeTest(40); - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); - -require_once $fixturesPath.'/includes/ProjectExtension.php'; - -class ProjectLoader extends XmlFileLoader -{ - public function parseFile($file) - { - return parent::parseFile($file); - } -} - -// ->load() -$t->diag('->load()'); - -$loader = new ProjectLoader($fixturesPath.'/ini'); - -try -{ - $loader->load('foo.xml'); - $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'); -} - -// ->parseFile() -$t->diag('->parseFile()'); - -try -{ - $loader->parseFile($fixturesPath.'/ini/parameters.ini'); - $t->fail('->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); -} - -$loader = new ProjectLoader($fixturesPath.'/xml'); - -try -{ - $loader->parseFile($fixturesPath.'/xml/nonvalid.xml'); - $t->fail('->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); -} - -$xml = $loader->parseFile($fixturesPath.'/xml/services1.xml'); -$t->is(get_class($xml), 'Symfony\\Components\\DependencyInjection\\SimpleXMLElement', '->parseFile() returns an SimpleXMLElement object'); - -// ->load() # parameters -$t->diag('->load() # parameters'); -$loader = new ProjectLoader($fixturesPath.'/xml'); -$config = $loader->load('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'); - -// ->load() # imports -$t->diag('->load() # imports'); -$config = $loader->load('services4.xml'); -$t->is($config->getParameters(), array('a string', 'foo' => 'bar', 'bar' => '%foo%', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'imported_from_yaml' => true, 'imported_from_ini' => true), '->load() imports and merges imported files'); - -// ->load() # anonymous services -$t->diag('->load() # anonymous services'); -$config = $loader->load('services5.xml'); -$services = $config->getDefinitions(); -$t->is(count($services), 3, '->load() attributes unique ids to anonymous services'); -$args = $services['foo']->getArguments(); -$t->is(count($args), 1, '->load() references anonymous services as "normal" ones'); -$t->is(get_class($args[0]), 'Symfony\\Components\\DependencyInjection\\Reference', '->load() converts anonymous services to references to "normal" services'); -$t->ok(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); -$inner = $services[(string) $args[0]]; -$t->is($inner->getClass(), 'BarClass', '->load() uses the same configuration as for the anonymous ones'); - -$args = $inner->getArguments(); -$t->is(count($args), 1, '->load() references anonymous services as "normal" ones'); -$t->is(get_class($args[0]), 'Symfony\\Components\\DependencyInjection\\Reference', '->load() converts anonymous services to references to "normal" services'); -$t->ok(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); -$inner = $services[(string) $args[0]]; -$t->is($inner->getClass(), 'BazClass', '->load() uses the same configuration as for the anonymous ones'); - -// ->load() # services -$t->diag('->load() # services'); -$config = $loader->load('services6.xml'); -$services = $config->getDefinitions(); -$t->ok(isset($services['foo']), '->load() parses elements'); -$t->is(get_class($services['foo']), 'Symfony\\Components\\DependencyInjection\\Definition', '->load() converts 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'); -$t->is($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute'); -$t->is($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag'); -$t->is($services['arguments']->getArguments(), array('foo', new Reference('foo'), array(true, false)), '->load() parses the argument tags'); -$t->is($services['configurator1']->getConfigurator(), 'sc_configure', '->load() parses the configurator tag'); -$t->is($services['configurator2']->getConfigurator(), array(new Reference('baz'), 'configure'), '->load() parses the configurator tag'); -$t->is($services['configurator3']->getConfigurator(), array('BazClass', 'configureStatic'), '->load() parses the configurator tag'); -$t->is($services['method_call1']->getMethodCalls(), array(array('setBar', array())), '->load() parses the method_call tag'); -$t->is($services['method_call2']->getMethodCalls(), array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), '->load() parses the method_call tag'); -$aliases = $config->getAliases(); -$t->ok(isset($aliases['alias_for_foo']), '->load() parses elements'); -$t->is($aliases['alias_for_foo'], 'foo', '->load() parses aliases'); - -// ::convertDomElementToArray() -$t->diag('::convertDomElementToArray()'); -$doc = new DOMDocument("1.0"); -$doc->loadXML('bar'); -$t->is(ProjectLoader::convertDomElementToArray($doc->documentElement), 'bar', '::convertDomElementToArray() converts a \DomElement to an array'); - -$doc = new DOMDocument("1.0"); -$doc->loadXML(''); -$t->is(ProjectLoader::convertDomElementToArray($doc->documentElement), array('foo' => 'bar'), '::convertDomElementToArray() converts a \DomElement to an array'); - -$doc = new DOMDocument("1.0"); -$doc->loadXML('bar'); -$t->is(ProjectLoader::convertDomElementToArray($doc->documentElement), array('foo' => 'bar'), '::convertDomElementToArray() converts a \DomElement to an array'); - -$doc = new DOMDocument("1.0"); -$doc->loadXML('barbar'); -$t->is(ProjectLoader::convertDomElementToArray($doc->documentElement), array('foo' => array('value' => 'bar', 'foo' => 'bar')), '::convertDomElementToArray() converts a \DomElement to an array'); - -$doc = new DOMDocument("1.0"); -$doc->loadXML(''); -$t->is(ProjectLoader::convertDomElementToArray($doc->documentElement), array('foo' => null), '::convertDomElementToArray() converts a \DomElement to an array'); - -$doc = new DOMDocument("1.0"); -$doc->loadXML(''); -$t->is(ProjectLoader::convertDomElementToArray($doc->documentElement), array('foo' => null), '::convertDomElementToArray() converts a \DomElement to an array'); - -// extensions -$t->diag('extensions'); -Loader::registerExtension(new ProjectExtension()); -$loader = new ProjectLoader($fixturesPath.'/xml'); - -$config = $loader->load('services10.xml'); -$services = $config->getDefinitions(); -$parameters = $config->getParameters(); -$t->ok(isset($services['project.service.bar']), '->load() parses extension elements'); -$t->ok(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); - -try -{ - $config = $loader->load('services11.xml'); - $t->fail('->load() throws an InvalidArgumentException if the tag is not valid'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if the tag is not valid'); -} - -try -{ - $config = $loader->load('services12.xml'); - $t->fail('->load() throws an InvalidArgumentException if an extension is not loaded'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if an extension is not loaded'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/Loader/YamlFileLoaderTest.php b/tests/unit/Symfony/Components/DependencyInjection/Loader/YamlFileLoaderTest.php deleted file mode 100644 index dd59663c0d47b..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/Loader/YamlFileLoaderTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * 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\Reference; -use Symfony\Components\DependencyInjection\Definition; -use Symfony\Components\DependencyInjection\Loader\Loader; -use Symfony\Components\DependencyInjection\Loader\YamlFileLoader; - -$t = new LimeTest(25); - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/'); - -require_once $fixturesPath.'/includes/ProjectExtension.php'; - -class ProjectLoader extends YamlFileLoader -{ - public function loadFile($file) - { - return parent::loadFile($file); - } -} - -// ->loadFile() -$t->diag('->loadFile()'); - -$loader = new ProjectLoader($fixturesPath.'/ini'); - -try -{ - $loader->loadFile('foo.yml'); - $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->loadFile('parameters.ini'); - $t->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); -} - -$loader = new ProjectLoader($fixturesPath.'/yaml'); - -foreach (array('nonvalid1', 'nonvalid2') as $fixture) -{ - 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'); -$t->is($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute'); -$t->is($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag'); -$t->is($services['arguments']->getArguments(), array('foo', new Reference('foo'), array(true, false)), '->load() parses the argument tags'); -$t->is($services['configurator1']->getConfigurator(), 'sc_configure', '->load() parses the configurator tag'); -$t->is($services['configurator2']->getConfigurator(), array(new Reference('baz'), 'configure'), '->load() parses the configurator tag'); -$t->is($services['configurator3']->getConfigurator(), array('BazClass', 'configureStatic'), '->load() parses the configurator tag'); -$t->is($services['method_call1']->getMethodCalls(), array(array('setBar', array())), '->load() parses the method_call tag'); -$t->is($services['method_call2']->getMethodCalls(), array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), '->load() parses the method_call tag'); -$aliases = $config->getAliases(); -$t->ok(isset($aliases['alias_for_foo']), '->load() parses aliases'); -$t->is($aliases['alias_for_foo'], 'foo', '->load() parses aliases'); - -// extensions -$t->diag('extensions'); -Loader::registerExtension(new ProjectExtension()); -$loader = new ProjectLoader($fixturesPath.'/yaml'); - -$config = $loader->load('services10.yml'); -$services = $config->getDefinitions(); -$parameters = $config->getParameters(); -$t->ok(isset($services['project.service.bar']), '->load() parses extension elements'); -$t->ok(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); - -try -{ - $config = $loader->load('services11.yml'); - $t->fail('->load() throws an InvalidArgumentException if the tag is not valid'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if the tag is not valid'); -} - -try -{ - $config = $loader->load('services12.yml'); - $t->fail('->load() throws an InvalidArgumentException if an extension is not loaded'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->load() throws an InvalidArgumentException if an extension is not loaded'); -} diff --git a/tests/unit/Symfony/Components/DependencyInjection/ParameterTest.php b/tests/unit/Symfony/Components/DependencyInjection/ParameterTest.php deleted file mode 100644 index 482caf78d0a14..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/ParameterTest.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * 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\Parameter; - -$t = new LimeTest(1); - -// __construct() ->__toString() -$t->diag('__construct() ->__toString()'); - -$ref = new Parameter('foo'); -$t->is((string) $ref, 'foo', '__construct() sets the id of the parameter, which is used for the __toString() method'); diff --git a/tests/unit/Symfony/Components/DependencyInjection/ReferenceTest.php b/tests/unit/Symfony/Components/DependencyInjection/ReferenceTest.php deleted file mode 100644 index 993711ccd6c02..0000000000000 --- a/tests/unit/Symfony/Components/DependencyInjection/ReferenceTest.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * 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'); diff --git a/tests/unit/Symfony/Components/EventDispatcher/EventDispatcherTest.php b/tests/unit/Symfony/Components/EventDispatcher/EventDispatcherTest.php deleted file mode 100644 index 0aae435969b34..0000000000000 --- a/tests/unit/Symfony/Components/EventDispatcher/EventDispatcherTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * 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\EventDispatcher\Event; -use Symfony\Components\EventDispatcher\EventDispatcher; - -$t = new LimeTest(19); - -$dispatcher = new EventDispatcher(); - -// ->connect() ->disconnect() -$t->diag('->connect() ->disconnect()'); -$dispatcher->connect('bar', 'listenToBar'); -$t->is($dispatcher->getListeners('bar'), array('listenToBar'), '->connect() connects a listener to an event name'); -$dispatcher->connect('bar', 'listenToBarBar'); -$t->is($dispatcher->getListeners('bar'), array('listenToBar', 'listenToBarBar'), '->connect() can connect several listeners for the same event name'); - -$dispatcher->connect('barbar', 'listenToBarBar'); -$dispatcher->disconnect('bar', 'listenToBarBar'); -$t->is($dispatcher->getListeners('bar'), array('listenToBar'), '->disconnect() disconnects a listener for an event name'); -$t->is($dispatcher->getListeners('barbar'), array('listenToBarBar'), '->disconnect() disconnects a listener for an event name'); - -$t->ok($dispatcher->disconnect('foobar', 'listen') === false, '->disconnect() returns false if the listener does not exist'); - -// ->getListeners() ->hasListeners() -$t->diag('->getListeners() ->hasListeners()'); -$t->is($dispatcher->hasListeners('foo'), false, '->hasListeners() returns false if the event has no listener'); -$dispatcher->connect('foo', 'listenToFoo'); -$t->is($dispatcher->hasListeners('foo'), true, '->hasListeners() returns true if the event has some listeners'); -$dispatcher->disconnect('foo', 'listenToFoo'); -$t->is($dispatcher->hasListeners('foo'), false, '->hasListeners() returns false if the event has no listener'); - -$t->is($dispatcher->getListeners('bar'), array('listenToBar'), '->getListeners() returns an array of listeners connected to the given event name'); -$t->is($dispatcher->getListeners('foobar'), array(), '->getListeners() returns an empty array if no listener are connected to the given event name'); - -$listener = new Listener(); - -// ->notify() -$t->diag('->notify()'); -$listener->reset(); -$dispatcher = new EventDispatcher(); -$dispatcher->connect('foo', array($listener, 'listenToFoo')); -$dispatcher->connect('foo', array($listener, 'listenToFooBis')); -$e = $dispatcher->notify($event = new Event(new stdClass(), 'foo')); -$t->is($listener->getValue(), 'listenToFoolistenToFooBis', '->notify() notifies all registered listeners in order'); -$t->is($e, $event, '->notify() returns the event object'); - -$listener->reset(); -$dispatcher = new EventDispatcher(); -$dispatcher->connect('foo', array($listener, 'listenToFooBis')); -$dispatcher->connect('foo', array($listener, 'listenToFoo')); -$dispatcher->notify(new Event(new stdClass(), 'foo')); -$t->is($listener->getValue(), 'listenToFooBislistenToFoo', '->notify() notifies all registered listeners in order'); - -// ->notifyUntil() -$t->diag('->notifyUntil()'); -$listener->reset(); -$dispatcher = new EventDispatcher(); -$dispatcher->connect('foo', array($listener, 'listenToFoo')); -$dispatcher->connect('foo', array($listener, 'listenToFooBis')); -$e = $dispatcher->notifyUntil($event = new Event(new stdClass(), 'foo')); -$t->is($listener->getValue(), 'listenToFoolistenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); -$t->is($e, $event, '->notifyUntil() returns the event object'); - -$listener->reset(); -$dispatcher = new EventDispatcher(); -$dispatcher->connect('foo', array($listener, 'listenToFooBis')); -$dispatcher->connect('foo', array($listener, 'listenToFoo')); -$e = $dispatcher->notifyUntil($event = new Event(new stdClass(), 'foo')); -$t->is($listener->getValue(), 'listenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); - -// ->filter() -$t->diag('->filter()'); -$listener->reset(); -$dispatcher = new EventDispatcher(); -$dispatcher->connect('foo', array($listener, 'filterFoo')); -$dispatcher->connect('foo', array($listener, 'filterFooBis')); -$e = $dispatcher->filter($event = new Event(new stdClass(), 'foo'), 'foo'); -$t->is($e->getReturnValue(), '-*foo*-', '->filter() filters a value'); -$t->is($e, $event, '->filter() returns the event object'); - -$listener->reset(); -$dispatcher = new EventDispatcher(); -$dispatcher->connect('foo', array($listener, 'filterFooBis')); -$dispatcher->connect('foo', array($listener, 'filterFoo')); -$e = $dispatcher->filter($event = new Event(new stdClass(), 'foo'), 'foo'); -$t->is($e->getReturnValue(), '*-foo-*', '->filter() filters a value'); - -class Listener -{ - protected - $value = ''; - - function filterFoo(Event $event, $foo) - { - return "*$foo*"; - } - - function filterFooBis(Event $event, $foo) - { - return "-$foo-"; - } - - function listenToFoo(Event $event) - { - $this->value .= 'listenToFoo'; - } - - function listenToFooBis(Event $event) - { - $this->value .= 'listenToFooBis'; - - return true; - } - - function getValue() - { - return $this->value; - } - - function reset() - { - $this->value = ''; - } -} diff --git a/tests/unit/Symfony/Components/EventDispatcher/EventTest.php b/tests/unit/Symfony/Components/EventDispatcher/EventTest.php deleted file mode 100644 index 0d4961437c430..0000000000000 --- a/tests/unit/Symfony/Components/EventDispatcher/EventTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * 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\EventDispatcher\Event; - -$t = new LimeTest(16); - -$subject = new stdClass(); -$parameters = array('foo' => 'bar'); -$event = new Event($subject, 'name', $parameters); - -// ->getSubject() -$t->diag('->getSubject()'); -$t->is($event->getSubject(), $subject, '->getSubject() returns the event subject'); - -// ->getName() -$t->diag('->getName()'); -$t->is($event->getName(), 'name', '->getName() returns the event name'); - -// ->getParameters() ->setParameter() ->hasParameter() ->getParameter() -$t->diag('->getParameters()'); -$t->is($event->getParameters(), $parameters, '->getParameters() returns the event parameters'); -$t->is($event->getParameter('foo'), 'bar', '->getParameter() returns the value of a parameter'); -$event->setParameter('foo', 'foo'); -$t->is($event->getParameter('foo'), 'foo', '->setParameter() changes the value of a parameter'); -$t->ok($event->hasParameter('foo'), '->hasParameter() returns true if the parameter is defined'); -unset($event['foo']); -$t->ok(!$event->hasParameter('foo'), '->hasParameter() returns false if the parameter is not defined'); - -try -{ - $event->getParameter('foobar'); - $t->fail('->getParameter() throws an \InvalidArgumentException exception when the parameter does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('->getParameter() throws an \InvalidArgumentException exception when the parameter does not exist'); -} -$event = new Event($subject, 'name', $parameters); - -// ->getReturnValue() ->setReturnValue() -$t->diag('->getReturnValue() ->setReturnValue()'); -$event->setReturnValue('foo'); -$t->is($event->getReturnValue(), 'foo', '->getReturnValue() returns the return value of the event'); - -// ->setProcessed() ->isProcessed() -$t->diag('->setProcessed() ->isProcessed()'); -$event->setProcessed(true); -$t->is($event->isProcessed(), true, '->isProcessed() returns true if the event has been processed'); -$event->setProcessed(false); -$t->is($event->isProcessed(), false, '->setProcessed() changes the processed status'); - -// ArrayAccess interface -$t->diag('ArrayAccess interface'); -$t->is($event['foo'], 'bar', 'Event implements the ArrayAccess interface'); -$event['foo'] = 'foo'; -$t->is($event['foo'], 'foo', 'Event implements the ArrayAccess interface'); - -try -{ - $event['foobar']; - $t->fail('::offsetGet() throws an \InvalidArgumentException exception when the parameter does not exist'); -} -catch (\InvalidArgumentException $e) -{ - $t->pass('::offsetGet() throws an \InvalidArgumentException exception when the parameter does not exist'); -} - -$t->ok(isset($event['foo']), 'Event implements the ArrayAccess interface'); -unset($event['foo']); -$t->ok(!isset($event['foo']), 'Event implements the ArrayAccess interface'); diff --git a/tests/unit/Symfony/Components/OutputEscaper/ArrayDecoratorTest.php b/tests/unit/Symfony/Components/OutputEscaper/ArrayDecoratorTest.php deleted file mode 100644 index af7c82875082d..0000000000000 --- a/tests/unit/Symfony/Components/OutputEscaper/ArrayDecoratorTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * 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\OutputEscaper\Escaper; - -$t = new LimeTest(11); - -$a = array('escaped!', 1, null, array(2, 'escaped!')); -$escaped = Escaper::escape('entities', $a); - -// ->getRaw() -$t->diag('->getRaw()'); -$t->is($escaped->getRaw(0), 'escaped!', '->getRaw() returns the raw value'); - -// ArrayAccess interface -$t->diag('ArrayAccess interface'); -$t->is($escaped[0], '<strong>escaped!</strong>', 'The escaped object behaves like an array'); -$t->is($escaped[2], null, 'The escaped object behaves like an array'); -$t->is($escaped[3][1], '<strong>escaped!</strong>', 'The escaped object behaves like an array'); - -$t->ok(isset($escaped[1]), 'The escaped object behaves like an array (isset)'); - -$t->diag('ArrayAccess interface is read only'); -try -{ - unset($escaped[0]); - $t->fail('The escaped object is read only (unset)'); -} -catch (\LogicException $e) -{ - $t->pass('The escaped object is read only (unset)'); -} - -try -{ - $escaped[0] = 12; - $t->fail('The escaped object is read only (set)'); -} -catch (\LogicException $e) -{ - $t->pass('The escaped object is read only (set)'); -} - -// Iterator interface -$t->diag('Iterator interface'); -foreach ($escaped as $key => $value) -{ - switch ($key) - { - case 0: - $t->is($value, '<strong>escaped!</strong>', 'The escaped object behaves like an array'); - break; - case 1: - $t->is($value, 1, 'The escaped object behaves like an array'); - break; - case 2: - $t->is($value, null, 'The escaped object behaves like an array'); - break; - case 3: - break; - default: - $t->fail('The escaped object behaves like an array'); - } -} - -// Coutable interface -$t->diag('Countable interface'); -$t->is(count($escaped), 4, 'The escaped object implements the Countable interface'); diff --git a/tests/unit/Symfony/Components/OutputEscaper/EscaperTest.php b/tests/unit/Symfony/Components/OutputEscaper/EscaperTest.php deleted file mode 100644 index d2fbe4db0f58f..0000000000000 --- a/tests/unit/Symfony/Components/OutputEscaper/EscaperTest.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * 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\OutputEscaper\Escaper; -use Symfony\Components\OutputEscaper\SafeDecorator; -use Symfony\Components\OutputEscaper\IteratorDecorator; -use Symfony\Components\OutputEscaper\ArrayDecorator; -use Symfony\Components\OutputEscaper\ObjectDecorator; - -$t = new LimeTest(39); - -class OutputEscaperTestClass -{ - public $title = 'escaped!'; - - public function getTitle() - { - return $this->title; - } - - public function getTitleTitle() - { - $o = new self; - - return $o->getTitle(); - } -} - -class OutputEscaperTestClassChild extends OutputEscaperTestClass -{ -} - -// ::escape() -$t->diag('::escape()'); -$t->diag('::escape() does not escape special values'); -$t->ok(Escaper::escape('entities', null) === null, '::escape() returns null if the value to escape is null'); -$t->ok(Escaper::escape('entities', false) === false, '::escape() returns false if the value to escape is false'); -$t->ok(Escaper::escape('entities', true) === true, '::escape() returns true if the value to escape is true'); - -$t->diag('::escape() does not escape a value when escaping method is RAW'); -$t->is(Escaper::escape('raw', 'escaped!'), 'escaped!', '::escape() takes an escaping strategy function name as its first argument'); - -$t->diag('::escape() escapes strings'); -$t->is(Escaper::escape('entities', 'escaped!'), '<strong>escaped!</strong>', '::escape() returns an escaped string if the value to escape is a string'); -$t->is(Escaper::escape('entities', 'échappé'), '<strong>échappé</strong>', '::escape() returns an escaped string if the value to escape is a string'); - -$t->diag('::escape() escapes arrays'); -$input = array( - 'foo' => 'escaped!', - 'bar' => array('foo' => 'escaped!'), -); -$output = Escaper::escape('entities', $input); -$t->ok($output instanceof ArrayDecorator, '::escape() returns a ArrayDecorator object if the value to escape is an array'); -$t->is($output['foo'], '<strong>escaped!</strong>', '::escape() escapes all elements of the original array'); -$t->is($output['bar']['foo'], '<strong>escaped!</strong>', '::escape() is recursive'); -$t->is($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); - -$t->diag('::escape() escapes objects'); -$input = new OutputEscaperTestClass(); -$output = Escaper::escape('entities', $input); -$t->ok($output instanceof ObjectDecorator, '::escape() returns a ObjectDecorator object if the value to escape is an object'); -$t->is($output->getTitle(), '<strong>escaped!</strong>', '::escape() escapes all methods of the original object'); -$t->is($output->title, '<strong>escaped!</strong>', '::escape() escapes all properties of the original object'); -$t->is($output->getTitleTitle(), '<strong>escaped!</strong>', '::escape() is recursive'); -$t->is($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); - -$t->is(Escaper::escape('entities', $output)->getTitle(), '<strong>escaped!</strong>', '::escape() does not double escape an object'); -$t->ok(Escaper::escape('entities', new \DirectoryIterator('.')) instanceof IteratorDecorator, '::escape() returns a IteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface'); - -$t->diag('::escape() does not escape object marked as being safe'); -$t->ok(Escaper::escape('entities', new SafeDecorator(new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::escape() returns the original value if it is marked as being safe'); - -Escaper::markClassAsSafe('OutputEscaperTestClass'); -$t->ok(Escaper::escape('entities', new OutputEscaperTestClass()) instanceof OutputEscaperTestClass, '::escape() returns the original value if the object class is marked as being safe'); -$t->ok(Escaper::escape('entities', new OutputEscaperTestClassChild()) instanceof OutputEscaperTestClassChild, '::escape() returns the original value if one of the object parent class is marked as being safe'); - -$t->diag('::escape() cannot escape resources'); -$fh = fopen(__FILE__, 'r'); -try -{ - Escaper::escape('entities', $fh); - $t->fail('::escape() throws an InvalidArgumentException if the value cannot be escaped'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('::escape() throws an InvalidArgumentException if the value cannot be escaped'); -} - -// ::unescape() -$t->diag('::unescape()'); -$t->diag('::unescape() does not unescape special values'); -$t->ok(Escaper::unescape(null) === null, '::unescape() returns null if the value to unescape is null'); -$t->ok(Escaper::unescape(false) === false, '::unescape() returns false if the value to unescape is false'); -$t->ok(Escaper::unescape(true) === true, '::unescape() returns true if the value to unescape is true'); - -$t->diag('::unescape() unescapes strings'); -$t->is(Escaper::unescape('<strong>escaped!</strong>'), 'escaped!', '::unescape() returns an unescaped string if the value to unescape is a string'); -$t->is(Escaper::unescape('<strong>échappé</strong>'), 'échappé', '::unescape() returns an unescaped string if the value to unescape is a string'); - -$t->diag('::unescape() unescapes arrays'); -$input = Escaper::escape('entities', array( - 'foo' => 'escaped!', - 'bar' => array('foo' => 'escaped!'), -)); -$output = Escaper::unescape($input); -$t->ok(is_array($output), '::unescape() returns an array if the input is a ArrayDecorator object'); -$t->is($output['foo'], 'escaped!', '::unescape() unescapes all elements of the original array'); -$t->is($output['bar']['foo'], 'escaped!', '::unescape() is recursive'); - -$t->diag('::unescape() unescapes objects'); -$object = new OutputEscaperTestClass(); -$input = Escaper::escape('entities', $object); -$output = Escaper::unescape($input); -$t->ok($output instanceof OutputEscaperTestClass, '::unescape() returns the original object when a ObjectDecorator object is passed'); -$t->is($output->getTitle(), 'escaped!', '::unescape() unescapes all methods of the original object'); -$t->is($output->title, 'escaped!', '::unescape() unescapes all properties of the original object'); -$t->is($output->getTitleTitle(), 'escaped!', '::unescape() is recursive'); - -$t->ok(IteratorDecorator::unescape(Escaper::escape('entities', new DirectoryIterator('.'))) instanceof DirectoryIterator, '::unescape() unescapes IteratorDecorator objects'); - -$t->diag('::unescape() does not unescape object marked as being safe'); -$t->ok(Escaper::unescape(Escaper::escape('entities', new SafeDecorator(new OutputEscaperTestClass()))) instanceof OutputEscaperTestClass, '::unescape() returns the original value if it is marked as being safe'); - -Escaper::markClassAsSafe('OutputEscaperTestClass'); -$t->ok(Escaper::unescape(Escaper::escape('entities', new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::unescape() returns the original value if the object class is marked as being safe'); -$t->ok(Escaper::unescape(Escaper::escape('entities', new OutputEscaperTestClassChild())) instanceof OutputEscaperTestClassChild, '::unescape() returns the original value if one of the object parent class is marked as being safe'); - -$t->diag('::unescape() do nothing to resources'); -$fh = fopen(__FILE__, 'r'); -$t->is(Escaper::unescape($fh), $fh, '::unescape() do nothing to resources'); - -$t->diag('::unescape() unescapes mixed arrays'); -$object = new OutputEscaperTestClass(); -$input = array( - 'foo' => 'bar', - 'bar' => Escaper::escape('entities', 'bar'), - 'foobar' => Escaper::escape('entities', $object), -); -$output = array( - 'foo' => 'bar', - 'bar' => 'bar', - 'foobar' => $object, -); -$t->is(Escaper::unescape($input), $output, '::unescape() unescapes values with some escaped and unescaped values'); diff --git a/tests/unit/Symfony/Components/OutputEscaper/ObjectDecoratorTest.php b/tests/unit/Symfony/Components/OutputEscaper/ObjectDecoratorTest.php deleted file mode 100644 index 993b9dc9e80e4..0000000000000 --- a/tests/unit/Symfony/Components/OutputEscaper/ObjectDecoratorTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\OutputEscaper\Escaper; - -$t = new LimeTest(3); - -class OutputEscaperTest -{ - public function __toString() - { - return $this->getTitle(); - } - - public function getTitle() - { - return 'escaped!'; - } - - public function getTitles() - { - return array(1, 2, 'escaped!'); - } -} - -$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'); diff --git a/tests/unit/Symfony/Components/OutputEscaper/SafeDecoratorTest.php b/tests/unit/Symfony/Components/OutputEscaper/SafeDecoratorTest.php deleted file mode 100644 index 6a543df25e28f..0000000000000 --- a/tests/unit/Symfony/Components/OutputEscaper/SafeDecoratorTest.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * 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\OutputEscaper\SafeDecorator; - -$t = new LimeTest(13); - -// ->getValue() -$t->diag('->getValue()'); -$safe = new SafeDecorator('foo'); -$t->is($safe->getValue(), 'foo', '->getValue() returns the embedded value'); - -// ->__set() ->__get() -$t->diag('->__set() ->__get()'); - -class TestClass1 -{ - public $foo = 'bar'; -} - -$safe = new SafeDecorator(new TestClass1()); - -$t->is($safe->foo, 'bar', '->__get() returns the object parameter'); -$safe->foo = 'baz'; -$t->is($safe->foo, 'baz', '->__set() sets the object parameter'); - -// ->__call() -$t->diag('->__call()'); - -class TestClass2 -{ - public function doSomething() - { - return 'ok'; - } -} - -$safe = new SafeDecorator(new TestClass2()); -$t->is($safe->doSomething(), 'ok', '->__call() invokes the embedded method'); - -// ->__isset() ->__unset() -$t->diag('->__isset() ->__unset()'); - -class TestClass3 -{ - public - $boolValue = true, - $nullValue = null; -} - -$safe = new SafeDecorator(new TestClass3()); - -$t->is(isset($safe->boolValue), true, '->__isset() returns true if the property is not null'); -$t->is(isset($safe->nullValue), false, '->__isset() returns false if the property is null'); -$t->is(isset($safe->undefinedValue), false, '->__isset() returns false if the property does not exist'); - -unset($safe->boolValue); -$t->is(isset($safe->boolValue), false, '->__unset() unsets the embedded property'); - -// Iterator -$t->diag('Iterator'); - -$input = array('one' => 1, 'two' => 2, 'three' => 3, 'children' => array(1, 2, 3)); -$output = array(); - -$safe = new SafeDecorator($input); -foreach ($safe as $key => $value) -{ - $output[$key] = $value; -} -$t->same($output, $input, '"Iterator" implementation imitates an array'); - -// ArrayAccess -$t->diag('ArrayAccess'); - -$safe = new SafeDecorator(array('foo' => 'bar')); - -$t->is($safe['foo'], 'bar', '"ArrayAccess" implementation returns a value from the embedded array'); -$safe['foo'] = 'baz'; -$t->is($safe['foo'], 'baz', '"ArrayAccess" implementation sets a value on the embedded array'); -$t->is(isset($safe['foo']), true, '"ArrayAccess" checks if a value is set on the embedded array'); -unset($safe['foo']); -$t->is(isset($safe['foo']), false, '"ArrayAccess" unsets a value on the embedded array'); diff --git a/tests/unit/Symfony/Components/Yaml/DumperTest.php b/tests/unit/Symfony/Components/Yaml/DumperTest.php deleted file mode 100644 index bdb7514e42517..0000000000000 --- a/tests/unit/Symfony/Components/Yaml/DumperTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * 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\Parser; -use Symfony\Components\Yaml\Dumper; - -Yaml::setSpecVersion('1.1'); - -$t = new LimeTest(151); - -$parser = new Parser(); -$dumper = new Dumper(); - -$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['dump_skip']) && $test['dump_skip']) - { - continue; - } - else if (isset($test['todo']) && $test['todo']) - { - $t->todo($test['test']); - } - else - { - $expected = eval('return '.trim($test['php']).';'); - - $t->is($parser->parse($dumper->dump($expected, 10)), $expected, $test['test']); - } - } -} - -// inline level -$array = array( - '' => 'bar', - 'foo' => '#bar', - 'foo\'bar' => array(), - 'bar' => array(1, 'foo'), - 'foobar' => array( - 'foo' => 'bar', - 'bar' => array(1, 'foo'), - 'foobar' => array( - 'foo' => 'bar', - 'bar' => array(1, 'foo'), - ), - ), -); - -$expected = <<is($dumper->dump($array, -10), $expected, '->dump() takes an inline level argument'); -$t->is($dumper->dump($array, 0), $expected, '->dump() takes an inline level argument'); - -$expected = <<is($dumper->dump($array, 1), $expected, '->dump() takes an inline level argument'); - -$expected = <<is($dumper->dump($array, 2), $expected, '->dump() takes an inline level argument'); - -$expected = <<is($dumper->dump($array, 3), $expected, '->dump() takes an inline level argument'); - -$expected = <<is($dumper->dump($array, 4), $expected, '->dump() takes an inline level argument'); -$t->is($dumper->dump($array, 10), $expected, '->dump() takes an inline level argument'); - -// objects -$t->diag('Objects support'); -class A -{ - public $a = 'foo'; -} -$a = array('foo' => new A(), 'bar' => 1); -$t->is($dumper->dump($a), '{ foo: !!php/object:O:1:"A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', '->dump() is able to dump objects'); diff --git a/tests/unit/Symfony/Components/Yaml/InlineTest.php b/tests/unit/Symfony/Components/Yaml/InlineTest.php deleted file mode 100644 index 3a591c8f29339..0000000000000 --- a/tests/unit/Symfony/Components/Yaml/InlineTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * 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' => 12.30e+02, - '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\'', - - // sequences - // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon - '[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'), - - // mappings - '{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'), - - // nested sequences and mappings - '[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' => 12.30e+02, - '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\'', - - // sequences - '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), - '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), - - // mappings - '{ 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'), - - // nested sequences and mappings - '[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) - { - continue; - } - - $t->is(Inline::load(Inline::dump($value)), $value, 'check consistency'); -} diff --git a/tests/unit/Symfony/Components/Yaml/ParserTest.php b/tests/unit/Symfony/Components/Yaml/ParserTest.php deleted file mode 100644 index b5b8c7f668194..0000000000000 --- a/tests/unit/Symfony/Components/Yaml/ParserTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * 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\Parser; -use Symfony\Components\Yaml\ParserException; - -Yaml::setSpecVersion('1.1'); - -$t = new LimeTest(151); - -$parser = new Parser(); - -$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 bar", - "foo:\n bar", - "foo:\n bar", - "foo:\n 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'); -class A -{ - public $a = 'foo'; -} -$a = array('foo' => new A(), 'bar' => 1); -$t->is($parser->parse(<<parse() is able to dump objects'); From 26723872ba1b0af4ffd4e06afa56b93940419e27 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Mar 2010 22:26:21 +0800 Subject: [PATCH 12/54] finished the conversions of unit tests to PHPUnit --- src/Symfony/Components/Templating/Engine.php | 1 + .../Components/Templating/EngineTest.php | 206 ++++++++ .../Templating/Helper/AssetsTest.php | 98 ++++ .../Templating/Helper/HelperTest.php | 34 ++ .../Helper/JavascriptsHelperTest.php | 44 ++ .../Templating/Helper/SlotsHelperTest.php | 84 ++++ .../Helper/StylesheetsHelperTest.php | 44 ++ .../Templating/Loader/CacheLoaderTest.php | 103 ++++ .../Templating/Loader/ChainLoaderTest.php | 61 +++ .../Loader/FilesystemLoaderTest.php | 86 ++++ .../Templating/Loader/LoaderTest.php | 22 +- .../Templating/Renderer/PhpRendererTest.php | 33 ++ .../Templating/Renderer/RendererTest.php | 28 +- .../Templating/Storage/FileStorageTest.php | 28 ++ .../Templating/Storage/StorageTest.php | 39 ++ .../Templating/Storage/StringStorageTest.php | 28 ++ tests/bin/prove.php | 28 -- .../lib/vendor/lime/LimeAnnotationSupport.php | 196 -------- .../lime/LimeAssertionFailedException.php | 62 --- tests/lib/vendor/lime/LimeAutoloader.php | 238 --------- tests/lib/vendor/lime/LimeColorizer.php | 196 -------- tests/lib/vendor/lime/LimeCoverage.php | 250 ---------- tests/lib/vendor/lime/LimeError.php | 162 ------ .../vendor/lime/LimeExceptionExpectation.php | 41 -- tests/lib/vendor/lime/LimePrinter.php | 127 ----- tests/lib/vendor/lime/LimeRegistration.php | 96 ---- tests/lib/vendor/lime/LimeTest.php | 435 ----------------- tests/lib/vendor/lime/LimeTestAnalyzer.php | 97 ---- tests/lib/vendor/lime/LimeTestCase.php | 59 --- tests/lib/vendor/lime/LimeTestRunner.php | 217 -------- tests/lib/vendor/lime/LimeTestSuite.php | 114 ----- tests/lib/vendor/lime/LimeTools.php | 43 -- tests/lib/vendor/lime/LimeTrace.php | 43 -- .../vendor/lime/constraint/LimeConstraint.php | 34 -- .../constraint/LimeConstraintContains.php | 37 -- .../constraint/LimeConstraintContainsNot.php | 37 -- .../constraint/LimeConstraintException.php | 23 - .../constraint/LimeConstraintGreaterThan.php | 37 -- .../LimeConstraintGreaterThanEqual.php | 37 -- .../constraint/LimeConstraintInterface.php | 32 -- .../lime/constraint/LimeConstraintIs.php | 37 -- .../lime/constraint/LimeConstraintIsNot.php | 37 -- .../constraint/LimeConstraintLessThan.php | 37 -- .../LimeConstraintLessThanEqual.php | 37 -- .../lime/constraint/LimeConstraintLike.php | 37 -- .../lime/constraint/LimeConstraintNotSame.php | 37 -- .../lime/constraint/LimeConstraintSame.php | 37 -- .../lime/constraint/LimeConstraintUnlike.php | 37 -- tests/lib/vendor/lime/lexer/LimeLexer.php | 402 --------------- .../lime/lexer/LimeLexerAnnotationAware.php | 213 -------- .../vendor/lime/lexer/LimeLexerCodeLines.php | 100 ---- .../lime/lexer/LimeLexerTestVariable.php | 89 ---- .../lexer/LimeLexerTransformAnnotations.php | 239 --------- .../vendor/lime/lexer/LimeLexerVariables.php | 65 --- tests/lib/vendor/lime/lime.php | 393 --------------- tests/lib/vendor/lime/mock/LimeMock.php | 345 ------------- .../vendor/lime/mock/LimeMockBehaviour.php | 140 ------ .../lime/mock/LimeMockBehaviourInterface.php | 84 ---- .../vendor/lime/mock/LimeMockException.php | 26 - .../vendor/lime/mock/LimeMockInterface.php | 73 --- .../vendor/lime/mock/LimeMockInvocation.php | 134 ----- .../lime/mock/LimeMockInvocationException.php | 38 -- .../mock/LimeMockInvocationExceptionStack.php | 67 --- .../mock/LimeMockInvocationExpectation.php | 462 ------------------ tests/lib/vendor/lime/mock/LimeMockMethod.php | 57 --- .../lime/mock/LimeMockMethodInterface.php | 8 - .../lime/mock/LimeMockOrderedBehaviour.php | 51 -- .../vendor/lime/mock/LimeMockRecordState.php | 99 ---- .../vendor/lime/mock/LimeMockReplayState.php | 75 --- .../lime/mock/LimeMockStateInterface.php | 56 --- .../lib/vendor/lime/mock/LimeMockTemplate.php | 57 --- .../lime/mock/LimeMockUnorderedBehaviour.php | 45 -- .../matcher/LimeMockInvocationMatcherAny.php | 59 --- .../LimeMockInvocationMatcherAtLeastOnce.php | 63 --- .../LimeMockInvocationMatcherBetween.php | 94 ---- .../LimeMockInvocationMatcherException.php | 27 - .../LimeMockInvocationMatcherInterface.php | 77 --- .../LimeMockInvocationMatcherParameter.php | 288 ----------- .../LimeMockInvocationMatcherTimes.php | 90 ---- .../lime/mock/template/mocked_class.tpl | 93 ---- .../vendor/lime/output/LimeOutputArray.php | 222 --------- .../lime/output/LimeOutputConsoleSummary.php | 275 ----------- .../vendor/lime/output/LimeOutputCoverage.php | 47 -- .../vendor/lime/output/LimeOutputFactory.php | 47 -- .../lime/output/LimeOutputInterface.php | 131 ----- .../lib/vendor/lime/output/LimeOutputNone.php | 41 -- .../vendor/lime/output/LimeOutputProxy.php | 110 ----- .../lib/vendor/lime/output/LimeOutputRaw.php | 96 ---- .../vendor/lime/output/LimeOutputResult.php | 277 ----------- .../lib/vendor/lime/output/LimeOutputTap.php | 275 ----------- .../lib/vendor/lime/output/LimeOutputXml.php | 139 ------ tests/lib/vendor/lime/parser/LimeParser.php | 43 -- .../lime/parser/LimeParserInterface.php | 8 - .../lib/vendor/lime/parser/LimeParserRaw.php | 77 --- .../lib/vendor/lime/parser/LimeParserTap.php | 81 --- tests/lib/vendor/lime/shell/LimeShell.php | 123 ----- tests/lib/vendor/lime/shell/LimeShellCode.php | 12 - .../vendor/lime/shell/LimeShellCommand.php | 67 --- .../vendor/lime/shell/LimeShellProcess.php | 35 -- tests/lib/vendor/lime/tester/LimeTester.php | 111 ----- .../vendor/lime/tester/LimeTesterArray.php | 293 ----------- .../vendor/lime/tester/LimeTesterDouble.php | 83 ---- .../lime/tester/LimeTesterException.php | 24 - .../vendor/lime/tester/LimeTesterFactory.php | 113 ----- .../vendor/lime/tester/LimeTesterInteger.php | 17 - .../lime/tester/LimeTesterInterface.php | 40 -- .../vendor/lime/tester/LimeTesterObject.php | 121 ----- .../vendor/lime/tester/LimeTesterResource.php | 48 -- .../vendor/lime/tester/LimeTesterScalar.php | 116 ----- .../vendor/lime/tester/LimeTesterString.php | 51 -- .../Components/Templating/EngineTest.php | 239 --------- .../Templating/Helper/AssetsTest.php | 90 ---- .../Templating/Helper/HelperSetTest.php | 52 -- .../Templating/Helper/HelperTest.php | 31 -- .../Helper/JavascriptsHelperTest.php | 47 -- .../Helper/StylesheetsHelperTest.php | 47 -- .../Templating/Loader/CacheLoaderTest.php | 99 ---- .../Templating/Loader/ChainLoaderTest.php | 51 -- .../Loader/FilesystemLoaderTest.php | 73 --- .../Templating/Renderer/PhpRendererTest.php | 30 -- .../Templating/Storage/FileStorageTest.php | 25 - .../Templating/Storage/StorageTest.php | 35 -- .../Templating/Storage/StringStorageTest.php | 26 - tests/unit/bootstrap.php | 17 - 124 files changed, 916 insertions(+), 11054 deletions(-) create mode 100644 tests/Symfony/Tests/Components/Templating/EngineTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php rename tests/{unit/Symfony => Symfony/Tests}/Components/Templating/Loader/LoaderTest.php (54%) create mode 100644 tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php rename tests/{unit/Symfony => Symfony/Tests}/Components/Templating/Renderer/RendererTest.php (58%) create mode 100644 tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php create mode 100644 tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php delete mode 100644 tests/bin/prove.php delete mode 100644 tests/lib/vendor/lime/LimeAnnotationSupport.php delete mode 100644 tests/lib/vendor/lime/LimeAssertionFailedException.php delete mode 100644 tests/lib/vendor/lime/LimeAutoloader.php delete mode 100644 tests/lib/vendor/lime/LimeColorizer.php delete mode 100644 tests/lib/vendor/lime/LimeCoverage.php delete mode 100644 tests/lib/vendor/lime/LimeError.php delete mode 100644 tests/lib/vendor/lime/LimeExceptionExpectation.php delete mode 100644 tests/lib/vendor/lime/LimePrinter.php delete mode 100644 tests/lib/vendor/lime/LimeRegistration.php delete mode 100644 tests/lib/vendor/lime/LimeTest.php delete mode 100644 tests/lib/vendor/lime/LimeTestAnalyzer.php delete mode 100644 tests/lib/vendor/lime/LimeTestCase.php delete mode 100644 tests/lib/vendor/lime/LimeTestRunner.php delete mode 100644 tests/lib/vendor/lime/LimeTestSuite.php delete mode 100644 tests/lib/vendor/lime/LimeTools.php delete mode 100644 tests/lib/vendor/lime/LimeTrace.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraint.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintContains.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintContainsNot.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintException.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintGreaterThan.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintGreaterThanEqual.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintInterface.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintIs.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintIsNot.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintLessThan.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintLessThanEqual.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintLike.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintNotSame.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintSame.php delete mode 100644 tests/lib/vendor/lime/constraint/LimeConstraintUnlike.php delete mode 100644 tests/lib/vendor/lime/lexer/LimeLexer.php delete mode 100644 tests/lib/vendor/lime/lexer/LimeLexerAnnotationAware.php delete mode 100644 tests/lib/vendor/lime/lexer/LimeLexerCodeLines.php delete mode 100644 tests/lib/vendor/lime/lexer/LimeLexerTestVariable.php delete mode 100644 tests/lib/vendor/lime/lexer/LimeLexerTransformAnnotations.php delete mode 100644 tests/lib/vendor/lime/lexer/LimeLexerVariables.php delete mode 100644 tests/lib/vendor/lime/lime.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMock.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockBehaviour.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockBehaviourInterface.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockException.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockInterface.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockInvocation.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockInvocationException.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockInvocationExceptionStack.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockInvocationExpectation.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockMethod.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockMethodInterface.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockOrderedBehaviour.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockRecordState.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockReplayState.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockStateInterface.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockTemplate.php delete mode 100644 tests/lib/vendor/lime/mock/LimeMockUnorderedBehaviour.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAny.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAtLeastOnce.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherBetween.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherException.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherInterface.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherParameter.php delete mode 100644 tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherTimes.php delete mode 100644 tests/lib/vendor/lime/mock/template/mocked_class.tpl delete mode 100644 tests/lib/vendor/lime/output/LimeOutputArray.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputConsoleSummary.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputCoverage.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputFactory.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputInterface.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputNone.php delete mode 100755 tests/lib/vendor/lime/output/LimeOutputProxy.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputRaw.php delete mode 100755 tests/lib/vendor/lime/output/LimeOutputResult.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputTap.php delete mode 100644 tests/lib/vendor/lime/output/LimeOutputXml.php delete mode 100644 tests/lib/vendor/lime/parser/LimeParser.php delete mode 100644 tests/lib/vendor/lime/parser/LimeParserInterface.php delete mode 100644 tests/lib/vendor/lime/parser/LimeParserRaw.php delete mode 100644 tests/lib/vendor/lime/parser/LimeParserTap.php delete mode 100644 tests/lib/vendor/lime/shell/LimeShell.php delete mode 100644 tests/lib/vendor/lime/shell/LimeShellCode.php delete mode 100644 tests/lib/vendor/lime/shell/LimeShellCommand.php delete mode 100644 tests/lib/vendor/lime/shell/LimeShellProcess.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTester.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterArray.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterDouble.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterException.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterFactory.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterInteger.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterInterface.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterObject.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterResource.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterScalar.php delete mode 100644 tests/lib/vendor/lime/tester/LimeTesterString.php delete mode 100644 tests/unit/Symfony/Components/Templating/EngineTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Helper/AssetsTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Helper/HelperSetTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Helper/HelperTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Helper/JavascriptsHelperTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Helper/StylesheetsHelperTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Loader/CacheLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Loader/ChainLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Loader/FilesystemLoaderTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Renderer/PhpRendererTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Storage/FileStorageTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Storage/StorageTest.php delete mode 100644 tests/unit/Symfony/Components/Templating/Storage/StringStorageTest.php delete mode 100644 tests/unit/bootstrap.php diff --git a/src/Symfony/Components/Templating/Engine.php b/src/Symfony/Components/Templating/Engine.php index 0baf4485d97a9..0e33de9642325 100644 --- a/src/Symfony/Components/Templating/Engine.php +++ b/src/Symfony/Components/Templating/Engine.php @@ -32,6 +32,7 @@ class Engine protected $parents; protected $stack; protected $charset; + protected $cache; /** * Constructor. diff --git a/tests/Symfony/Tests/Components/Templating/EngineTest.php b/tests/Symfony/Tests/Components/Templating/EngineTest.php new file mode 100644 index 0000000000000..7f2629229f455 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/EngineTest.php @@ -0,0 +1,206 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating; + +require_once __DIR__.'/../../bootstrap.php'; + +require_once __DIR__.'/../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php'; + +use Symfony\Components\Templating\Engine; +use Symfony\Components\Templating\Loader\Loader; +use Symfony\Components\Templating\Loader\CompilableLoaderInterface; +use Symfony\Components\Templating\Renderer\Renderer; +use Symfony\Components\Templating\Renderer\PhpRenderer; +use Symfony\Components\Templating\Storage\Storage; +use Symfony\Components\Templating\Storage\StringStorage; +use Symfony\Components\Templating\Helper\SlotsHelper; + +class EngineTest extends \PHPUnit_Framework_TestCase +{ + static protected $loader, $renderer; + + static public function setUpBeforeClass() + { + self::$loader = new ProjectTemplateLoader(); + self::$renderer = new ProjectTemplateRenderer(); + } + + public function testConstructor() + { + $engine = new ProjectTemplateEngine(self::$loader); + $this->assertEquals($engine->getLoader(), self::$loader, '__construct() takes a loader instance as its second first argument'); + $this->assertEquals(array_keys($engine->getRenderers()), array('php'), '__construct() automatically registers a PHP renderer if none is given'); + + $engine = new ProjectTemplateEngine(self::$loader, array('foo' => self::$renderer)); + $this->assertEquals(array_keys($engine->getRenderers()), array('foo', 'php'), '__construct() takes an array of renderers as its third argument'); + $this->assertTrue(self::$renderer->getEngine() === $engine, '__construct() registers itself on all renderers'); + + $engine = new ProjectTemplateEngine(self::$loader, array('php' => self::$renderer)); + $this->assertTrue($engine->getRenderers() === array('php' => self::$renderer), '__construct() can overridde the default PHP renderer'); + } + + public function testMagicGet() + { + $engine = new ProjectTemplateEngine(self::$loader); + $engine->set($helper = new \SimpleHelper('bar'), 'foo'); + $this->assertEquals($engine->foo, $helper, '->__get() returns the value of a helper'); + + try + { + $engine->bar; + $this->fail('->__get() throws an InvalidArgumentException if the helper is not defined'); + } + catch (\InvalidArgumentException $e) + { + } + } + + public function testGetSetHas() + { + $engine = new ProjectTemplateEngine(self::$loader); + $foo = new \SimpleHelper('foo'); + $engine->set($foo); + $this->assertEquals($engine->get('foo'), $foo, '->set() sets a helper'); + + $engine->set($foo, 'bar'); + $this->assertEquals($engine->get('bar'), $foo, '->set() takes an alias as a second argument'); + + try + { + $engine->get('foobar'); + $this->fail('->get() throws an InvalidArgumentException if the helper is not defined'); + } + catch (\InvalidArgumentException $e) + { + } + + $this->assertTrue($engine->has('foo'), '->has() returns true if the helper exists'); + $this->assertTrue(!$engine->has('foobar'), '->has() returns false if the helper does not exist'); + } + + public function testExtendRender() + { + $engine = new ProjectTemplateEngine(self::$loader, array(), array(new SlotsHelper())); + try + { + $engine->render('name'); + $this->fail('->render() throws an InvalidArgumentException if the template does not exist'); + } + catch (\InvalidArgumentException $e) + { + } + + try + { + self::$loader->setTemplate('name.foo', 'foo'); + $engine->render('foo:name'); + $this->fail('->render() throws an InvalidArgumentException if no renderer is registered for the given renderer'); + } + catch (\InvalidArgumentException $e) + { + } + + $engine = new ProjectTemplateEngine(self::$loader, array(), array(new SlotsHelper())); + $engine->set(new \SimpleHelper('bar')); + self::$loader->setTemplate('foo.php', 'extend("layout"); echo $view->foo.$foo ?>'); + self::$loader->setTemplate('layout.php', '-slots->get("_content") ?>-'); + $this->assertEquals($engine->render('foo', array('foo' => 'foo')), '-barfoo-', '->render() uses the decorator to decorate the template'); + + $engine = new ProjectTemplateEngine(self::$loader, array(), array(new SlotsHelper())); + $engine->set(new \SimpleHelper('bar')); + self::$loader->setTemplate('bar.php', 'bar'); + self::$loader->setTemplate('foo.php', 'extend("layout"); echo $foo ?>'); + self::$loader->setTemplate('layout.php', 'render("bar") ?>-slots->get("_content") ?>-'); + $this->assertEquals($engine->render('foo', array('foo' => 'foo', 'bar' => 'bar')), 'bar-foo-', '->render() supports render() calls in templates'); + + // compilable templates + $engine = new ProjectTemplateEngine(new CompilableTemplateLoader(), array('foo' => new FooTemplateRenderer())); + $this->assertEquals($engine->render('index'), 'foo', '->load() takes into account the renderer embedded in the Storage instance if not null'); + } + + public function testEscape() + { + $engine = new ProjectTemplateEngine(self::$loader); + $this->assertEquals($engine->escape('
'), '<br />', '->escape() escapes strings'); + $this->assertEquals($engine->escape($foo = new \stdClass()), $foo, '->escape() does nothing on non strings'); + } + + public function testGetSetCharset() + { + $engine = new ProjectTemplateEngine(self::$loader); + $this->assertEquals($engine->getCharset(), 'UTF-8', '->getCharset() returns UTF-8 by default'); + $engine->setCharset('ISO-8859-1'); + $this->assertEquals($engine->getCharset(), 'ISO-8859-1', '->setCharset() changes the default charset to use'); + } +} + +class ProjectTemplateEngine extends Engine +{ + public function getLoader() + { + return $this->loader; + } + + public function getRenderers() + { + return $this->renderers; + } +} + +class ProjectTemplateRenderer extends PhpRenderer +{ + public function getEngine() + { + return $this->engine; + } +} + +class ProjectTemplateLoader extends Loader +{ + public $templates = array(); + + public function setTemplate($name, $template) + { + $this->templates[$name] = $template; + } + + public function load($template, array $options = array()) + { + if (isset($this->templates[$template.'.'.$options['renderer']])) + { + return new StringStorage($this->templates[$template.'.'.$options['renderer']]); + } + + return false; + } +} + +class CompilableTemplateLoader extends Loader implements CompilableLoaderInterface +{ + public function load($template, array $options = array()) + { + return new StringStorage($template, 'foo'); + } + + public function compile($template) + { + return 'COMPILED'; + } +} + +class FooTemplateRenderer extends Renderer +{ + public function evaluate(Storage $template, array $parameters = array()) + { + return 'foo'; + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php new file mode 100644 index 0000000000000..16f135ddfad83 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Helper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Helper\AssetsHelper; + +class AssetsHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $helper = new AssetsHelper('foo', 'http://www.example.com', 'abcd'); + $this->assertEquals($helper->getBasePath(), '/foo/', '__construct() takes a base path as its first argument'); + $this->assertEquals($helper->getBaseURLs(), array('http://www.example.com'), '__construct() takes a base URL as its second argument'); + $this->assertEquals($helper->getVersion(), 'abcd', '__construct() takes a version as its thrid argument'); + } + + public function testGetSetBasePath() + { + $helper = new AssetsHelper(); + $helper->setBasePath('foo/'); + $this->assertEquals($helper->getBasePath(), '/foo/', '->setBasePath() prepends a / if needed'); + $helper->setBasePath('/foo'); + $this->assertEquals($helper->getBasePath(), '/foo/', '->setBasePath() appends a / is needed'); + $helper->setBasePath(''); + $this->assertEquals($helper->getBasePath(), '/', '->setBasePath() returns / if no base path is defined'); + $helper->setBasePath('0'); + $this->assertEquals($helper->getBasePath(), '/0/', '->setBasePath() returns /0/ if 0 is given'); + } + + public function testGetSetVersion() + { + $helper = new AssetsHelper(); + $helper->setVersion('foo'); + $this->assertEquals($helper->getVersion(), 'foo', '->setVersion() sets the version'); + } + + public function testSetGetBaseURLs() + { + $helper = new AssetsHelper(); + $helper->setBaseURLs('http://www.example.com/'); + $this->assertEquals($helper->getBaseURLs(), array('http://www.example.com'), '->setBaseURLs() removes the / at the of an absolute base path'); + $helper->setBaseURLs(array('http://www1.example.com/', 'http://www2.example.com/')); + $URLs = array(); + for ($i = 0; $i < 20; $i++) + { + $URLs[] = $helper->getBaseURL($i); + } + $URLs = array_values(array_unique($URLs)); + sort($URLs); + $this->assertEquals($URLs, array('http://www1.example.com', 'http://www2.example.com'), '->getBaseURL() returns a random base URL if several are given'); + $helper->setBaseURLs(''); + $this->assertEquals($helper->getBaseURL(1), '', '->getBaseURL() returns an empty string if no base URL exist'); + } + + public function testGetUrl() + { + $helper = new AssetsHelper(); + $this->assertEquals($helper->getUrl('http://example.com/foo.js'), 'http://example.com/foo.js', '->getUrl() does nothing if an absolute URL is given'); + + $helper = new AssetsHelper(); + $this->assertEquals($helper->getUrl('foo.js'), '/foo.js', '->getUrl() appends a / on relative paths'); + $this->assertEquals($helper->getUrl('/foo.js'), '/foo.js', '->getUrl() does nothing on absolute paths'); + + $helper = new AssetsHelper('/foo'); + $this->assertEquals($helper->getUrl('foo.js'), '/foo/foo.js', '->getUrl() appends the basePath on relative paths'); + $this->assertEquals($helper->getUrl('/foo.js'), '/foo.js', '->getUrl() does not append the basePath on absolute paths'); + + $helper = new AssetsHelper(null, 'http://assets.example.com/'); + $this->assertEquals($helper->getUrl('foo.js'), 'http://assets.example.com/foo.js', '->getUrl() prepends the base URL'); + $this->assertEquals($helper->getUrl('/foo.js'), 'http://assets.example.com/foo.js', '->getUrl() prepends the base URL'); + + $helper = new AssetsHelper(null, 'http://www.example.com/foo'); + $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL with a path'); + $this->assertEquals($helper->getUrl('/foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL with a path'); + + $helper = new AssetsHelper('/foo', 'http://www.example.com/'); + $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL and the base path if defined'); + $this->assertEquals($helper->getUrl('/foo.js'), 'http://www.example.com/foo.js', '->getUrl() prepends the base URL but not the base path on absolute paths'); + + $helper = new AssetsHelper('/bar', 'http://www.example.com/foo'); + $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/bar/foo.js', '->getUrl() prepends the base URL and the base path if defined'); + $this->assertEquals($helper->getUrl('/foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL but not the base path on absolute paths'); + + $helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd'); + $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/bar/foo.js?abcd', '->getUrl() appends the version if defined'); + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php new file mode 100644 index 0000000000000..679aff7cdf4e5 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Helper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Helper\Helper; + +class HelperTest extends \PHPUnit_Framework_TestCase +{ + public function testGetSetCharset() + { + $helper = new ProjectTemplateHelper(); + $helper->setCharset('ISO-8859-1'); + $this->assertTrue('ISO-8859-1' === $helper->getCharset(), '->setCharset() sets the charset set related to this helper'); + } +} + +class ProjectTemplateHelper extends Helper +{ + public function getName() + { + return 'foo'; + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php new file mode 100644 index 0000000000000..667bb88c473a3 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Helper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Helper\AssetsHelper; +use Symfony\Components\Templating\Helper\JavascriptsHelper; +use Symfony\Components\Templating\Loader\FilesystemLoader; + +class JavascriptsHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testAdd() + { + $assetHelper = new AssetsHelper(); + $helper = new JavascriptsHelper($assetHelper); + $helper->add('foo'); + $this->assertEquals($helper->get(), array('/foo' => array()), '->add() adds a JavaScript'); + $helper->add('/foo'); + $this->assertEquals($helper->get(), array('/foo' => array()), '->add() does not add the same JavaScript twice'); + $helper = new JavascriptsHelper($assetHelper); + $assetHelper->setBaseURLs('http://assets.example.com/'); + $helper->add('foo'); + $this->assertEquals($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the JavaScript to a public path'); + } + + public function testMagicToString() + { + $assetHelper = new AssetsHelper(); + $assetHelper->setBaseURLs(''); + $helper = new JavascriptsHelper($assetHelper); + $helper->add('foo', array('class' => 'ba>')); + $this->assertEquals($helper->__toString(), ''."\n", '->__toString() converts the JavaScript configuration to HTML'); + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php new file mode 100644 index 0000000000000..4d1f8ef2aad41 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Helper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Helper\SlotsHelper; + +class SlotsHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testHasGetSet() + { + $helper = new SlotsHelper(); + $helper->set('foo', 'bar'); + $this->assertEquals($helper->get('foo'), 'bar', '->set() sets a slot value'); + $this->assertEquals($helper->get('bar', 'bar'), 'bar', '->get() takes a default value to return if the slot does not exist'); + + $this->assertTrue($helper->has('foo'), '->has() returns true if the slot exists'); + $this->assertTrue(!$helper->has('bar'), '->has() returns false if the slot does not exist'); + } + + public function testOutput() + { + $helper = new SlotsHelper(); + $helper->set('foo', 'bar'); + ob_start(); + $ret = $helper->output('foo'); + $output = ob_get_clean(); + $this->assertEquals($output, 'bar', '->output() outputs the content of a slot'); + $this->assertEquals($ret, true, '->output() returns true if the slot exists'); + + ob_start(); + $ret = $helper->output('bar', 'bar'); + $output = ob_get_clean(); + $this->assertEquals($output, 'bar', '->output() takes a default value to return if the slot does not exist'); + $this->assertEquals($ret, true, '->output() returns true if the slot does not exist but a default value is provided'); + + ob_start(); + $ret = $helper->output('bar'); + $output = ob_get_clean(); + $this->assertEquals($output, '', '->output() outputs nothing if the slot does not exist'); + $this->assertEquals($ret, false, '->output() returns false if the slot does not exist'); + } + + public function testStartStop() + { + $helper = new SlotsHelper(); + $helper->start('bar'); + echo 'foo'; + $helper->stop(); + $this->assertEquals($helper->get('bar'), 'foo', '->start() starts a slot'); + $this->assertTrue($helper->has('bar'), '->starts() starts a slot'); + + $helper->start('bar'); + try + { + $helper->start('bar'); + $helper->stop(); + $this->fail('->start() throws an InvalidArgumentException if a slot with the same name is already started'); + } + catch (\InvalidArgumentException $e) + { + $helper->stop(); + } + + try + { + $helper->stop(); + $this->fail('->stop() throws an LogicException if no slot is started'); + } + catch (\LogicException $e) + { + } + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php new file mode 100644 index 0000000000000..16fd096da0fb7 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Helper; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Helper\AssetsHelper; +use Symfony\Components\Templating\Helper\StylesheetsHelper; +use Symfony\Components\Templating\Loader\FilesystemLoader; + +class StylesheetsHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testAdd() + { + $assetHelper = new AssetsHelper(); + $helper = new StylesheetsHelper($assetHelper); + $helper->add('foo'); + $this->assertEquals($helper->get(), array('/foo' => array()), '->add() adds a stylesheet'); + $helper->add('/foo'); + $this->assertEquals($helper->get(), array('/foo' => array()), '->add() does not add the same stylesheet twice'); + $helper = new StylesheetsHelper($assetHelper); + $assetHelper->setBaseURLs('http://assets.example.com/'); + $helper->add('foo'); + $this->assertEquals($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the stylesheet to a public path'); + } + + public function testMagicToString() + { + $assetHelper = new AssetsHelper(); + $assetHelper->setBaseURLs(''); + $helper = new StylesheetsHelper($assetHelper); + $helper->add('foo', array('media' => 'ba>')); + $this->assertEquals($helper->__toString(), ''."\n", '->__toString() converts the stylesheet configuration to HTML'); + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php new file mode 100644 index 0000000000000..358a02563d99c --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; + +use Symfony\Components\Templating\Loader\Loader; +use Symfony\Components\Templating\Loader\CacheLoader; +use Symfony\Components\Templating\Loader\CompilableLoaderInterface; +use Symfony\Components\Templating\Storage\StringStorage; + +class CacheLoaderTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), sys_get_temp_dir()); + $this->assertTrue($loader->getLoader() === $varLoader, '__construct() takes a template loader as its first argument'); + $this->assertEquals($loader->getDir(), sys_get_temp_dir(), '__construct() takes a directory where to store the cache as its second argument'); + } + + public function testLoad() + { + $dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999); + mkdir($dir, 0777, true); + + $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir); + $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); + $this->assertTrue($loader->load('foo') === false, '->load() returns false if the embed loader is not able to load the template'); + $loader->load('index'); + $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); + $loader->load('index'); + $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); + + // load() template compilation + $dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999); + mkdir($dir, 0777, true); + + $loader = new ProjectTemplateLoader(new CompilableTemplateLoader(), $dir); + $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); + $template = $loader->load('special', array('renderer' => 'comp')); + $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); + $this->assertEquals($template->getRenderer(), 'php', '->load() changes the renderer to php if the template is compilable'); + + $template = $loader->load('special', array('renderer' => 'comp')); + $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); + $this->assertEquals($template->getRenderer(), 'php', '->load() changes the renderer to php if the template is compilable'); + } +} + +class ProjectTemplateLoader extends CacheLoader +{ + public function getDir() + { + return $this->dir; + } + + public function getLoader() + { + return $this->loader; + } +} + +class ProjectTemplateLoaderVar extends Loader +{ + public function getIndexTemplate() + { + return 'Hello World'; + } + + public function getSpecialTemplate() + { + return 'Hello {{ name }}'; + } + + public function load($template, array $options = array()) + { + if (method_exists($this, $method = 'get'.ucfirst($template).'Template')) + { + return new StringStorage($this->$method()); + } + + return false; + } +} + +class CompilableTemplateLoader extends ProjectTemplateLoaderVar implements CompilableLoaderInterface +{ + public function compile($template) + { + return preg_replace('/{{\s*([a-zA-Z0-9_]+)\s*}}/', '', $template); + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php new file mode 100644 index 0000000000000..75e66b46b017a --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; + +use Symfony\Components\Templating\Loader\ChainLoader; +use Symfony\Components\Templating\Loader\FilesystemLoader; +use Symfony\Components\Templating\Storage\FileStorage; + +class ChainLoaderTest extends \PHPUnit_Framework_TestCase +{ + static protected $loader1, $loader2; + + static public function setUpBeforeClass() + { + $fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/'); + self::$loader1 = new FilesystemLoader($fixturesPath.'/null/%name%'); + self::$loader2 = new FilesystemLoader($fixturesPath.'/templates/%name%.%renderer%'); + } + + public function testConstructor() + { + $loader = new ProjectTemplateLoader1(array(self::$loader1, self::$loader2)); + $this->assertEquals($loader->getLoaders(), array(self::$loader1, self::$loader2), '__construct() takes an array of template loaders as its second argument'); + } + + public function testAddLoader() + { + $loader = new ProjectTemplateLoader1(array(self::$loader1)); + $loader->addLoader(self::$loader2); + $this->assertEquals($loader->getLoaders(), array(self::$loader1, self::$loader2), '->addLoader() adds a template loader at the end of the loaders'); + } + + public function testLoad() + { + $loader = new ProjectTemplateLoader1(array(self::$loader1, self::$loader2)); + $this->assertTrue($loader->load('bar') === false, '->load() returns false if the template is not found'); + $this->assertTrue($loader->load('foo', array('renderer' => 'xml')) === false, '->load() returns false if the template does not exists for the given renderer'); + $this->assertTrue($loader->load('foo') instanceof FileStorage, '->load() returns a FileStorage if the template exists'); + } +} + +class ProjectTemplateLoader1 extends ChainLoader +{ + public function getLoaders() + { + return $this->loaders; + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php new file mode 100644 index 0000000000000..0619838990b55 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; + +require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; + +use Symfony\Components\Templating\Loader\FilesystemLoader; +use Symfony\Components\Templating\Storage\FileStorage; + +class FilesystemLoaderTest extends \PHPUnit_Framework_TestCase +{ + static protected $fixturesPath; + + static public function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/'); + } + + public function testConstructor() + { + $pathPattern = self::$fixturesPath.'/templates/%name%.%renderer%'; + $path = self::$fixturesPath.'/templates'; + $loader = new ProjectTemplateLoader2($pathPattern); + $this->assertEquals($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes a path as its second argument'); + $loader = new ProjectTemplateLoader2(array($pathPattern)); + $this->assertEquals($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes an array of paths as its second argument'); + } + + public function testIsAbsolutePath() + { + $this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); + $this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('c:\\\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); + $this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('c:/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); + $this->assertTrue(ProjectTemplateLoader2::isAbsolutePath('\\server\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); + } + + public function testLoad() + { + $pathPattern = self::$fixturesPath.'/templates/%name%.%renderer%'; + $path = self::$fixturesPath.'/templates'; + $loader = new ProjectTemplateLoader2($pathPattern); + $storage = $loader->load($path.'/foo.php'); + $this->assertTrue($storage instanceof FileStorage, '->load() returns a FileStorage if you pass an absolute path'); + $this->assertEquals((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the passed absolute path'); + + $this->assertTrue($loader->load('bar') === false, '->load() returns false if the template is not found'); + + $storage = $loader->load('foo'); + $this->assertTrue($storage instanceof FileStorage, '->load() returns a FileStorage if you pass a relative template that exists'); + $this->assertEquals((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the absolute path of the template'); + + $loader = new ProjectTemplateLoader2($pathPattern); + $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); + $this->assertTrue($loader->load('foo', array('renderer' => 'xml')) === false, '->load() returns false if the template does not exists for the given renderer'); + $this->assertTrue($debugger->hasMessage('Failed loading template'), '->load() logs a "Failed loading template" message if the template is not found'); + + $loader = new ProjectTemplateLoader2(array(self::$fixturesPath.'/null/%name%', $pathPattern)); + $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); + $loader->load('foo'); + $this->assertTrue($debugger->hasMessage('Loaded template file'), '->load() logs a "Loaded template file" message if the template is found'); + } +} + +class ProjectTemplateLoader2 extends FilesystemLoader +{ + public function getTemplatePathPatterns() + { + return $this->templatePathPatterns; + } + + static public function isAbsolutePath($path) + { + return parent::isAbsolutePath($path); + } +} diff --git a/tests/unit/Symfony/Components/Templating/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php similarity index 54% rename from tests/unit/Symfony/Components/Templating/Loader/LoaderTest.php rename to tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php index 5031c6296b4f3..295ecbd71e66f 100644 --- a/tests/unit/Symfony/Components/Templating/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php @@ -9,15 +9,25 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/../../../../bootstrap.php'; +namespace Symfony\Tests\Components\Templating\Loader; + +require_once __DIR__.'/../../../bootstrap.php'; require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; use Symfony\Components\Templating\Loader\Loader; -$t = new LimeTest(1); +class LoaderTest extends \PHPUnit_Framework_TestCase +{ + public function testGetSetDebugger() + { + $loader = new ProjectTemplateLoader4(); + $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); + $this->assertTrue($loader->getDebugger() === $debugger, '->setDebugger() sets the debugger instance'); + } +} -class ProjectTemplateLoader extends Loader +class ProjectTemplateLoader4 extends Loader { public function load($template, array $options = array()) { @@ -28,9 +38,3 @@ public function getDebugger() return $this->debugger; } } - -// ->setDebugger() -$t->diag('->setDebugger()'); -$loader = new ProjectTemplateLoader(); -$loader->setDebugger($debugger = new ProjectTemplateDebugger()); -$t->ok($loader->getDebugger() === $debugger, '->setDebugger() sets the debugger instance'); diff --git a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php new file mode 100644 index 0000000000000..73a35c48deaed --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Renderer; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Renderer\PhpRenderer; +use Symfony\Components\Templating\Storage\Storage; +use Symfony\Components\Templating\Storage\StringStorage; +use Symfony\Components\Templating\Storage\FileStorage; + +class PhpRendererTest extends \PHPUnit_Framework_TestCase +{ + public function testEvaluate() + { + $renderer = new PhpRenderer(); + + $template = new StringStorage(''); + $this->assertEquals($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of StringStorage'); + + $template = new FileStorage(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/templates/foo.php'); + $this->assertEquals($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of FileStorage'); + } +} diff --git a/tests/unit/Symfony/Components/Templating/Renderer/RendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php similarity index 58% rename from tests/unit/Symfony/Components/Templating/Renderer/RendererTest.php rename to tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php index b03cb5515f7f3..fd5c718ad5943 100644 --- a/tests/unit/Symfony/Components/Templating/Renderer/RendererTest.php +++ b/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php @@ -9,7 +9,9 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/../../../../bootstrap.php'; +namespace Symfony\Tests\Components\Templating\Renderer; + +require_once __DIR__.'/../../../bootstrap.php'; require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php'; @@ -18,8 +20,17 @@ use Symfony\Components\Templating\Storage\Storage; use Symfony\Components\Templating\Loader\FilesystemLoader; -$t = new LimeTest(1); - +class RendererTest extends \PHPUnit_Framework_TestCase +{ + public function testSetEngine() + { + $loader = new FilesystemLoader(array(__DIR__.'/fixtures/templates/%name%.%renderer%')); + $engine = new Engine($loader); + $renderer = new ProjectTemplateRenderer(); + $renderer->setEngine($engine); + $this->assertTrue($renderer->getEngine() === $engine, '->setEngine() sets the engine instance tied to this renderer'); + } +} class ProjectTemplateRenderer extends Renderer { public function getEngine() @@ -31,14 +42,3 @@ public function evaluate(Storage $template, array $parameters = array()) { } } - -$loader = new FilesystemLoader(array(__DIR__.'/fixtures/templates/%name%.%renderer%')); -$engine = new Engine($loader); -$engine->set('foo', 'bar'); -$engine->getHelperSet()->set(new SimpleHelper('foo'), 'bar'); - -// ->setEngine() -$t->diag('->setEngine()'); -$renderer = new ProjectTemplateRenderer(); -$renderer->setEngine($engine); -$t->ok($renderer->getEngine() === $engine, '->setEngine() sets the engine instance tied to this renderer'); diff --git a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php new file mode 100644 index 0000000000000..16b1e8877612c --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Storage; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Storage\Storage; +use Symfony\Components\Templating\Storage\FileStorage; + +class FileStorageTest extends \PHPUnit_Framework_TestCase +{ + public function testGetContent() + { + $storage = new FileStorage('foo'); + $this->assertTrue($storage instanceof Storage, 'FileStorage is an instance of Storage'); + $storage = new FileStorage(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/templates/foo.php'); + $this->assertEquals($storage->getContent(), '', '->getContent() returns the content of the template'); + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php new file mode 100644 index 0000000000000..544c468ce0199 --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Storage; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Storage\Storage; +use Symfony\Components\Templating\Renderer\PhpRenderer; + +class StorageTest extends \PHPUnit_Framework_TestCase +{ + public function testMagicToString() + { + $storage = new TestStorage('foo'); + $this->assertEquals((string) $storage, 'foo', '__toString() returns the template name'); + } + + public function testGetRenderer() + { + $storage = new TestStorage('foo', $renderer = new PhpRenderer()); + $this->assertTrue($storage->getRenderer() === $renderer, '->getRenderer() returns the renderer'); + } +} + +class TestStorage extends Storage +{ + public function getContent() + { + } +} diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php new file mode 100644 index 0000000000000..ed1cf095ca44a --- /dev/null +++ b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\Templating\Storage; + +require_once __DIR__.'/../../../bootstrap.php'; + +use Symfony\Components\Templating\Storage\Storage; +use Symfony\Components\Templating\Storage\StringStorage; + +class StringStorageTest extends \PHPUnit_Framework_TestCase +{ + public function testGetContent() + { + $storage = new StringStorage('foo'); + $this->assertTrue($storage instanceof Storage, 'StringStorage is an instance of Storage'); + $storage = new StringStorage('foo'); + $this->assertEquals($storage->getContent(), 'foo', '->getContent() returns the content of the template'); + } +} diff --git a/tests/bin/prove.php b/tests/bin/prove.php deleted file mode 100644 index a9e22cb8deaf6..0000000000000 --- a/tests/bin/prove.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../lib/vendor/lime/LimeAutoloader.php'; -LimeAutoloader::register(); - -$h = new LimeTestSuite(array( - 'force_colors' => isset($argv) && in_array('--color', $argv), - 'verbose' => isset($argv) && in_array('--verbose', $argv), -)); -$h->base_dir = realpath(__DIR__.'/..'); - -foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__.'/../unit'), RecursiveIteratorIterator::LEAVES_ONLY) as $file) -{ - if (preg_match('/Test\.php$/', $file)) - { - $h->register($file->getRealPath()); - } -} - -exit($h->run() ? 0 : 1); diff --git a/tests/lib/vendor/lime/LimeAnnotationSupport.php b/tests/lib/vendor/lime/LimeAnnotationSupport.php deleted file mode 100644 index 37dd8e3f33f08..0000000000000 --- a/tests/lib/vendor/lime/LimeAnnotationSupport.php +++ /dev/null @@ -1,196 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Extends lime_test to support annotations in test files. - * - * With this extension of lime_test, you can write very simple test files that - * support more features than regular lime, such as code executed before - * or after each test, code executed before or after the whole test suite - * or expected exceptions. - * - * A test file can be written like this with LimeTest: - * - * - * setValue('Bumblebee'); - * $t->is($r->getValue(), 'Bumblebee', 'The setter works'); - * - * // @Test - * $t->is($r->getValue(), 'Foobar', 'The value is "Foobar" by default'); - * - * - * The available annotations are: - * - * * @BeforeAll Executed before the whole test suite - * * @Before Executed before each test - * * @After Executed after each test - * * @AfterAll Executed after the whole test suite - * * @Test A test case - * - * You can add comments to the annotations that will be printed in the console: - * - * - * // @Test: The record supports setValue() - * $r->setValue('Bumblebee') - * // etc. - * - * - * You can also automatically test that certain exceptions are thrown from - * within a test. To do that, you must call the method ->expect() on the - * LimeTest object '''before''' executing the test that should throw - * an exception. - * - * - * // @Test - * $r->expect('RuntimeException'); - * throw new RuntimeException(); - * - * // results in a passed test - * - * - * @package lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeAnnotationSupport.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeAnnotationSupport -{ - protected static - $enabled = false; - - protected - $originalPath = null, - $path = null, - $test = null, - $lexer = null; - - /** - * Enables annotation support in a script file. - */ - public static function enable() - { - // make sure that annotations are not replaced twice at the same time - if (!self::$enabled) - { - self::$enabled = true; - - $support = new LimeAnnotationSupport(self::getScriptPath()); - $support->execute(); - - exit; - } - } - - /** - * Returns the file path of the executed test script - * - * @return string The file path - */ - protected static function getScriptPath() - { - $traces = debug_backtrace(); - $file = $traces[count($traces)-1]['file']; - - if (!is_file($file)) - { - throw new RuntimeException('The script name from the traces is not valid: '.$file); - } - - return $file; - } - - /** - * Constructor. - * - * Creates a backup of the given file with the extension .bak. - */ - protected function __construct($path) - { - $this->originalPath = $path; - $this->path = dirname($path).'/@'.basename($path); - - register_shutdown_function(array($this, 'cleanup')); - } - - /** - * Removes the transformed script file. - */ - public function cleanup() - { - if (file_exists($this->path)) - { - unlink($this->path); - } - } - - /** - * Transforms the annotations in the script file and executes the resulting - * script. - */ - protected function execute() - { - if (file_exists($this->path)) - { - unlink($this->path); - } - - $this->lexer = new LimeLexerTransformAnnotations($this->path); - $callbacks = $this->lexer->parse($this->originalPath); - - $this->includeTestFile(); - - $testRunner = new LimeTestRunner($this->test ? $this->test->getOutput() : null); - - foreach ($callbacks as $annotation => $callbacks) - { - $addMethod = 'add'.$annotation; - foreach ($callbacks as $list) - { - list ($callback, $comment) = $list; - $testRunner->$addMethod($callback, $comment); - } - } - - if ($this->test instanceof LimeTest) - { - $testRunner->addExceptionHandler(array($this->test, 'handleException')); - $testRunner->addAfter(array($this->test, 'verifyException')); - } - - $testRunner->run(); - } - - /** - * Includes the test file in a separate scope. - * - * @param string $testVariable - */ - protected function includeTestFile() - { -// var_dump(file_get_contents($this->path)); - include $this->path; - - if (!is_null($this->lexer->getTestVariable())) - { - eval(sprintf('$this->test = %s;', $this->lexer->getTestVariable())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeAssertionFailedException.php b/tests/lib/vendor/lime/LimeAssertionFailedException.php deleted file mode 100644 index 5097847a3aa64..0000000000000 --- a/tests/lib/vendor/lime/LimeAssertionFailedException.php +++ /dev/null @@ -1,62 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeAssertionFailedException extends Exception -{ - private - $actual = '', - $expected = ''; - - public function __construct($actual, $expected) - { - parent::__construct(sprintf('Got: %s, Expected: %s', $actual, $expected)); - - $this->actual = (string)$actual; - $this->expected = (string)$expected; - } - - public function getActual($indentation = 0) - { - if ($indentation > 0) - { - return $this->indent($this->actual, $indentation); - } - else - { - return $this->actual; - } - } - - public function getExpected($indentation = 0) - { - if ($indentation > 0) - { - return $this->indent($this->expected, $indentation); - } - else - { - return $this->expected; - } - } - - protected function indent($lines, $indentation = 2) - { - $lines = explode("\n", $lines); - - foreach ($lines as $key => $line) - { - $lines[$key] = str_repeat(' ', $indentation).$line; - } - - return trim(implode("\n", $lines)); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeAutoloader.php b/tests/lib/vendor/lime/LimeAutoloader.php deleted file mode 100644 index 2c1b4c3ae1783..0000000000000 --- a/tests/lib/vendor/lime/LimeAutoloader.php +++ /dev/null @@ -1,238 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -// PHP_VERSION_ID is available as of PHP 5.2.7, if our -// version is lower than that, then emulate it -if(!defined('PHP_VERSION_ID')) -{ - $version = explode('.',PHP_VERSION); - - define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); -} - -/** - * LimeAutoloader is an autoloader for the lime test framework classes. - * - * Use the method register() to activate autoloading for all classes of this - * component. - * - * - * include 'path/to/LimeAutoloader.php'; - * LimeAutoloader::register(); - * - * - * Bundled with this component comes a backwards compatibility layer that - * offers class and method signatures of lime 1.0 (lime_test, lime_harness etc.). - * To activate this layer, call the method LimeAutoloader::enableLegacyMode() - * anytime before using any of the old class names in your code. - * - * - * include 'path/to/LimeAutoloader.php'; - * LimeAutoloader::register(); - * LimeAutoloader::enableLegacyMode(); - * - * - * @package symfony - * @subpackage lime - * @author Fabien Potencier - * @author Bernhard Schussek - * @version SVN: $Id: LimeAutoloader.php 24189 2009-11-20 11:29:03Z bschussek $ - */ -class LimeAutoloader -{ - static protected - $isLegacyMode = false, - $isRegistered = false; - - /** - * Enables a backwards compatibility layer to allow use of old class names - * such as lime_test, lime_output etc. - */ - static public function enableLegacyMode() - { - self::$isLegacyMode = true; - } - - /** - * Registers LimeAutoloader as an SPL autoloader. - */ - static public function register() - { - if (!self::$isRegistered) - { - ini_set('unserialize_callback_func', 'spl_autoload_call'); - spl_autoload_register(array(new self, 'autoload')); - - self::$isRegistered = true; - } - } - - /** - * Handles autoloading of classes. - * - * @param string $class A class name. - * - * @return boolean Returns true if the class has been loaded - */ - public function autoload($class) - { - // backwards compatibility - if (0 === strpos($class, 'lime_') && self::$isLegacyMode) - { - require_once dirname(__FILE__).'/lime.php'; - - return true; - } - - if (0 === strpos($class, 'Lime')) - { - $file = dirname(__FILE__).'/'; - - if (0 === strpos($class, 'LimeExpectation')) - { - $file .= 'expectation/'; - } - else if (0 === strpos($class, 'LimeLexer')) - { - $file .= 'lexer/'; - } - else if (0 === strpos($class, 'LimeParser')) - { - $file .= 'parser/'; - } - else if (0 === strpos($class, 'LimeOutput')) - { - $file .= 'output/'; - } - else if (0 === strpos($class, 'LimeMockInvocationMatcher')) - { - $file .= 'mock/matcher/'; - } - else if (0 === strpos($class, 'LimeMock')) - { - $file .= 'mock/'; - } - else if (0 === strpos($class, 'LimeTester')) - { - $file .= 'tester/'; - } - else if (0 === strpos($class, 'LimeShell')) - { - $file .= 'shell/'; - } - else if (0 === strpos($class, 'LimeConstraint')) - { - $file .= 'constraint/'; - } - - $file .= $class.'.php'; - - if (file_exists($file)) - { - require_once $file; - - return true; - } - } - - return false; - } -} - -/** - * Prints the given value to the error stream in a nicely formatted way. - * - * @param mixed $value - */ -function lime_debug($value) -{ - $result = ""; - - if (is_object($value) || is_array($value)) - { - $result = is_object($value) ? sprintf("object(%s) (\n", get_class($value)) : "array ("; - - if (is_object($value)) - { - $value = LimeTesterObject::toArray($value); - } - - foreach ($value as $key => $val) - { - if (is_object($val) || is_array($val)) - { - $output = is_object($val) ? sprintf("object(%s) (", get_class($val)) : "array ("; - - if (is_object($val)) - { - $val = LimeTesterObject::toArray($val); - } - - if (count($val) > 0) - { - $output .= "\n ...\n "; - } - - $output .= ")"; - } - else - { - if (is_string($val) && strlen($val) > 60) - { - $val = substr($val, 0, 57).'...'; - } - - $output = lime_colorize($val); - } - - $result .= sprintf(" %s => %s,\n", var_export($key, true), $output); - } - - $result .= ")"; - } - else - { - $result = lime_colorize($value); - } - - fwrite(STDERR, $result."\n"); -} - -/** - * Returns a colorized export of the given value depending on its type. - * - * @param mixed $value - * @return string - */ -function lime_colorize($value) -{ - static $colorizer = null; - - if (is_null($colorizer) && LimeColorizer::isSupported()) - { - $colorizer = new LimeColorizer(); - $colorizer->setStyle('string', array('fg' => 'cyan')); - $colorizer->setStyle('integer', array('fg' => 'green')); - $colorizer->setStyle('double', array('fg' => 'green')); - $colorizer->setStyle('boolean', array('fg' => 'red')); - } - - $type = gettype($value); - $value = var_export($value, true); - - if (!is_null($colorizer) && in_array($type, array('string', 'integer', 'double', 'boolean'))) - { - $value = $colorizer->colorize($value, $type); - } - - return $value; -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeColorizer.php b/tests/lib/vendor/lime/LimeColorizer.php deleted file mode 100644 index e85e21eaf399d..0000000000000 --- a/tests/lib/vendor/lime/LimeColorizer.php +++ /dev/null @@ -1,196 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Colorizes text strings for output in a console. - * - * You can colorize text by calling the method colorize() with a given text - * string: - * - * - * $colorizer = new LimeColorizer(); - * $text = $colorizer->colorize('Hello World', array( - * 'bold' => true, - * 'fg' => 'white', - * 'bg' => 'blue', - * )); - * - * - * You can also predefine styles using the static method setStyle(). - * - * Use the static method isSupported() to find out whether colorization is - * supported by the current OS and console. - * - * @package lime - * @author Fabien Potencier - * @author Bernhard Schussek - * @version SVN: $Id: LimeColorizer.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeColorizer -{ - static protected - $fontStyles = array( - 'bold' => 1, - 'underscore' => 4, - 'blink' => 5, - 'reverse' => 7, - 'conceal' => 8, - ), - $foregroundColors = array( - 'black' => 30, - 'red' => 31, - 'green' => 32, - 'yellow' => 33, - 'blue' => 34, - 'magenta' => 35, - 'cyan' => 36, - 'white' => 37, - ), - $backgroundColors = array( - 'black' => 40, - 'red' => 41, - 'green' => 42, - 'yellow' => 43, - 'blue' => 44, - 'magenta' => 45, - 'cyan' => 46, - 'white' => 47, - ); - - protected - $styles = array(); - - /** - * Returns whether colorization is supported by the current OS and console. - * - * This method returns true if either the current operating system is - * Windows or the console is not a tty console. - * - * @return boolean - */ - public static function isSupported() - { - return DIRECTORY_SEPARATOR != '\\' && function_exists('posix_isatty') && @posix_isatty(STDOUT); - } - - /** - * Registers a color style under a given name. - * - * The options array may contain the following entries: - * - * - * - * - * - * - * - * - * - * - *
Option Value Type Description
bold boolean true for bold text
underscoreboolean true for underscored text
blink boolean true for blinking text
reverse boolean true for text with inverted foreground/background color
conceal boolean true for invisible text
fg color The color of the text
bg color The color of the background
- * - * The following color values are supported: - * - * * black - * * red - * * green - * * yellow - * * blue - * * magenta - * * cyan - * * white - * - * Example: - * - * - * $colorizer = new LimeColorizer(); - * $colorizer->setStyle('myStyle', array( - * 'bold' => true, - * 'fg' => 'white', - * 'bg' => 'blue', - * )); - * - * - * @param string $name - * @param array $options - */ - public function setStyle($name, array $options = array()) - { - $this->styles[$name] = $options; - } - - /** - * Colorizes a given text. - * - * The second parameter can either be the name of a style predefined with - * setStyle() or an array of style options. For more information about the - * possible style options, see the description of setStyle(). - * - * The returned string contains special codes that are interpreted by the - * shell to format the output. - * - * Example (with options): - * - * - * $colorizer = new LimeColorizer(); - * $text = $colorizer->colorize('Hello World', array( - * 'bold' => true, - * 'fg' => 'white', - * 'bg' => 'blue', - * )); - * - * - * Example (with style name): - * - * - * $colorizer = new LimeColorizer(); - * $colorizer->setStyle('myStyle', array( - * 'bold' => true, - * 'fg' => 'white', - * 'bg' => 'blue', - * )); - * $text = $colorizer->colorize('Hello World', 'myStyle'); - * - * - * @param string $text The text to colorize - * @param string|array $parameters The style name or style options - * - * @return string The colorized text - */ - public function colorize($text = '', $parameters = array()) - { - if (!is_array($parameters) && isset(self::$this->styles[$parameters])) - { - $parameters = $this->styles[$parameters]; - } - - $codes = array(); - if (isset($parameters['fg'])) - { - $codes[] = self::$foregroundColors[$parameters['fg']]; - } - if (isset($parameters['bg'])) - { - $codes[] = self::$backgroundColors[$parameters['bg']]; - } - - foreach (self::$fontStyles as $fontStyle => $code) - { - if (isset($parameters[$fontStyle]) && $parameters[$fontStyle]) - { - $codes[] = $code; - } - } - - return "\033[".implode(';', $codes).'m'.$text."\033[0m"; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeCoverage.php b/tests/lib/vendor/lime/LimeCoverage.php deleted file mode 100644 index 2e3743e9a9e67..0000000000000 --- a/tests/lib/vendor/lime/LimeCoverage.php +++ /dev/null @@ -1,250 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeCoverage extends LimeRegistration -{ - const - COVERED = 1, - UNCOVERED = -1; - - protected - $options = array(), - $files = array(), - $suite = null, - $coverage = array(), - $coveredLines = 0, - $uncoveredLines = 0, - $coveredCode = array(), - $uncoveredCode = array(), - $actualCode = array(); - - public function __construct(LimeTestSuite $suite, array $options = array()) - { - $this->suite = $suite; - $this->options = array_merge(array( - 'base_dir' => null, - 'extension' => '.php', - 'verbose' => false, - ), $options); - - // temporary solution, LimeRegistration needs to be modified - $this->setBaseDir($this->options['base_dir']); - $this->setExtension($this->options['extension']); - - if (!function_exists('xdebug_start_code_coverage')) - { - throw new Exception('You must install and enable xdebug before using lime coverage.'); - } - - if (!ini_get('xdebug.extended_info')) - { - throw new Exception('You must set xdebug.extended_info to 1 in your php.ini to use lime coverage.'); - } - } - - public function setFiles($files) - { - if (!is_array($files)) - { - $files = array($files); - } - - $this->files = $files; - } - - public function run() - { - if (!count($this->suite->files)) - { - throw new Exception('You must register some test files before running coverage!'); - } - - if (!count($this->files)) - { - throw new Exception('You must register some files to cover!'); - } - - $this->coverage = array(); - - $this->process($this->suite->files); - $this->parseCoverage($this->coverage); - - $this->render(); - } - - protected function process(array $files) - { - $this->output = new LimeOutput(); - - foreach ($files as $file) - { - $command = new LimeShellCommand($file, array('coverage' => true)); - $command->execute(); - - // script failed - if ($command->getStatus() != LimeShell::SUCCESS) - { - $this->output->echoln(sprintf('Warning: %s returned status %d, results may be inaccurate', $file, $command->getStatus()), LimeOutput::ERROR); - } - - // script succeeded, coverage not readable - if (false === $coverage = @unserialize($command->getOutput())) - { - if ($command->getStatus() == LimeShell::SUCCESS) - { - throw new Exception(sprintf('Unable to unserialize coverage for file "%s"', $file)); - } - } - else - { - foreach ($coverage as $file => $lines) - { - if (!isset($this->coverage[$file])) - { - $this->coverage[$file] = $lines; - } - else - { - foreach ($lines as $line => $flag) - { - if ($flag == self::COVERED) - { - $this->coverage[$file][$line] = 1; - } - } - } - } - } - } - } - - protected function parseCoverage(array $coverage) - { - $this->coveredLines = 0; - $this->uncoveredLines = 0; - - ksort($coverage); - - foreach ($coverage as $file => $lines) - { - $this->coveredCode[$file] = array(); - $this->uncoveredCode[$file] = array(); - - foreach ($lines as $line => $flag) - { - if ($flag == self::COVERED) - { - $this->coveredCode[$file][] = $line; - $this->coveredLines++; - } - else - { - $this->uncoveredCode[$file][] = $line; - $this->uncoveredLines++; - } - } - } - - $lexer = new LimeLexerCodeLines(); - - foreach ($this->files as $file) - { - if (!array_key_exists($file, $this->coveredCode)) - { - $this->coveredCode[$file] = array(); - $this->uncoveredCode[$file] = $lexer->parse($file); - $this->uncoveredLines += count($this->uncoveredCode[$file]); - } - } - } - - protected function render() - { - $printer = new LimePrinter(new LimeColorizer()); - - foreach ($this->files as $file) - { - $totalLines = count($this->coveredCode[$file]) + count($this->uncoveredCode[$file]); - $percent = count($this->coveredCode[$file]) * 100 / max($totalLines, 1); - - $relativeFile = $this->getRelativeFile($file); - - if ($percent == 100) - { - $style = LimePrinter::OK; - } - else if ($percent >= 90) - { - $style = LimePrinter::INFO; - } - else if ($percent <= 20) - { - $style = LimePrinter::NOT_OK; - } - else - { - $style = null; - } - - $printer->printLine(sprintf("%-76s%3.0f%%", $relativeFile, $percent), $style); - - if ($this->options['verbose'] && $percent > 0 && $percent < 100) - { - $printer->printLine(sprintf("missing: %s", $this->formatRange($this->uncoveredCode[$file])), LimePrinter::COMMENT); - } - } - - $totalLines = $this->coveredLines + $this->uncoveredLines; - $percent = $this->coveredLines * 100 / max($totalLines, 1); - - if ($percent <= 20) - { - $style = LimePrinter::NOT_OK; - } - else - { - $style = LimePrinter::HAPPY; - } - - $printer->printLine(str_pad(sprintf(" Total Coverage: %3.0f%%", $percent), 80), $style); - } - - protected function formatRange(array $lines) - { - sort($lines); - $formatted = ''; - $first = -1; - $last = -1; - foreach ($lines as $line) - { - if ($last + 1 != $line) - { - if ($first != -1) - { - $formatted .= $first == $last ? "$first " : "[$first - $last] "; - } - $first = $line; - $last = $line; - } - else - { - $last = $line; - } - } - if ($first != -1) - { - $formatted .= $first == $last ? "$first " : "[$first - $last] "; - } - - return $formatted; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeError.php b/tests/lib/vendor/lime/LimeError.php deleted file mode 100644 index 4c5d54452bef7..0000000000000 --- a/tests/lib/vendor/lime/LimeError.php +++ /dev/null @@ -1,162 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Stores an error and optionally its trace. - * - * This class is similar to PHP's native Exception class, but is guaranteed - * to be serializable. The native Exception class is not serializable if the - * traces contain circular references between objects. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeError.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeError implements Serializable -{ - private - $type = null, - $message = null, - $file = null, - $line = null, - $trace = null; - - /** - * Creates a new instance and copies the data from an exception. - * - * @param Exception $exception - * @return LimeError - */ - public static function fromException(Exception $exception) - { - return new self( - $exception->getMessage(), - $exception->getFile(), - $exception->getLine(), - get_class($exception), - $exception->getTrace() - ); - } - - /** - * Constructor. - * - * @param string $message The error message - * @param string $file The file where the error occurred - * @param integer $line The line where the error occurred - * @param string $type The error type, f.i. "Fatal Error" - * @param array $trace The traces of the error - */ - public function __construct($message, $file, $line, $type = 'Error', array $trace = array()) - { - $this->message = $message; - $this->file = $file; - $this->line = $line; - $this->type = $type; - $this->trace = $trace; - } - - /** - * Returns the error type. - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Returns the error message. - * - * @return string - */ - public function getMessage() - { - return $this->message; - } - - /** - * Returns the file where the error occurred. - * - * @return string - */ - public function getFile() - { - return $this->file; - } - - /** - * Returns the line where the error occurred. - * - * @return integer - */ - public function getLine() - { - return $this->line; - } - - /** - * Returns the trace of the error. - * - * @return array - */ - public function getTrace() - { - return $this->trace; - } - - /** - * Serializes the error. - * - * @see Serializable#serialize() - * @return string The serialized error content - */ - public function serialize() - { - $traces = $this->trace; - - foreach ($traces as &$trace) - { - if (array_key_exists('args', $trace)) - { - foreach ($trace['args'] as &$value) - { - // TODO: This should be improved. Maybe we can check for recursions - // and only exclude duplicate objects from the trace - if (is_object($value)) - { - // replace object by class name - $value = sprintf('object (%s) (...)', get_class($value)); - } - else if (is_array($value)) - { - $value = 'array(...)'; - } - } - } - } - - return serialize(array($this->file, $this->line, $this->message, $traces, $this->type)); - } - - /** - * Unserializes an error. - * - * @see Serializable#unserialize() - * @param string $data The serialized error content - */ - public function unserialize($data) - { - list($this->file, $this->line, $this->message, $this->trace, $this->type) = unserialize($data); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeExceptionExpectation.php b/tests/lib/vendor/lime/LimeExceptionExpectation.php deleted file mode 100644 index 26d93a0c90019..0000000000000 --- a/tests/lib/vendor/lime/LimeExceptionExpectation.php +++ /dev/null @@ -1,41 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeExceptionExpectation -{ - private - $exception = null, - $file = null, - $line = null; - - public function __construct($exception, $file, $line) - { - $this->exception = $exception; - $this->file = $file; - $this->line = $line; - } - - public function getException() - { - return $this->exception; - } - - public function getFile() - { - return $this->file; - } - - public function getLine() - { - return $this->line; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimePrinter.php b/tests/lib/vendor/lime/LimePrinter.php deleted file mode 100644 index c2275c145932b..0000000000000 --- a/tests/lib/vendor/lime/LimePrinter.php +++ /dev/null @@ -1,127 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimePrinter -{ - const - OK = 0, - NOT_OK = 1, - COMMENT = 2, - SKIP = 3, - WARNING = 4, - ERROR = 5, - HAPPY = 6, - STRING = 7, - NUMBER = 8, - BOOLEAN = 9, - INFO = 10, - TRACE = 11, - TODO = 12; - - protected - $colorizer = null; - - public function __construct(LimeColorizer $colorizer = null) - { - if (!is_null($colorizer)) - { - $colorizer->setStyle(self::OK, array('fg' => 'green', 'bold' => true)); - $colorizer->setStyle(self::NOT_OK, array('bg' => 'red', 'fg' => 'white', 'bold' => true)); - $colorizer->setStyle(self::COMMENT, array('fg' => 'yellow')); - $colorizer->setStyle(self::SKIP, array('fg' => 'yellow', 'bold' => true)); - $colorizer->setStyle(self::TODO, array('fg' => 'yellow', 'bold' => true)); - $colorizer->setStyle(self::WARNING, array('fg' => 'white', 'bg' => 'yellow', 'bold' => true)); - $colorizer->setStyle(self::ERROR, array('bg' => 'red', 'fg' => 'white', 'bold' => true)); - $colorizer->setStyle(self::HAPPY, array('fg' => 'white', 'bg' => 'green', 'bold' => true)); - $colorizer->setStyle(self::STRING, array('fg' => 'cyan')); - $colorizer->setStyle(self::NUMBER, array()); - $colorizer->setStyle(self::BOOLEAN, array('fg' => 'cyan')); - $colorizer->setStyle(self::INFO, array('fg' => 'cyan', 'bold' => true)); - $colorizer->setStyle(self::TRACE, array('fg' => 'green', 'bold' => true)); - } - - $this->colorizer = $colorizer; - } - - public function printText($text, $style = null) - { - print $this->colorize($text, $style); - } - - public function printLine($text, $style = null) - { - print $this->colorize($text, $style)."\n"; - } - - public function printBox($text, $style = null) - { - print $this->colorize(str_pad($text, 80, ' '), $style)."\n"; - } - - public function printLargeBox($text, $style = null) - { - $space = $this->colorize(str_repeat(' ', 80), $style)."\n"; - $text = trim($text); - $text = wordwrap($text, 75, "\n"); - - print "\n".$space; - foreach (explode("\n", $text) as $line) - { - print $this->colorize(str_pad(' '.$line, 80, ' '), $style)."\n"; - } - print $space."\n"; - } - - protected function colorize($text, $style) - { - if (is_null($this->colorizer)) - { - return $text; - } - else - { - if (is_null($style)) - { - return preg_replace_callback('/("[^"]*"|(?|::)?\w+\([^\)]*\)*/.')/', array($this, 'autoColorize'), $text); - } - else - { - return $this->colorizer->colorize($text, $style); - } - } - } - - public function autoColorize($text) - { - $text = $text[0]; - - if (is_null($this->colorizer)) - { - return $text; - } - else - { - if ($text{0} == '"') - { - return $this->colorizer->colorize($text, self::STRING); - } - else if (in_array(strtolower($text), array('true', 'false'))) - { - return $this->colorizer->colorize($text, self::BOOLEAN); - } - else - { - return $this->colorizer->colorize($text, self::NUMBER); - } - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeRegistration.php b/tests/lib/vendor/lime/LimeRegistration.php deleted file mode 100644 index 8c730223f5b0c..0000000000000 --- a/tests/lib/vendor/lime/LimeRegistration.php +++ /dev/null @@ -1,96 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeRegistration -{ - protected - $files = array(), - $extension = '.php', - $baseDir = ''; - - public function setBaseDir($baseDir) - { - $this->baseDir = $baseDir; - } - - public function setExtension($extension) - { - $this->extension = $extension; - } - - public function getFiles() - { - return $this->files; - } - - public function register($filesOrDirectories) - { - foreach ((array) $filesOrDirectories as $fileOrDirectory) - { - if (is_file($fileOrDirectory)) - { - $this->files[] = realpath($fileOrDirectory); - } - elseif (is_dir($fileOrDirectory)) - { - $this->registerDir($fileOrDirectory); - } - else - { - throw new Exception(sprintf('The file or directory "%s" does not exist.', $fileOrDirectory)); - } - } - } - - public function registerGlob($glob) - { - if ($dirs = glob($glob)) - { - foreach ($dirs as $file) - { - $this->files[] = realpath($file); - } - } - } - - public function registerDir($directory) - { - if (!is_dir($directory)) - { - throw new Exception(sprintf('The directory "%s" does not exist.', $directory)); - } - - $files = array(); - - $currentDir = opendir($directory); - while ($entry = readdir($currentDir)) - { - if ($entry == '.' || $entry == '..') continue; - - if (is_dir($entry)) - { - $this->registerDir($entry); - } - elseif (preg_match('#'.$this->extension.'$#', $entry)) - { - $files[] = realpath($directory.DIRECTORY_SEPARATOR.$entry); - } - } - - $this->files = array_merge($this->files, $files); - } - - protected function getRelativeFile($file) - { - return str_replace(DIRECTORY_SEPARATOR, '/', str_replace(array(realpath($this->baseDir).DIRECTORY_SEPARATOR, $this->extension), '', $file)); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTest.php b/tests/lib/vendor/lime/LimeTest.php deleted file mode 100644 index 220a6d2261a78..0000000000000 --- a/tests/lib/vendor/lime/LimeTest.php +++ /dev/null @@ -1,435 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Unit test library. - * - * @package lime - * @author Fabien Potencier - * @version SVN: $Id: LimeTest.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -class LimeTest -{ - protected - $output = null, - $options = array(), - $errorReporting = true, - $exception = null, - $exceptionExpectation = null; - - public function __construct($plan = null, array $options = array()) - { - $this->options = array( - 'base_dir' => null, - 'output' => 'tap', - 'force_colors' => false, - 'verbose' => false, - 'serialize' => false, - 'coverage' => false, - ); - - foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) - { - $this->options[str_replace('-', '_', $argument)] = $value; - } - - $this->options = array_merge($this->options, $options); - - $this->options['base_dir'] = realpath($this->options['base_dir']); - - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - if ($this->options['coverage']) - { - $this->output = new LimeOutputCoverage(); - } - elseif (is_string($this->options['output'])) - { - $factory = new LimeOutputFactory($this->options); - - $this->output = $factory->create($this->options['output']); - } - else - { - $this->output = $this->options['output']; - } - - $this->output->focus($file); - - if (!is_null($plan)) - { - $this->output->plan($plan); - } - - set_error_handler(array($this, 'handleError')); - - // make sure that exceptions that are not caught by the test runner are - // caught and formatted in an appropriate way - set_exception_handler(array($this, 'handleException')); - } - - public function setErrorReporting($enabled) - { - $this->errorReporting = $enabled; - } - - public function __destruct() - { - $this->output->close(); - $this->output->flush(); - - restore_error_handler(); - restore_exception_handler(); - } - - public function getOutput() - { - return $this->output; - } - - private function test(LimeConstraintInterface $constraint, $value, $message) - { - try - { - $constraint->evaluate($value); - - return $this->pass($message); - } - catch (LimeConstraintException $e) - { - return $this->fail($message, $e->getMessage()); - } - } - - /** - * Tests a condition and passes if it is true - * - * @param mixed $exp condition to test - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function ok($exp, $message = '') - { - if ((boolean)$exp) - { - return $this->pass($message); - } - else - { - return $this->fail($message); - } - } - - /** - * Compares two values and passes if they are equal (==) - * - * @param mixed $exp1 left value - * @param mixed $exp2 right value - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function is($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintIs($exp2), $exp1, $message); - } - - /** - * Compares two values and passes if they are identical (===) - * - * @param mixed $exp1 left value - * @param mixed $exp2 right value - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function same($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintSame($exp2), $exp1, $message); - } - - /** - * Compares two values and passes if they are not equal - * - * @param mixed $exp1 left value - * @param mixed $exp2 right value - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function isnt($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintIsNot($exp2), $exp1, $message); - } - - /** - * Compares two values and passes if they are not identical (!==) - * - * @param mixed $exp1 left value - * @param mixed $exp2 right value - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function isntSame($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintNotSame($exp2), $exp1, $message); - } - - /** - * Tests a string against a regular expression - * - * @param string $exp value to test - * @param string $regex the pattern to search for, as a string - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function like($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintLike($exp2), $exp1, $message); - } - - /** - * Checks that a string doesn't match a regular expression - * - * @param string $exp value to test - * @param string $regex the pattern to search for, as a string - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function unlike($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintUnlike($exp2), $exp1, $message); - } - - public function greaterThan($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintGreaterThan($exp2), $exp1, $message); - } - - public function greaterThanEqual($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintGreaterThanEqual($exp2), $exp1, $message); - } - - public function lessThan($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintLessThan($exp2), $exp1, $message); - } - - public function lessThanEqual($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintLessThanEqual($exp2), $exp1, $message); - } - - public function contains($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintContains($exp2), $exp1, $message); - } - - public function containsNot($exp1, $exp2, $message = '') - { - return $this->test(new LimeConstraintContainsNot($exp2), $exp1, $message); - } - - /** - * Always passes--useful for testing exceptions - * - * @param string $message display output message - * - * @return true - */ - public function pass($message = '') - { - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - $this->output->pass($message, $file, $line); - - return true; - } - - /** - * Always fails--useful for testing exceptions - * - * @param string $message display output message - * - * @return false - */ - public function fail($message = '', $error = null) - { - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - $this->output->fail($message, $file, $line, $error); - - return false; - } - - /** - * Outputs a diag message but runs no test - * - * @param string $message display output message - * - * @return void - */ - public function diag($message) - { - $this->output->comment($message); - } - - /** - * Counts as $nbTests tests--useful for conditional tests - * - * @param string $message display output message - * @param integer $nbTests number of tests to skip - * - * @return void - */ - public function skip($message = '', $nbTests = 1) - { - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - for ($i = 0; $i < $nbTests; $i++) - { - $this->output->skip($message, $file, $line); - } - } - - /** - * Counts as a test--useful for tests yet to be written - * - * @param string $message display output message - * - * @return void - */ - public function todo($message = '') - { - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - $this->output->todo($message, $file, $line); - } - - public function comment($message) - { - $this->output->comment($message); - } - - public function mock($class, array $options = array()) - { - return LimeMock::create($class, $this->output, $options); - } - - public function stub($class, array $options = array()) - { - $options = array_merge(array( - 'nice' => true, - 'no_exceptions' => true, - ), $options); - - return LimeMock::create($class, new LimeOutputNone(), $options); - } - - public function extendMock($class, array $options = array()) - { - $options['stub_methods'] = false; - - return $this->mock($class, $options); - } - - public function extendStub($class, array $options = array()) - { - $options['stub_methods'] = false; - - return $this->stub($class, $options); - } - - public function expect($exception, $code = null) - { - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - $this->exceptionExpectation = new LimeExceptionExpectation($exception, $file, $line); - $this->exception = null; - } - - public function handleError($code, $message, $file, $line, $context) - { - if (!$this->errorReporting || ($code & error_reporting()) == 0) - { - return false; - } - - switch ($code) - { - case E_WARNING: - $message = 'Warning: '.$message; - break; - case E_NOTICE: - $message = 'Notice: '.$message; - break; - } - - $this->output->warning($message, $file, $line); - } - - public function handleException(Exception $exception) - { - if (!is_null($this->exceptionExpectation)) - { - $this->exception = $exception; - } - else - { - $this->output->error(LimeError::fromException($exception)); - } - - return true; - } - - public function verifyException() - { - if (!is_null($this->exceptionExpectation)) - { - $expected = $this->exceptionExpectation->getException(); - $file = $this->exceptionExpectation->getFile(); - $line = $this->exceptionExpectation->getLine(); - - if (is_string($expected)) - { - $actual = is_object($this->exception) ? get_class($this->exception) : 'none'; - $message = sprintf('A "%s" was thrown', $expected); - } - else - { - $actual = $this->exception; - $message = sprintf('A "%s" was thrown', get_class($expected)); - } - - // can't use ->is() here because the custom file and line need to be - // passed to the output - try - { - $constraint = new LimeConstraintIs($expected); - $constraint->evaluate($actual); - - $this->output->pass($message, $file, $line); - } - catch (LimeConstraintException $e) - { - $this->output->fail($message, $file, $line, $e->getMessage()); - } - } - - $this->exceptionExpectation = null; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTestAnalyzer.php b/tests/lib/vendor/lime/LimeTestAnalyzer.php deleted file mode 100644 index ad807cd6b9189..0000000000000 --- a/tests/lib/vendor/lime/LimeTestAnalyzer.php +++ /dev/null @@ -1,97 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTestAnalyzer -{ - protected - $suppressedMethods = array(), - $output = null, - $errors = '', - $file = null, - $process = null, - $done = true, - $parser = null; - - public function __construct(LimeOutputInterface $output, array $suppressedMethods = array()) - { - $this->suppressedMethods = $suppressedMethods; - $this->output = $output; - } - - public function getConnectedFile() - { - return $this->file; - } - - public function connect($file, array $arguments = array()) - { - $arguments['output'] = 'raw'; - - $this->file = $file; - $this->done = false; - $this->parser = null; - $this->process = new LimeShellProcess($file, $arguments); - $this->process->execute(); - } - - public function proceed() - { - $data = $this->process->getOutput(); - - if (is_null($this->parser)) - { - if (substr($data, 0, 5) == "\0raw\0") - { - $this->parser = new LimeParserRaw($this->output, $this->suppressedMethods); - $data = substr($data, 5); - } - else - { - $this->parser = new LimeParserTap($this->output); - } - } - - $this->parser->parse($data); - - $this->errors .= $this->process->getErrors(); - - while (preg_match('/^(.+)\n/', $this->errors, $matches)) - { - $this->output->warning($matches[1], $this->file, 0); - $this->errors = substr($this->errors, strlen($matches[0])); - } - - if ($this->process->isClosed()) - { - if (!$this->parser->done()) - { - // FIXME: Should be handled in a better way - $buffer = substr($this->parser->buffer, 0, strpos($this->parser->buffer, "\n")); - $this->output->warning(sprintf('Could not parse test output: "%s"', $buffer), $this->file, 1); - } - - // if the last error was not followed by \n, it is still in the buffer - if (!empty($this->errors)) - { - $this->output->warning($this->errors, $this->file, 0); - $this->errors = ''; - } - - $this->done = true; - } - } - - public function done() - { - return $this->done; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTestCase.php b/tests/lib/vendor/lime/LimeTestCase.php deleted file mode 100644 index 207df13e56d47..0000000000000 --- a/tests/lib/vendor/lime/LimeTestCase.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTestCase extends LimeTest -{ - protected - $testRunner = null; - - public function __construct($plan = null, array $options = array()) - { - parent::__construct($plan, $options); - - $this->testRunner = new LimeTestRunner($this->getOutput()); - $this->testRunner->addBefore(array($this, 'setUp')); - $this->testRunner->addAfter(array($this, 'tearDown')); - - // attention: the following lines are not tested - $this->testRunner->addExceptionHandler(array($this, 'handleException')); - $this->testRunner->addAfter(array($this, 'verifyException')); - - foreach (get_class_methods($this) as $method) - { - if (strpos($method, 'test') === 0 && strlen($method) > 4) - { - $this->testRunner->addTest(array($this, $method), $this->humanize($method)); - } - } - } - - public function setUp() {} - - public function tearDown() {} - - public function run() - { - $this->testRunner->run(); - } - - protected function humanize($method) - { - if (substr($method, 0, 4) == 'test') - { - $method = substr($method, 4); - } - - $method = preg_replace('/([a-z])([A-Z])/', '$1 $2', $method); - - return ucfirst(strtolower($method)); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTestRunner.php b/tests/lib/vendor/lime/LimeTestRunner.php deleted file mode 100644 index d07c406fa8cca..0000000000000 --- a/tests/lib/vendor/lime/LimeTestRunner.php +++ /dev/null @@ -1,217 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Runs a set of test methods. - * - * You can add different types of callbacks to a test runner. The most important - * type is the "test" callback. These callbacks are added by calling addTest(). - * All "test" callbacks are executed upon calling run(). - * - * The other callback types are called before or after the "test" callbacks: - * - * - "before all": Called once before all tests - * - "after all": Called once after all tests - * - "before": Called before each test - * - "after": Called after each test - * - * These callbacks are added by calling addBeforeAll(), addAfterAll(), - * addBefore() and addAfter(). You can add multiple callbacks for each type. - * Callbacks are called in the same order in which they are added. - * - * @package lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeTestRunner.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeTestRunner -{ - protected - $output = null, - $beforeAllCallbacks = array(), - $afterAllCallbacks = array(), - $beforeCallbacks = array(), - $afterCallbacks = array(), - $testCallbacks = array(), - $testComments = array(), - $errorCallbacks = array(), - $exceptionCallbacks = array(); - - /** - * Constructor. - * - * @param LimeOutputInterface $output - */ - public function __construct(LimeOutputInterface $output = null) - { - if (is_null($output)) - { - $output = new LimeOutputNone(); - } - - $this->output = $output; - } - - /** - * Runs all registered callbacks. - */ - public function run() - { - foreach ($this->beforeAllCallbacks as $callback) - { - call_user_func($callback); - } - - foreach ($this->testCallbacks as $key => $testCallback) - { - if (!empty($this->testComments[$key])) - { - $this->output->comment($this->testComments[$key]); - } - - foreach ($this->beforeCallbacks as $callback) - { - call_user_func($callback); - } - - try - { - call_user_func($testCallback); - } - catch (Exception $e) - { - $this->handleException($e); - } - - foreach ($this->afterCallbacks as $callback) - { - call_user_func($callback); - } - } - - foreach ($this->afterAllCallbacks as $callback) - { - call_user_func($callback); - } - } - - /** - * Adds a callable that is called once before all tests. - * - * @param callable $callback - * @throws InvalidArgumentException If the argument is no callbale - */ - public function addBeforeAll($callback) - { - $this->assertIsCallable($callback); - $this->beforeAllCallbacks[] = $callback; - } - - /** - * Adds a callable that is called once after all tests. - * - * @param callable $callback - * @throws InvalidArgumentException If the argument is no callbale - */ - public function addAfterAll($callback) - { - $this->assertIsCallable($callback); - $this->afterAllCallbacks[] = $callback; - } - - /** - * Adds a callable that is called before each test. - * - * @param callable $callback - * @throws InvalidArgumentException If the argument is no callbale - */ - public function addBefore($callback) - { - $this->assertIsCallable($callback); - $this->beforeCallbacks[] = $callback; - } - - /** - * Adds a callable that is called after each test. - * - * @param callable $callback - * @throws InvalidArgumentException If the argument is no callbale - */ - public function addAfter($callback) - { - $this->assertIsCallable($callback); - $this->afterCallbacks[] = $callback; - } - - /** - * Adds a test callable. - * - * @param callable $callback - * @throws InvalidArgumentException If the argument is no callbale - */ - public function addTest($callback, $comment = '') - { - $this->assertIsCallable($callback); - $this->testCallbacks[] = $callback; - $this->testComments[] = $comment; - } - - /** - * Adds a callback that is called when an exception is thrown in a test. - * - * The callback retrieves the exception as first argument. It - * should return TRUE if it was able to handle the exception successfully and - * FALSE otherwise. In the latter case, the exception is thrown globally. - * - * @param callable $callback - * @throws InvalidArgumentException If the argument is no callbale - */ - public function addExceptionHandler($callback) - { - $this->assertIsCallable($callback); - $this->exceptionCallbacks[] = $callback; - } - - /** - * Calls all registered exception callbacks. - * - * The exception is passed to the callbacks as first argument. - * - * @param Exception $exception - */ - protected function handleException(Exception $exception) - { - foreach ($this->exceptionCallbacks as $callback) - { - if (true === call_user_func($callback, $exception)) - { - return; - } - } - - throw $exception; - } - - /** - * Asserts that the given argument is a callable. - * - * @param mixed $callable - * @throws InvalidArgumentException If the argument is no callbale - */ - private function assertIsCallable($callable) - { - if (!is_callable($callable)) - { - throw new InvalidArgumentException('The given Argument must be a callable.'); - } - } - -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTestSuite.php b/tests/lib/vendor/lime/LimeTestSuite.php deleted file mode 100644 index 48f11a1c8360c..0000000000000 --- a/tests/lib/vendor/lime/LimeTestSuite.php +++ /dev/null @@ -1,114 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTestSuite extends LimeRegistration -{ - protected - $options = array(), - $executable = null, - $output = null; - - public function __construct(array $options = array()) - { - $this->options = array_merge(array( - 'base_dir' => null, - 'executable' => null, - 'output' => 'summary', - 'force_colors' => false, - 'verbose' => false, - 'serialize' => false, - 'processes' => 1, - ), $options); - - foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) - { - $this->options[str_replace('-', '_', $argument)] = $value; - } - - $this->options['base_dir'] = realpath($this->options['base_dir']); - - if (is_string($this->options['output'])) - { - $factory = new LimeOutputFactory($this->options); - - $type = $this->options['output']; - $output = $factory->create($type); - } - else - { - $output = $this->options['output']; - $type = get_class($output); - } - - if ($this->options['processes'] > 1 && !$output->supportsThreading()) - { - throw new LogicException(sprintf('The output "%s" does not support multi-processing', $type)); - } - - $this->output = new LimeOutputProxy($output); - } - - public function run() - { - if (!count($this->files)) - { - throw new Exception('You must register some test files before running them!'); - } - - // sort the files to be able to predict the order - sort($this->files); - reset($this->files); - - $connectors = array(); - - for ($i = 0; $i < $this->options['processes']; ++$i) - { - $connectors[] = new LimeTestAnalyzer($this->output, array('focus', 'close', 'flush')); - } - - do - { - $done = true; - - foreach ($connectors as $connector) - { - if ($connector->done() && !is_null(key($this->files))) - { - // start and close the file explicitly in case the file contains syntax errors - $this->output->focus(current($this->files)); - $connector->connect(current($this->files)); - - next($this->files); - } - - if (!$connector->done()) - { - $this->output->focus($connector->getConnectedFile()); - - $connector->proceed(); - $done = false; - - if ($connector->done()) - { - // start and close the file explicitly in case the file contains syntax errors - $this->output->close(); - } - } - } - } - while (!$done); - - $this->output->flush(); - - return !$this->output->getResult()->isFailed(); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTools.php b/tests/lib/vendor/lime/LimeTools.php deleted file mode 100644 index 4b2855b5bf054..0000000000000 --- a/tests/lib/vendor/lime/LimeTools.php +++ /dev/null @@ -1,43 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Provides static utility methods. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeTools.php 23864 2009-11-13 18:06:20Z bschussek $ - */ -abstract class LimeTools -{ - /** - * Indents every line of the given string for the given number of spaces - * (except for the first line, which is not indented). - * - * @param string $text The input string - * @param integer $numberOfSpaces The number of spaces for indenting the - * input string - * @return string The indented string - */ - public static function indent($text, $numberOfSpaces) - { - $indentation = str_repeat(' ', $numberOfSpaces); - $lines = explode("\n", $text); - - for ($i = 0, $c = count($lines); $i < $c; ++$i) - { - $lines[$i] = $indentation.$lines[$i]; - } - - return implode("\n", $lines); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/LimeTrace.php b/tests/lib/vendor/lime/LimeTrace.php deleted file mode 100644 index 7d482358eb04c..0000000000000 --- a/tests/lib/vendor/lime/LimeTrace.php +++ /dev/null @@ -1,43 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -abstract class LimeTrace -{ - static public function findCaller($class) - { - $traces = debug_backtrace(); - $result = array($traces[0]['file'], $traces[0]['line']); - - $t = array_reverse($traces); - foreach ($t as $trace) - { - if (isset($trace['object']) && isset($trace['file']) && isset($trace['line'])) - { - $reflection = new ReflectionClass($trace['object']); - - if ($reflection->getName() == $class || $reflection->isSubclassOf($class)) - { - $result = array($trace['file'], $trace['line']); - break; - } - } - } - - // remove .test suffix which is added in case of annotated tests - if (substr($result[0], -5) == '.test') - { - $result[0] = substr($result[0], 0, -5); - } - - return $result; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraint.php b/tests/lib/vendor/lime/constraint/LimeConstraint.php deleted file mode 100644 index 6b32d440bbae5..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraint.php +++ /dev/null @@ -1,34 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Base class for all constraints. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraint.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -abstract class LimeConstraint implements LimeConstraintInterface -{ - protected - $expected = null; - - /** - * Constructor. - * - * @param $expected The value against which the constraint should be tested - */ - public function __construct($expected) - { - $this->expected = $expected; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintContains.php b/tests/lib/vendor/lime/constraint/LimeConstraintContains.php deleted file mode 100644 index 295cf7430f62f..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintContains.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value contains another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintContains.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintContains extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->contains(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf("%s\n doesn't contain\n%s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintContainsNot.php b/tests/lib/vendor/lime/constraint/LimeConstraintContainsNot.php deleted file mode 100644 index b7e109c69daff..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintContainsNot.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value does not contain another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintContainsNot.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintContainsNot extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->containsNot(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf("%s\n must not contain\n%s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintException.php b/tests/lib/vendor/lime/constraint/LimeConstraintException.php deleted file mode 100644 index 4bdc06616dc83..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * This exception is thrown when a constraint fails. - * - * The message of the exception contains the detailed description why the - * constraint failed. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintException.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintException extends Exception {} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintGreaterThan.php b/tests/lib/vendor/lime/constraint/LimeConstraintGreaterThan.php deleted file mode 100644 index 48e6cd1e4c5a0..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintGreaterThan.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is greater than another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintGreaterThan.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintGreaterThan extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->greaterThan(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" %s\nis not > %s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintGreaterThanEqual.php b/tests/lib/vendor/lime/constraint/LimeConstraintGreaterThanEqual.php deleted file mode 100644 index c976132736a16..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintGreaterThanEqual.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is greater than or equal to another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintGreaterThanEqual.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintGreaterThanEqual extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->greaterThanEqual(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" %s\nis not >= %s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintInterface.php b/tests/lib/vendor/lime/constraint/LimeConstraintInterface.php deleted file mode 100644 index 35e6eda18a446..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests whether a value satisfies a constraint. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintInterface.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -interface LimeConstraintInterface -{ - /** - * Evaluates the constraint for the given value. - * - * If the evaluation fails, a LimeConstraintException with details about the - * error is thrown. - * - * @param mixed $value - * @throws LimeConstraintException If the evaluation fails - */ - public function evaluate($value); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintIs.php b/tests/lib/vendor/lime/constraint/LimeConstraintIs.php deleted file mode 100644 index a5520109f7b33..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintIs.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value equals another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintIs.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintIs extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->is(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" got: %s\nexpected: %s", $e->getActual(10), $e->getExpected(10))); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintIsNot.php b/tests/lib/vendor/lime/constraint/LimeConstraintIsNot.php deleted file mode 100644 index 019a7fe0461a3..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintIsNot.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value does not equal another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintIsNot.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintIsNot extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->isnt(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf("%s\n must not be\n%s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintLessThan.php b/tests/lib/vendor/lime/constraint/LimeConstraintLessThan.php deleted file mode 100644 index b13ff923ac2cf..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintLessThan.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is less than another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintLessThan.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintLessThan extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->lessThan(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" %s\nis not < %s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintLessThanEqual.php b/tests/lib/vendor/lime/constraint/LimeConstraintLessThanEqual.php deleted file mode 100644 index 1908da8dbcbd4..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintLessThanEqual.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is less than or equal to another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintLessThanEqual.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintLessThanEqual extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->lessThanEqual(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" %s\nis not <= %s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintLike.php b/tests/lib/vendor/lime/constraint/LimeConstraintLike.php deleted file mode 100644 index 1d9b4a5e555a0..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintLike.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is like another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintLike.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintLike extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->like(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" %s\ndoesn't match %s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintNotSame.php b/tests/lib/vendor/lime/constraint/LimeConstraintNotSame.php deleted file mode 100644 index 8c6d1d6d45b71..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintNotSame.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is not identical to another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintNotSame.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintNotSame extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->isntSame(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf("%s\n must not be\n%s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintSame.php b/tests/lib/vendor/lime/constraint/LimeConstraintSame.php deleted file mode 100644 index 716f469e58a97..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintSame.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is identical to another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintSame.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintSame extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->same(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" got: %s\nexpected: %s", $e->getActual(10), $e->getExpected(10))); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/constraint/LimeConstraintUnlike.php b/tests/lib/vendor/lime/constraint/LimeConstraintUnlike.php deleted file mode 100644 index 8216880cbe9be..0000000000000 --- a/tests/lib/vendor/lime/constraint/LimeConstraintUnlike.php +++ /dev/null @@ -1,37 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Tests that a value is unlike another. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeConstraintUnlike.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeConstraintUnlike extends LimeConstraint -{ - /** - * (non-PHPdoc) - * @see constraint/LimeConstraintInterface#evaluate($value) - */ - public function evaluate($value) - { - try - { - LimeTester::create($value)->unlike(LimeTester::create($this->expected)); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeConstraintException(sprintf(" %s\nmatches %s", $e->getActual(), $e->getExpected())); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lexer/LimeLexer.php b/tests/lib/vendor/lime/lexer/LimeLexer.php deleted file mode 100644 index 75be4ee6c8861..0000000000000 --- a/tests/lib/vendor/lime/lexer/LimeLexer.php +++ /dev/null @@ -1,402 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Analyzes PHP scripts syntactically. - * - * You can extend this class if you want to write your own lexer that parses - * a PHP file for specific information. - * - * To create your own lexer, implement the methods process() and getResult() - * in your class. process() is called for every token in the file. You can use - * the methods of this class to retrieve more information about the context of - * the token, f.i. whether the token is inside a class or function etc. - * - * The method getResult() must return the value that should be returned by - * parse(). - * - * A lexer is stateless. This means that you can analyze any number of PHP - * scripts with the same lexer instance. - * - * @package Lime - * @author Bernhard Schussek - * @author Fabien Potencier - * @version SVN: $Id: LimeLexer.php 25934 2009-12-27 20:44:07Z bschussek $ - */ -abstract class LimeLexer -{ - private - $continue, - $currentClass, - $inClassDeclaration, - $currentFunction, - $inFunctionDeclaration, - $inAssignment, - $endOfCurrentExpr, - $currentLine; - - /** - * Analyzes the given file or PHP code. - * - * @param string $content A file path or a string with PHP code. - * - * @return mixed The result from getResult() - */ - public function parse($content) - { - if (is_readable($content)) - { - $content = file_get_contents($content); - } - - $this->continue = true; - $this->currentClass = array(); - $this->inClassDeclaration = false; - $this->currentFunction = array(); - $this->inFunctionDeclaration = false; - $this->inAssignment = false; - $this->endOfCurrentExpr = true; - $this->currentLine = 1; - - $tokens = token_get_all($content); - $openBraces = 0; - foreach ($tokens as $token) - { - if (is_string($token)) - { - switch ($token) - { - case '{': - ++$openBraces; - $this->inClassDeclaration = false; - $this->inFunctionDeclaration = false; - break; - case ';': - // abstract functions - if ($this->inFunctionDeclaration) - { - $this->inFunctionDeclaration = false; - unset($this->currentFunction[$openBraces]); - } - $this->endOfCurrentExpr = true; - break; - case '}': - $this->endOfCurrentExpr = true; - break; - case '=': - $this->endOfCurrentExpr = false; - $this->inAssignment = true; - break; - } - - - if ($this->endOfCurrentExpr) - { - $this->inAssignment = false; - } - - $this->beforeProcess($token, null); - $this->process($token, null); - $this->afterProcess($token, null); - - switch ($token) - { - case '}': - --$openBraces; - if (array_key_exists($openBraces, $this->currentClass)) - { - unset($this->currentClass[$openBraces]); - } - if (array_key_exists($openBraces, $this->currentFunction)) - { - unset($this->currentFunction[$openBraces]); - } - break; - } - } - else - { - list($id, $text) = $token; - - switch ($id) - { - case T_CURLY_OPEN: - case T_DOLLAR_OPEN_CURLY_BRACES: - ++$openBraces; - break; - case T_OPEN_TAG: - case T_CLOSE_TAG: - $this->endOfCurrentExpr = true; - $this->currentLine += count(explode("\n", $text)) - 1; - break; - case T_WHITESPACE: - case T_START_HEREDOC: - case T_CONSTANT_ENCAPSED_STRING: - case T_ENCAPSED_AND_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - $this->currentLine += count(explode("\n", $text)) - 1; - break; - case T_ABSTRACT: - if ($this->inClass()) - { - $this->currentFunction[$openBraces] = null; - $this->inFunctionDeclaration = true; - } - else - { - $this->currentClass[$openBraces] = null; - $this->inClassDeclaration = true; - } - break; - case T_INTERFACE: - case T_CLASS: - $this->currentClass[$openBraces] = null; - $this->inClassDeclaration = true; - break; - case T_FUNCTION: - $this->currentFunction[$openBraces] = null; - $this->inFunctionDeclaration = true; - break; - case T_STRING: - if (array_key_exists($openBraces, $this->currentClass) && is_null($this->currentClass[$openBraces])) - { - $this->currentClass[$openBraces] = $text; - } - if (array_key_exists($openBraces, $this->currentFunction) && is_null($this->currentFunction[$openBraces])) - { - $this->currentFunction[$openBraces] = $text; - } - break; - case T_AND_EQUAL: - case T_BREAK: - case T_CASE: - case T_CATCH: - case T_CLONE: - case T_CONCAT_EQUAL: - case T_CONTINUE: - case T_DEC: - case T_DECLARE: - case T_DEFAULT: - case T_DIV_EQUAL: - case T_DO: - case T_ECHO: - case T_ELSEIF: - case T_EMPTY: - case T_ENDDECLARE: - case T_ENDFOR: - case T_ENDFOREACH: - case T_ENDIF: - case T_ENDSWITCH: - case T_ENDWHILE: - case T_END_HEREDOC: - case T_EVAL: - case T_EXIT: - case T_FOR: - case T_FOREACH: - case T_GLOBAL: - case T_IF: - case T_INC: - case T_INCLUDE: - case T_INCLUDE_ONCE: - case T_INSTANCEOF: - case T_ISSET: - case T_IS_EQUAL: - case T_IS_GREATER_OR_EQUAL: - case T_IS_IDENTICAL: - case T_IS_NOT_EQUAL: - case T_IS_NOT_IDENTICAL: - case T_IS_SMALLER_OR_EQUAL: - case T_LIST: - case T_LOGICAL_AND: - case T_LOGICAL_OR: - case T_LOGICAL_XOR: - case T_MINUS_EQUAL: - case T_MOD_EQUAL: - case T_MUL_EQUAL: - case T_NEW: - case T_OBJECT_OPERATOR: - case T_OR_EQUAL: - case T_PLUS_EQUAL: - case T_PRINT: - case T_REQUIRE: - case T_REQUIRE_ONCE: - case T_RETURN: - case T_SL: - case T_SL_EQUAL: - case T_SR: - case T_SR_EQUAL: - case T_SWITCH: - case T_THROW: - case T_TRY: - case T_UNSET: - case T_UNSET_CAST: - case T_USE: - case T_WHILE: - case T_XOR_EQUAL: - $this->endOfCurrentExpr = false; - break; - } - - if ($this->endOfCurrentExpr) - { - $this->inAssignment = false; - } - - $this->beforeProcess($text, $id); - $this->process($text, $id); - $this->afterProcess($text, $id); - } - - if (!$this->continue) - { - break; - } - } - - return $this->getResult(); - } - - protected function beforeProcess($text, $id) - { - } - - protected function afterProcess($text, $id) - { - } - - /** - * Processes a token in the PHP code. - * - * @param string $text The string representation of the token - * @param integer $id The token identifier (f.i. T_VARIABLE) or NULL, if - * the token does not have an identifier. - */ - abstract protected function process($text, $id); - - /** - * Returns the result of the lexing process. - * - * @return mixed - */ - abstract protected function getResult(); - - /** - * Returns the line number at the current position of the lexer. - * - * @return integer - */ - protected function getCurrentLine() - { - return $this->currentLine; - } - - /** - * Returns the class name at the current position of the lexer. - * - * @return string Returns NULL if the current position is not inside a class. - */ - protected function getCurrentClass() - { - return $this->inClass() ? end($this->currentClass) : null; - } - - /** - * Returns the function name at the current position of the lexer. - * - * @return string Returns NULL if the current position is not inside a function. - */ - protected function getCurrentFunction() - { - return $this->inFunction() ? end($this->currentFunction) : null; - } - - /** - * Returns whether the current position of the lexer is inside a class. - * - * @return boolean - */ - protected function inClass() - { - return count($this->currentClass) > 0; - } - - /** - * Returns whether the current position of the lexer is inside a class - * declaration (f.i. "abstract class ClassName extends BaseClass"). - * - * @return boolean - */ - protected function inClassDeclaration() - { - return $this->inClassDeclaration; - } - - /** - * Returns whether the current position of the lexer is inside a function. - * - * @return boolean - */ - protected function inFunction() - { - return count($this->currentFunction) > 0; - } - - /** - * Returns whether the current position of the lexer is inside a function - * declaration (f.i. "protected function myFunctionName()"). - * - * @return boolean - */ - protected function inFunctionDeclaration() - { - return $this->inFunctionDeclaration; - } - - /** - * Returns how many functions are currently nested inside each other. - * - * @return integer - */ - protected function getFunctionNestingLevel() - { - return count($this->currentFunction); - } - - /** - * Returns whether the current token marks the end of the last expression. - * - * @return boolean - */ - protected function isEndOfCurrentExpr() - { - return $this->endOfCurrentExpr; - } - - /** - * Returns whether the current token is inside an assignment operation. - * - * @return boolean - */ - protected function inAssignment() - { - return $this->inAssignment; - } - - /** - * Tells the lexer to stop lexing. - */ - protected function stop() - { - $this->continue = false; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lexer/LimeLexerAnnotationAware.php b/tests/lib/vendor/lime/lexer/LimeLexerAnnotationAware.php deleted file mode 100644 index a84cef1baa112..0000000000000 --- a/tests/lib/vendor/lime/lexer/LimeLexerAnnotationAware.php +++ /dev/null @@ -1,213 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Analyzes PHP scripts taking annotations into account. - * - * Like LimeLexer, this class analyzes PHP scripts syntactically but is aware - * of annotations. Annotations are expected to be expressed using single - * line comments. Optionally, you can add a comment to the annotation, which - * needs to be separated from the annotation by any number of colons or spaces. - * - * - * // @Annotation: Optional comment - * - * - * You can extend this class if you want to write your own lexer that takes - * existing annotations into account. You have to pass a number of - * expected annotations to the constructor. Any other exception that is not - * passed in this array will result in an exception during parsing. - * - * - * $lexer = new CustomLexerAnnotationAware(array('Annotation1', 'Annotation2')); - * - * - * The following script will lead to an error when parsed: - * - * - * $i = 1; - * // @Annotation3 - * $i++; - * - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeLexerAnnotationAware.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeLexer - */ -abstract class LimeLexerAnnotationAware extends LimeLexer -{ - private - $allowedAnnotations, - $currentAnnotation, - $currentAnnotationComment, - $inAnnotation, - $inAnnotationDeclaration; - - /** - * Constructor. - * - * Accepts an array of expected annotation names as argument. Any annotation - * that is not listed in this array will cause an exception during parsing. - * - * @param array $allowedAnnotations The list of allowed annotations. - */ - public function __construct(array $allowedAnnotations = array()) - { - $this->allowedAnnotations = $allowedAnnotations; - } - - /** - * (non-PHPdoc) - * @see lexer/LimeLexer#parse($content) - */ - public function parse($content) - { - $this->currentAnnotation = null; - $this->currentAnnotationComment = null; - $this->inAnnotation = false; - $this->inAnnotationDeclaration = false; - - return parent::parse($content); - } - - /** - * (non-PHPdoc) - * @see lexer/LimeLexer#beforeProcess($text, $id) - */ - protected function beforeProcess($text, $id) - { - if (!$this->inClass() && !$this->inFunction() && $id = T_COMMENT && strpos($text, '//') === 0) - { - list($annotation, $comment) = $this->extractAnnotation($text); - - if (!is_null($annotation)) - { - $this->currentAnnotation = $annotation; - $this->currentAnnotationComment = $comment; - $this->inAnnotation = true; - $this->inAnnotationDeclaration = true; - } - } - else - { - $this->inAnnotationDeclaration = false; - } - } - - /** - * Returns whether the parser currently is within any annotation. - * - * All the code following an annotation declaration is considered to be - * inside this annotation's block. In annotated script, this method will thus - * only return false before the first annotation declaration. - * - * @return boolean TRUE if any annotation declaration preceded the current - * position of the lexer - */ - protected function inAnnotation() - { - return $this->inAnnotation; - } - - /** - * Returns whether the parser is currently inside an annotation declaration. - * - * An annotation declaration is any single line comment with a word that - * starts with "@" and any optional following comments. Annotations and - * comments have to be separated by one or more spaces or colons. - * - * - * // @Annotation: Optional comment - * - * - * @return boolean - */ - protected function inAnnotationDeclaration() - { - return $this->inAnnotationDeclaration; - } - - /** - * Returns the name of the currently active annotation. - * - * @return boolean - * @see inAnnotation() - */ - protected function getCurrentAnnotation() - { - return $this->currentAnnotation; - } - - /** - * Returns the comment of the currently active annotation. - * - * @return boolean - * @see inAnnotation() - */ - protected function getCurrentAnnotationComment() - { - return $this->currentAnnotationComment; - } - - /** - * Returns the array of allowed annotation names. - * - * This array can be set in the constructor. - * - * @return array - */ - protected function getAllowedAnnotations() - { - return $this->allowedAnnotations; - } - - /** - * Extracts an annotation from a single-line comment and validates it. - * - * Possible valid annotations are: - * - * // @Annotation - * // @Annotation: Some comment here - * - * - * The results for those annotations are: - * - * array('Annotation', null); - * array('Annotation', 'Some comment here'); - * - * - * @param string $text Some code - * - * @return array An array with the annotation name and the annotation - * comment. If either of both cannot be read, it is NULL. - */ - protected function extractAnnotation($text) - { - if (preg_match('/^\/\/\s*@(\w+)([:\s]+(.*))?\s*$/', $text, $matches)) - { - $annotation = $matches[1]; - $data = count($matches) > 3 ? trim($matches[3]) : null; - - if (!in_array($annotation, $this->allowedAnnotations)) - { - throw new LogicException(sprintf('The annotation "%s" is not valid', $annotation)); - } - - return array($annotation, $data); - } - else - { - return array(null, null); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lexer/LimeLexerCodeLines.php b/tests/lib/vendor/lime/lexer/LimeLexerCodeLines.php deleted file mode 100644 index 939ecb81b1492..0000000000000 --- a/tests/lib/vendor/lime/lexer/LimeLexerCodeLines.php +++ /dev/null @@ -1,100 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Processes a source file for the lines of code and returns the line numbers. - * - * The following rules apply for detecting LOC and are conformant with - * xdebug_get_code_coverage(): - * - * * identifier in function declaration == LOC - * * class declaration != LOC - * * method declaration != LOC - * * property declaration != LOC - * * } == LOC - * * { != LOC - * * { after class declaration == LOC - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeLexerCodeLines.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeLexerCodeLines extends LimeLexer -{ - private - $lines = array(); - - /** - * (non-PHPdoc) - * @see lexer/LimeLexer#parse($content) - */ - public function parse($content) - { - $this->lines = array(); - - return parent::parse($content); - } - - /** - * (non-PHPdoc) - * @see lexer/LimeLexer#process($text, $id) - */ - protected function process($text, $id) - { - // whitespace is ignored - if ($id == T_WHITESPACE) - { - return; - } - // PHP tags are ignored - else if ($id == T_OPEN_TAG || $id == T_CLOSE_TAG) - { - return; - } - // class declarations are ignored - else if ($this->inClassDeclaration()) - { - return; - } - // function declarations are ignored, except for the identifier - else if ($this->inFunctionDeclaration() && $id != T_STRING) - { - return; - } - // method declarations are ignored - else if ($this->inClass() && $this->inFunctionDeclaration()) - { - return; - } - // everything in classes except function body, the { and the } of the class is ignored - else if ($this->inClass() && !$this->inFunction() && $text != '{' && $text != '}') - { - return; - } - // { is ignored, except for after class declarations - else if ($text == '{' && !($this->inClass() && !$this->inFunction())) - { - return; - } - - $this->lines[$this->getCurrentLine()] = true; - } - - /** - * (non-PHPdoc) - * @see lexer/LimeLexer#getResult() - */ - protected function getResult() - { - return array_keys($this->lines); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lexer/LimeLexerTestVariable.php b/tests/lib/vendor/lime/lexer/LimeLexerTestVariable.php deleted file mode 100644 index 7f1f44b7087a6..0000000000000 --- a/tests/lib/vendor/lime/lexer/LimeLexerTestVariable.php +++ /dev/null @@ -1,89 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Extracts the first global variable containing a reference to an instance of - * LimeTest or any subclass from a source file. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeLexerTestVariable.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeLexerTestVariable extends LimeLexer -{ - const - NORMAL = 0, - VARIABLE = 1, - ASSIGNMENT = 2, - INSTANTIATION = 3; - - protected - $lastVariable = null, - $testVariable = null, - $state = self::NORMAL; - - /** - * This method implements a turing machine for variable assignments. - * - * Once a variable name is caught, the object is set to state VARIABLE. - * When the variable is succeeded by an assignment operator "=", the state - * is set to ASSIGNMENT. If the assignment operator is succeeded by the - * keyword "new", the state is set to INSTANTIATION. If the assignment - * operator is succeeded by a class name that inherits class LimeTest, - * processing is stopped and the variable name is returned. Otherwise, - * the state is reset and processing continues. - * - * @see LimeLexer#process($text, $id) - */ - protected function process($text, $id) - { - if ($id == T_VARIABLE && !$this->inFunction()) - { - $this->lastVariable = $text; - $this->state = self::VARIABLE; - } - else if ($text == '=' && $this->state == self::VARIABLE) - { - $this->state = self::ASSIGNMENT; - } - else if ($id == T_NEW && $this->state == self::ASSIGNMENT) - { - $this->state = self::INSTANTIATION; - } - else if ($id == T_STRING && $this->state == self::INSTANTIATION) - { - if (class_exists($text)) - { - $class = new ReflectionClass($text); - if ($text == 'LimeTest' || $class->isSubclassOf('LimeTest')) - { - $this->testVariable = $this->lastVariable; - $this->stop(); - } - } - $this->state = self::NORMAL; - } - else if ($id != T_WHITESPACE) - { - $this->state = self::NORMAL; - } - } - - /** - * (non-PHPdoc) - * @see LimeLexer#getResult() - */ - protected function getResult() - { - return $this->testVariable; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lexer/LimeLexerTransformAnnotations.php b/tests/lib/vendor/lime/lexer/LimeLexerTransformAnnotations.php deleted file mode 100644 index 9648021244ee1..0000000000000 --- a/tests/lib/vendor/lime/lexer/LimeLexerTransformAnnotations.php +++ /dev/null @@ -1,239 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Transforms annotated code in a file into functions. - * - * The created function names are returned by the function parse(), indexed - * by annotation name. - * - * - * $lexer = new LimeLexerTransformAnnotations('path/to/transformed/file.php', array('First', 'Second')); - * $functions = $lexer->parse('/path/to/original/file.php'); - * - * // => array('First' => array(...), 'Second' => array(...)) - * - * - * The annotated source file for the above code could look like this: - * - * - * $test = 'nothing'; - * - * // @First - * $test = 'First'; - * - * // @Second - * $test = 'Second'; - * - * // @First - * echo $test; - * - * - * You can include the transformed file and execute a certain subset of - * annotations: - * - * - * include 'path/to/transformed/file.php'; - * - * foreach ($functions['First'] as $function) - * { - * $function(); - * } - * - * // => First - * - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeLexerTransformAnnotations.php 25934 2009-12-27 20:44:07Z bschussek $ - * @see LimeLexerAnnotationAware - */ -class LimeLexerTransformAnnotations extends LimeLexerAnnotationAware -{ - protected static - $annotations = array('Test', 'Before', 'After', 'BeforeAll', 'AfterAll'); - - protected - $fileName, - $file, - $variables, - $functions, - $functionCount, - $initialized, - $testVariable, - $classBuffer, - $classNotLoaded, - $firstAnnotation; - - /** - * Constructor. - * - * @param string $targetFile The file where the transformed code - * will be written. - * @param array $allowedAnnotations The allowed annotations. - */ - public function __construct($targetFile) - { - parent::__construct(self::$annotations); - - $this->fileName = $targetFile; - } - - /** - * Transforms the annoated code in the given file and writes it to the - * target file. - * - * @see LimeLexer#parse($content) - */ - public function parse($content) - { - if (is_readable($content)) - { - $content = file_get_contents($content); - } - - $lexer = new LimeLexerVariables($this->getAllowedAnnotations(), array('Before')); - $this->variables = $lexer->parse($content); - - $lexer = new LimeLexerTestVariable(); - $this->testVariable = $lexer->parse($content); - - $this->initialized = false; - $this->functionCount = 0; - $this->functions = array(); - $this->classBuffer = ''; - $this->classNotLoaded = false; - $this->firstAnnotation = true; - - foreach ($this->getAllowedAnnotations() as $annotation) - { - $this->functions[$annotation] = array(); - } - - // backup the contents for the case that the path == filename - $this->file = fopen($this->fileName, 'w'); - - $result = parent::parse($content); - - if ($this->inAnnotation()) - { - fwrite($this->file, "\n}"); - } - - fclose($this->file); - - return $result; - } - - /** - * Returns the name of the first global variable that contains an instance - * of LimeTest or any subclass. - * - * If no such variable could be detected, NULL is returned. - * - * @return string - */ - public function getTestVariable() - { - return $this->testVariable; - } - - /** - * (non-PHPdoc) - * @see LimeLexer#process($text, $id) - */ - protected function process($text, $id) - { - if (!$this->inClassDeclaration()) - { - $this->classBuffer = ''; - } - - if (!$this->inClass()) - { - $this->classNotLoaded = false; - } - - // Some classes are automatically loaded when the script is opened, others - // are not. These other classes need to be left in the source code, - // otherwise they cannot be instantiated later. - // This functionality is covered in LimeAnnotationSupportTest 11+12 - if ($this->inClassDeclaration()) - { - if ($this->getCurrentClass() && !class_exists($this->getCurrentClass()) && !interface_exists($this->getCurrentClass())) - { - $this->classNotLoaded = true; - $text = $this->classBuffer.$text; - $this->classBuffer = ''; - } - else - { - $this->classBuffer .= $text; - } - } - - // Closures and anonymous functions should not be stripped from the output - if ($this->inFunction()) - { - if ($this->inFunctionDeclaration()) - { - $this->functionBuffer .= $text; - $text = ''; - } - // if the name of the function is NULL, it is a closure/anonymous function - else if (!$this->getCurrentFunction() || $this->inClass()) - { - $text = $this->functionBuffer.$text; - $this->functionBuffer = ''; - } - else - { - $text = str_repeat("\n", count(explode("\n", $this->functionBuffer.$text)) - 1); - $this->functionBuffer = ''; - } - } - - if ($id == T_OPEN_TAG && !$this->initialized) - { - if (count($this->variables)) - { - $text .= 'global '.implode(', ', $this->variables).';'; - } - $this->initialized = true; - } - else if ($this->inClass() && !$this->classNotLoaded) - { - $text = str_repeat("\n", count(explode("\n", $text)) - 1); - } - else if ($this->inAnnotationDeclaration()) - { - $functionName = '__lime_annotation_'.($this->functionCount++); - $this->functions[$this->getCurrentAnnotation()][] = array($functionName, $this->getCurrentAnnotationComment()); - - $text = $this->firstAnnotation ? '' : '} '; - $this->firstAnnotation = false; - $variables = count($this->variables) ? sprintf('global %s;', implode(', ', $this->variables)) : ''; - $text .= sprintf("function %s() { %s\n", $functionName, $variables); - } - - fwrite($this->file, $text); - } - - /** - * (non-PHPdoc) - * @see LimeLexer#getResult() - */ - protected function getResult() - { - return $this->functions; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lexer/LimeLexerVariables.php b/tests/lib/vendor/lime/lexer/LimeLexerVariables.php deleted file mode 100644 index 6cc980ee12dce..0000000000000 --- a/tests/lib/vendor/lime/lexer/LimeLexerVariables.php +++ /dev/null @@ -1,65 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Extracts all global variables from a source file. - * - * This lexer includes all global variables that are not inside annotations, - * except variables from the scope of the annotations passed to the constructor, - * which are included as well. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeLexerVariables.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeLexerVariables extends LimeLexerAnnotationAware -{ - protected - $includedAnnotations = array(), - $variables = array(); - - /** - * Constructor. - * - * @param array $allowedAnnotations The list of allowed annotation names - * @param array $includedAnnotations The list of annotation names whose - * variables are considered global - */ - public function __construct(array $allowedAnnotations = array(), array $includedAnnotations = array()) - { - parent::__construct($allowedAnnotations); - - $this->includedAnnotations = $includedAnnotations; - } - - /** - * (non-PHPdoc) - * @see LimeLexer#process($text, $id) - */ - protected function process($text, $id) - { - if ($id == T_VARIABLE && !$this->inClass() && !$this->inFunction() - && (!$this->inAnnotation() || in_array($this->getCurrentAnnotation(), $this->includedAnnotations))) - { - $this->variables[] = $text; - } - } - - /** - * (non-PHPdoc) - * @see LimeLexer#getResult() - */ - protected function getResult() - { - return array_unique($this->variables); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/lime.php b/tests/lib/vendor/lime/lime.php deleted file mode 100644 index 2b91fee20ed18..0000000000000 --- a/tests/lib/vendor/lime/lime.php +++ /dev/null @@ -1,393 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -require_once dirname(__FILE__).'/LimeAutoloader.php'; - -LimeAutoloader::enableLegacyMode(); -LimeAutoloader::register(); - -class lime_test extends LimeTest -{ - public function __construct($plan = null, $options = array()) - { - // for BC - if (!is_array($options)) - { - $options = array(); // drop the old output because it is not compatible with LimeTest - } - - parent::__construct($plan, $options); - } - - static public function to_array() - { - return self::toArray(); - } - - static public function to_xml($results = null) - { - return self::toXml($results); - } - - /** - * Compares two arguments with an operator - * - * @param mixed $exp1 left value - * @param string $op operator - * @param mixed $exp2 right value - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function cmp_ok($exp1, $op, $exp2, $message = '') - { - switch ($op) - { - case '===': - return $this->same($exp1, $exp2, $message); - case '!==': - return $this->isntSame($exp1, $exp2, $message); - case '==': - return $this->is($exp1, $exp2, $message); - case '!=': - return $this->isnt($exp1, $exp2, $message); - case '<': - return $this->lessThan($exp1, $exp2, $message); - case '<=': - return $this->lessThanEqual($exp1, $exp2, $message); - case '>': - return $this->greaterThan($exp1, $exp2, $message); - case '>=': - return $this->greaterThanEqual($exp1, $exp2, $message); - default: - throw new InvalidArgumentException(sprintf('Unknown operation "%s"', $op)); - } - } - - /** - * Checks the availability of a method for an object or a class - * - * @param mixed $object an object instance or a class name - * @param string|array $methods one or more method names - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function can_ok($object, $methods, $message = '') - { - $result = true; - $failedMessages = array(); - foreach ((array) $methods as $method) - { - if (!method_exists($object, $method)) - { - $failedMessages[] = sprintf("method '%s' does not exist", $method); - $result = false; - } - } - - return $this->test_ok($result, $message, implode("\n", $failedMessages)); - } - - /** - * Checks the type of an argument - * - * @param mixed $var variable instance - * @param string $class class or type name - * @param string $message display output message when the test passes - * - * @return boolean - */ - public function isa_ok($var, $class, $message = '') - { - $type = is_object($var) ? get_class($var) : gettype($var); - $error = sprintf("variable isn't a '%s' it's a '%s'", $class, $type); - - return $this->test_ok($type == $class, $message, $error); - } - - public function is_deeply($exp1, $exp2, $message = '') - { - return $this->is($exp1, $exp2, $message); - } - - public function include_ok($file, $message = '') - { - return $this->includeOk($file, $message); - } - - public function error($message) - { - list($file, $line) = LimeTrace::findCaller('lime_test'); - - $this->output->error(new LimeError($message, $file, $line)); - } - - /** - * @deprecated Use comment() instead - * @param $message - * @return unknown_type - */ - public function info($message) - { - if ($this->output instanceof LimeOutputTap) - { - $this->output->info($message); - } - } - - private function test_ok($condition, $message, $error = null) - { - list ($file, $line) = LimeTrace::findCaller('LimeTest'); - - if ($result = (boolean) $condition) - { - $this->output->pass($message, $file, $line); - } - else - { - $this->output->fail($message, $file, $line, $error); - } - - return $result; - } -} - -class lime_output -{ - const - ERROR = 'ERROR', - INFO = 'INFO', - PARAMETER = 'PARAMETER', - COMMENT = 'COMMENT', - GREEN_BAR = 'GREEN_BAR', - RED_BAR = 'RED_BAR', - INFO_BAR = 'INFO_BAR'; - - protected static - $styles = array(self::ERROR, self::INFO, self::PARAMETER, self::COMMENT, self::GREEN_BAR, self::RED_BAR, self::INFO_BAR); - - protected - $colorizer = null; - - /** - * Constructor. - * - * @param boolean $forceColors If set to TRUE, colorization will be enforced - * whether or not the current console supports it - */ - public function __construct($forceColors = false) - { - if (LimeColorizer::isSupported() || $forceColors) - { - $colorizer = new LimeColorizer(); - $colorizer->setStyle(self::ERROR, array('bg' => 'red', 'fg' => 'white', 'bold' => true)); - $colorizer->setStyle(self::INFO, array('fg' => 'green', 'bold' => true)); - $colorizer->setStyle(self::PARAMETER, array('fg' => 'cyan')); - $colorizer->setStyle(self::COMMENT, array('fg' => 'yellow')); - $colorizer->setStyle(self::GREEN_BAR, array('fg' => 'white', 'bg' => 'green', 'bold' => true)); - $colorizer->setStyle(self::RED_BAR, array('fg' => 'white', 'bg' => 'red', 'bold' => true)); - $colorizer->setStyle(self::INFO_BAR, array('fg' => 'cyan', 'bold' => true)); - - $this->colorizer = $colorizer; - } - } - - /** - * Colorizes the given text with the given style. - * - * @param string $text Some text - * @param string $style One of the predefined style constants - * @return string The formatted text - */ - protected function colorize($text, $style) - { - if (!in_array($style, self::$styles)) - { - throw new InvalidArgumentException(sprintf('The style "%s" does not exist', $style)); - } - - return is_null($this->colorizer) ? $text : $this->colorizer->colorize($text, $style); - } - - /** - * ? - */ - public function diag() - { - $messages = func_get_args(); - foreach ($messages as $message) - { - echo $this->colorize('# '.join("\n# ", (array) $message), self::COMMENT)."\n"; - } - } - - /** - * Prints a comment. - * - * @param string $message - */ - public function comment($message) - { - echo $this->colorize(sprintf('# %s', $message), self::COMMENT)."\n"; - } - - /** - * Prints an informational message. - * - * @param string $message - */ - public function info($message) - { - echo $this->colorize(sprintf('> %s', $message), self::INFO_BAR)."\n"; - } - - /** - * Prints an error. - * - * @param string $message - */ - public function error($message) - { - echo $this->colorize(sprintf(' %s ', $message), self::RED_BAR)."\n"; - } - - /** - * Prints and automatically colorizes a line. - * - * You can wrap the whole line into a specific predefined style by passing - * the style constant in the second parameter. - * - * @param string $message The message to colorize - * @param string $style The desired style constant - * @param boolean $colorize Whether to automatically colorize parts of the - * line - */ - public function echoln($message, $style = null, $colorize = true) - { - if ($colorize) - { - $message = preg_replace('/(?:^|\.)((?:not ok|dubious) *\d*)\b/e', '$this->colorize(\'$1\', self::ERROR)', $message); - $message = preg_replace('/(?:^|\.)(ok *\d*)\b/e', '$this->colorize(\'$1\', self::INFO)', $message); - $message = preg_replace('/"(.+?)"/e', '$this->colorize(\'$1\', self::PARAMETER)', $message); - $message = preg_replace('/(\->|\:\:)?([a-zA-Z0-9_]+?)\(\)/e', '$this->colorize(\'$1$2()\', self::PARAMETER)', $message); - } - - echo ($style ? $this->colorize($message, $style) : $message)."\n"; - } - - /** - * Prints a message in a green box. - * - * @param string $message - */ - public function greenBar($message) - { - echo $this->colorize($message.str_repeat(' ', 71 - min(71, strlen($message))), self::GREEN_BAR)."\n"; - } - - /** - * Prints a message a in a red box. - * - * @param string $message - */ - public function redBar($message) - { - echo $this->colorize($message.str_repeat(' ', 71 - min(71, strlen($message))), self::RED_BAR)."\n"; - } -} - -class lime_output_color extends lime_output -{ -} - -class lime_colorizer extends LimeColorizer -{ - protected static - $instances = array(), - $staticStyles = array(); - - public function __construct() - { - self::$instances[] = $this; - $this->styles = self::$staticStyles; - } - - public static function style($name, $options = array()) - { - foreach (self::$instances as $instance) - { - $instance->setStyle($name, $options); - } - self::$staticStyles[$name] = $options; - } -} - -class lime_harness extends LimeTestSuite -{ - public function __construct($options = array()) - { - // for BC - if (!is_array($options)) - { - $options = array(); // drop the old output because it is not compatible with LimeTest - } - else if (array_key_exists('php_cli', $options)) - { - $options['executable'] = $options['php_cli']; - unset($options['php_cli']); - } - - parent::__construct($options); - } - - public function to_array() - { - return $this->toArray(); - } - - public function to_xml() - { - return $this->toXml(); - } - - public function get_failed_files() - { - return $this->output->getFailedFiles(); - } -} - -class lime_coverage extends LimeCoverage -{ - public static function get_php_lines($content) - { - return self::getPhpLines($content); - } - - public function format_range($lines) - { - return $this->formatRange($lines); - } -} - -class lime_registration extends LimeRegistration -{ - public function register_glob($glob) - { - return $this->registerGlob($glob); - } - - public function register_dir($directory) - { - return $this->registerDir($directory); - } -} diff --git a/tests/lib/vendor/lime/mock/LimeMock.php b/tests/lib/vendor/lime/mock/LimeMock.php deleted file mode 100644 index c0060c3ab7b4d..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMock.php +++ /dev/null @@ -1,345 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Generates mock objects - * - * This class generates configurable mock objects based on existing interfaces, - * classes or virtual (non-existing) class names. You can use it to create - * objects of classes that you have not implemented yet, or to substitute - * an existing class in a test. - * - * A mock object is created with the create() method: - * - * - * $mock = LimeMock::create('MyClass', $output); - * - * - * Note: The LimeTest class offers an easy access to preconfigured mocks and - * stubs using the methods mock() and stub(). - * - * Initially the mock is in recording mode. In this mode you just make the - * expected method calls with the expected parameters. You can use modifiers - * to configure return values or exceptions that should be thrown. - * - * - * // method "someMethod()" returns "return value" when called with "parameter" - * $mock->someMethod('parameter')->returns('return value'); - * - * - * You can find the complete list of method modifiers in class - * LimeMockInvocationExpectation. By default, expected methods are initialized - * with the modifier once(). If the option "nice" is set, the method is - * initialized with the modifier any() instead. - * - * Once the recording is over, you must call the method replay() on the mock. - * After the call to this method, the mock is in replay mode. In this mode, it - * listens for method calls and returns the results configured before. - * - * - * $mock = LimeMock::create('MyClass', $output); - * $mock->add(1, 2)->returns(3); - * $mock->replay(); - * - * echo $mock->add(1, 2); - * // returns 3 - * - * - * You also have the possibility to find out whether all the configured - * methods have been called with the right parameters while in replay mode - * by calling verify(). - * - * - * $mock = LimeMock::create('MyClass', $output); - * $mock->add(1,2); - * $mock->replay(); - * $mock->add(1); - * $mock->verify(); - * - * // results in a failing test - * - * - * The method create() accepts several options to configure the created mock: - * - * * strict: If set to TRUE, the mock expects methods to be - * called in the same order in which they were recorded. - * Additionally, method parameters will be compared - * with strict typing. Default: FALSE - * * generate_controls: If set to FALSE, the mock's control methods - * replay(), verify() etc. will not be generated. - * Setting this option is useful when the mocked - * class contains any of these methods. You then have - * to access the control methods statically in this - * class, f.i. LimeMock::replay($mock); - * Default: TRUE - * * stub_methods: If set to FALSE, method implementations in the - * mocked class are called when a method is not - * configured to be stubbed. Default: TRUE - * * nice: See LimeMockBehaviour - * * no_exceptions: See LimeMockBehaviour - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMock.php 24994 2009-12-06 21:02:45Z bschussek $ - * @see LimeMockBehaviour - * @see LimeMockInvocationExpectation - */ -class LimeMock -{ - protected static - $methodTemplate = '%s function %s(%s) { $args = func_get_args(); return $this->__call(\'%s\', $args); }', - $parameterTemplate = '%s %s', - $parameterWithDefaultTemplate = '%s %s = %s', - - $illegalMethods = array( - '__construct', - '__call', - '__lime_replay', - '__lime_getState', - ), - - $controlMethods = array( - 'replay', - 'any', - 'reset', - 'verify', - 'setExpectNothing', - ); - - /** - * Creates a new mock object for the given class or interface name. - * - * The class/interface does not necessarily have to exist. Every generated - * object fulfills the condition ($mock instanceof $class). - * - * @param string $classOrInterface The (non-)existing class/interface - * you want to mock - * @param LimeOutputInterface $output The output for displaying the test results - * @param array $options Generation options. See the class - * description for more information. - * @return LimeMockInterface The mock object - */ - public static function create($classOrInterface, LimeOutputInterface $output, array $options = array()) - { - $options = array_merge(array( - 'strict' => false, - 'generate_controls' => true, - 'stub_methods' => true, - ), $options); - - if ($options['strict']) - { - $behaviour = new LimeMockOrderedBehaviour($options); - } - else - { - $behaviour = new LimeMockUnorderedBehaviour($options); - } - - $name = self::generateClass($classOrInterface, $options['generate_controls']); - - return new $name($classOrInterface, $behaviour, $output, $options['stub_methods']); - } - - /** - * Generates a mock class for the given class/interface name and returns - * the generated class name. - * - * @param string $classOrInterface The mocked class/interface name - * @param boolean $generateControls Whether control methods should be generated. - * @return string The generated class name - */ - protected static function generateClass($classOrInterface, $generateControls = true) - { - $methods = ''; - - if (!class_exists($classOrInterface, false) && !interface_exists($classOrInterface, false)) - { - if (($pos = strpos($classOrInterface, '\\')) !== false) - { - $namespace = substr($classOrInterface, 0, $pos); - $interface = substr($classOrInterface, $pos+1); - - eval(sprintf('namespace %s { interface %s {} }', $namespace, $interface)); - } - else - { - eval(sprintf('interface %s {}', $classOrInterface)); - } - } - - $class = new ReflectionClass($classOrInterface); - foreach ($class->getMethods() as $method) - { - /* @var $method ReflectionMethod */ - if (in_array($method->getName(), self::$controlMethods) && $generateControls) - { - throw new LogicException(sprintf('The mocked class "%s" contains the method "%s", which conflicts with the mock\'s control methods. Please set the option "generate_controls" to false.', $classOrInterface, $method->getName())); - } - - if (!in_array($method->getName(), self::$illegalMethods) && !$method->isFinal()) - { - $modifiers = Reflection::getModifierNames($method->getModifiers()); - $modifiers = array_diff($modifiers, array('abstract')); - $modifiers = implode(' ', $modifiers); - - $parameters = array(); - - foreach ($method->getParameters() as $parameter) - { - $typeHint = ''; - - /* @var $parameter ReflectionParameter */ - if ($parameter->getClass()) - { - $typeHint = $parameter->getClass()->getName(); - } - else if ($parameter->isArray()) - { - $typeHint = 'array'; - } - - $name = '$'.$parameter->getName(); - - if ($parameter->isPassedByReference()) - { - $name = '&'.$name; - } - - if ($parameter->isOptional()) - { - $default = var_export($parameter->getDefaultValue(), true); - $parameters[] = sprintf(self::$parameterWithDefaultTemplate, $typeHint, $name, $default); - } - else - { - $parameters[] = sprintf(self::$parameterTemplate, $typeHint, $name); - } - } - - $methods .= sprintf(self::$methodTemplate, $modifiers, $method->getName(), - implode(', ', $parameters), $method->getName())."\n "; - } - } - - $interfaces = array(); - - $name = self::generateName($class->getName()); - - $declaration = 'class '.$name; - - if ($class->isInterface()) - { - $interfaces[] = $class->getName(); - } - else - { - $declaration .= ' extends '.$class->getName(); - } - - $interfaces[] = 'LimeMockInterface'; - - if (count($interfaces) > 0) - { - $declaration .= ' implements '.implode(', ', $interfaces); - } - - $template = new LimeMockTemplate(dirname(__FILE__).'/template/mocked_class.tpl'); - - eval($template->render(array( - 'class_declaration' => $declaration, - 'methods' => $methods, - 'generate_controls' => $generateControls, - ))); - - return $name; - } - - /** - * Generates a mock class name for the given original class/interface name. - * - * @param string $originalName - * @return string - */ - protected static function generateName($originalName) - { - // strip namespace separators - $originalName = str_replace('\\', '_', $originalName); - - while (!isset($name) || class_exists($name, false)) - { - // inspired by PHPUnit_Framework_MockObject_Generator - $name = 'Mock_'.$originalName.'_'.substr(md5(microtime()), 0, 8); - } - - return $name; - } - - /** - * Turns the given mock into replay mode. - * - * @param LimeMockInterface $mock - */ - public static function replay(LimeMockInterface $mock) - { - return $mock->__lime_replay(); - } - - /** - * Resets the given mock. - * - * All expected invocations are removed, the mock is set to record mode again. - * - * @param LimeMockInterface $mock - */ - public static function reset(LimeMockInterface $mock) - { - return $mock->__lime_reset(); - } - - /** - * Expects the given method on the given mock to be called with any parameters. - * - * The LimeMockInvocationExpectation object is returned and allows you to - * set further modifiers on the method expectation. - * - * @param LimeMockInterface $mock - * @param string $methodName - * @return LimeMockInvocationExpectation - */ - public static function any(LimeMockInterface $mock, $methodName) - { - return $mock->__call($methodName, null); - } - - /** - * Configures the mock to expect no method call. - * - * @param LimeMockInterface $mock - */ - public static function setExpectNothing(LimeMockInterface $mock) - { - return $mock->__lime_getState()->setExpectNothing(); - } - - /** - * Verifies the given mock. - * - * @param LimeMockInterface $mock - */ - public static function verify(LimeMockInterface $mock) - { - return $mock->__lime_getState()->verify(); - } -} - - diff --git a/tests/lib/vendor/lime/mock/LimeMockBehaviour.php b/tests/lib/vendor/lime/mock/LimeMockBehaviour.php deleted file mode 100644 index 279713d4707ee..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockBehaviour.php +++ /dev/null @@ -1,140 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Provides common methods of all implemented behaviours. - * - * Behaviours accept the following options for initialization: - * - * * strict: If set to TRUE, the behaviour initializes all mocked - * methods with the modifier strict() to enable strict - * type comparison. Default: FALSE - * * nice: If set to TRUE, the behaviour will ignore unexpected - * method calls. Mocked methods will be initialized - * with the modifier any(). Default: FALSE - * * no_exceptions: If set to TRUE, throwing of exceptions is - * suppressed when unexpected methods are called. - * The methods will be reported as errors when - * verify() is called. Default: FALSE - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockBehaviour.php 23880 2009-11-14 10:14:34Z bschussek $ - * @see LimeMockBehaviourInterface - */ -abstract class LimeMockBehaviour implements LimeMockBehaviourInterface -{ - protected - $options = array(), - $verified = false, - $invocations = array(), - $expectNothing = false; - - /** - * Constructor. - * - * @param array $options The options for initializing the behaviour. - * @return unknown_type - */ - public function __construct(array $options = array()) - { - $this->options = array_merge(array( - 'strict' => false, - 'nice' => false, - 'no_exceptions' => false, - ), $options); - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviourInterface#expect($invocation) - */ - public function expect(LimeMockInvocationExpectation $invocation) - { - $this->invocations[] = $invocation; - - if ($this->options['strict']) - { - $invocation->strict(); - } - - if ($this->options['nice']) - { - $invocation->any(); - } - else - { - $invocation->once(); - } - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviourInterface#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - if (!$this->options['nice'] && !$this->verified && !$this->options['no_exceptions'] && ($this->expectNothing || count($this->invocations) > 0)) - { - throw new LimeMockInvocationException($invocation, 'was not expected to be called'); - } - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviourInterface#isInvokable($method) - */ - public function isInvokable(LimeMockMethod $method) - { - foreach ($this->invocations as $invocation) - { - if ($invocation->matches($method)) - { - return true; - } - } - - return false; - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviourInterface#verify() - */ - public function verify() - { - foreach ($this->invocations as $invocation) - { - $invocation->verify(); - } - - $this->verified = true; - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviourInterface#setExpectNothing() - */ - public function setExpectNothing() - { - $this->expectNothing = true; - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviourInterface#reset() - */ - public function reset() - { - $this->invocations = array(); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockBehaviourInterface.php b/tests/lib/vendor/lime/mock/LimeMockBehaviourInterface.php deleted file mode 100644 index fb05d2936a7a8..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockBehaviourInterface.php +++ /dev/null @@ -1,84 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * A behaviour specifies how the mock compares expected method invocations with - * actual method invocations. - * - * The behaviour is fed with different invocation expectations by calling the - * method expect(). Later, the method invoke() is called for all actual - * invocations. The behaviour has to decide which expectations to compare - * with incoming actual invocations. One behaviour implementation may, for - * example, decide to accept invoked invocations only if they are called - * in the same order as the invocation expectations. - * - * In the end, verify() can be called on the behaviour to verify whether all - * expectations have been met. - * - * The behaviour should pass the matching of methods and method verification - * to LimeMockInvocationExpectation. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockBehaviourInterface.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -interface LimeMockBehaviourInterface -{ - /** - * Adds the following invocation expectation. - * - * @param LimeMockInvocationExpectation $invocation - */ - public function expect(LimeMockInvocationExpectation $invocation); - - /** - * Invokes the given method invocation. - * - * If the method invocation is not expected, this method should throw a - * LimeMockInvocationException. Otherwise the call should be passed to - * the method invoke() of LimeMockInvocationExpectation, its return value - * should be returned. - * - * @param LimeMockInvocation $invocation The invoked method - * @return mixed The return value of - * LimeMockInvocationExpectation#invoke() - * @throws LimeMockInvocationException If the method should not have been - * invoked - */ - public function invoke(LimeMockInvocation $invocation); - - /** - * Returns whether the given method is invokable. - * - * @param LimeMockMethod $method The method - * @return boolean TRUE if the method is invokable - */ - public function isInvokable(LimeMockMethod $method); - - /** - * Verifies whether all expectations have been fulfilled. - * - * You should call LimeMockInvocationExpectation#verify() to implement this - * method. - */ - public function verify(); - - /** - * Configures the behaviour to expect no method to be invoked. - */ - public function setExpectNothing(); - - /** - * Clears all invocation expectations in the behaviour. - */ - public function reset(); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockException.php b/tests/lib/vendor/lime/mock/LimeMockException.php deleted file mode 100644 index 6d6a8a7c165b5..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockException.php +++ /dev/null @@ -1,26 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * An exception thrown from mock objects. - * - * This exception is generally thrown if you invoke an unexpected method on - * a mock object while in replay mode. Generally this exception should bubble - * up to notify the user about test errors. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockException.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeMockException extends Exception -{ -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockInterface.php b/tests/lib/vendor/lime/mock/LimeMockInterface.php deleted file mode 100644 index f5ee53b24cf0a..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockInterface.php +++ /dev/null @@ -1,73 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * This interface is implemented by all mock objects. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInterface.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMock - */ -interface LimeMockInterface -{ - /** - * Constructor. - * - * @param string $class The name of the mocked class - * @param LimeMockBehaviourInterface $behaviour The behaviour for invocation - * comparisons. - * @param LimeOutputInterface $output The output for displaying - * the comparison results. - */ - public function __construct($class, LimeMockBehaviourInterface $behaviour, LimeOutputInterface $output); - - /** - * Invokes the given method. - * - * The mock reacts accordingly depending on whether it is in record or in - * replay mode. In record mode, mocks return an instance of - * LimeMockInvocationExpectation, which you can use to further configure - * the expected invocation. In replay mode, the configured return value - * is returned. If you configured the method to throw an exception, this - * exception will be thrown here. - * - * @param string $method The method - * @param array $parameters The method parameters - * @return LimeMockInvocationExpectation|mixed - * @throws LimeMockException If the method should not have been invoked - * @throws Exception If you configured the mock to throw an exception - */ - public function __call($method, $parameters); - - /** - * Switches the mock object into replay mode. - * - * @throws BadMethodCallException If the object already is in replay mode - */ - public function __lime_replay(); - - /** - * Resets all expected invocations in the mock and switches it into record - * mode. - * - * @see LimeMockBehaviourInterface#reset() - */ - public function __lime_reset(); - - /** - * Returns the object representing the current state of the mock. - * - * @return LimeMockStateInterface - */ - public function __lime_getState(); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockInvocation.php b/tests/lib/vendor/lime/mock/LimeMockInvocation.php deleted file mode 100644 index 9c58d5ba3c354..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockInvocation.php +++ /dev/null @@ -1,134 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Represents the invocation of a class or object method with a set of - * parameters. - * - * This class is used internally by LimeMockControl to track the method - * invocations on mock objects. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocation.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -class LimeMockInvocation implements LimeMockMethodInterface -{ - protected - $method = null, - $parameters = array(); - - /** - * Constructor. - * - * @param string $method The method name - * @param array $parameters The method parameters - */ - public function __construct(LimeMockMethod $method, array $parameters = array()) - { - $this->method = $method; - $this->parameters = $parameters; - } - - /** - * Returns the class name. - * - * @return string - */ - public function getClass() - { - return $this->method->getClass(); - } - - /** - * Returns the method name. - * - * @return string - */ - public function getMethod() - { - return $this->method->getMethod(); - } - - /** - * Returns the method parameters. - * - * @return array The parameter array - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * Returns the parameter at the given index. - * - * @param integer $index - * @return mixed - */ - public function getParameter($index) - { - if ($index >= count($this->parameters)) - { - throw new OutOfRangeException(sprintf('The parameter %s does not exist', $index)); - } - - return $this->parameters[$index]; - } - - /** - * Returns a string representation of the method call invocation. - * - * The result looks like a method call in PHP source code. - * - * Example: - * - * $invocation = new LimeMockMethodInvocation('doSomething', array(1, 'foobar')); - * print $invocation; - * - * // => "doSomething(1, 'foobar')" - * - * - * @return string - */ - public function __toString() - { - $parameters = $this->parameters; - - if (is_array($parameters)) - { - foreach ($parameters as $key => $value) - { - if (is_string($value)) - { - $value = str_replace(array("\0", "\n", "\t", "\r"), array('\0', '\n', '\t', '\r'), $value); - $value = strlen($value) > 30 ? substr($value, 0, 30).'...' : $value; - $parameters[$key] = '"'.$value.'"'; - } - else if (is_object($value)) - { - $parameters[$key] = get_class($value); - } - else if (is_array($value)) - { - $parameters[$key] = 'array'; - } - else - { - $parameters[$key] = var_export($value, true); - } - } - } - - return sprintf('%s(%s)', $this->method->getMethod(), implode(', ', (array)$parameters)); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockInvocationException.php b/tests/lib/vendor/lime/mock/LimeMockInvocationException.php deleted file mode 100644 index 7ab03061a0dbe..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockInvocationException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Thrown when a method invocation should not have been made. - * - * This exception is usually wrapped inside a LimeMockInvocation and should not - * bubble up. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationException.php 23864 2009-11-13 18:06:20Z bschussek $ - */ -class LimeMockInvocationException extends Exception -{ - /** - * Constructor. - * - * @param LimeMockInvocation $invocation The erroneous method invocation - * @param string $message The message describing why the - * invocation should not have been - * made. The message is appended - * at the method name. - */ - public function __construct(LimeMockInvocation $invocation, $message) - { - parent::__construct($invocation.' '.$message); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockInvocationExceptionStack.php b/tests/lib/vendor/lime/mock/LimeMockInvocationExceptionStack.php deleted file mode 100644 index 1d488a69f1065..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockInvocationExceptionStack.php +++ /dev/null @@ -1,67 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Collects a number of LimeMockInvocationException objects. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationExceptionStack.php 24352 2009-11-24 19:49:42Z bschussek $ - */ -class LimeMockInvocationExceptionStack extends LimeMockInvocationException -{ - protected - $exceptions = array(); - - /** - * Ignores the parent constructor. - */ - public function __construct() {} - - /** - * Adds a new exception to the stack. - * - * The stack message is updated to contain the message of the exception. - * - * @param LimeMockInvocationException $exception - */ - public function add(LimeMockInvocationException $exception) - { - $this->exceptions[] = $exception; - - if (count($this->exceptions) > 1) - { - $this->message = "One of the following errors occured:\n"; - - for ($i = 1; $i <= count($this->exceptions); ++$i) - { - $message = LimeTools::indent(wordwrap($this->exceptions[$i-1]->getMessage(), 70), strlen($i)+2); - - $this->message .= sprintf("%s) %s\n", $i, trim($message)); - } - } - else - { - $this->message = $this->exceptions[0]->getMessage(); - } - } - - /** - * Returns TRUE when the stack contains no exceptions, FALSE otherwise. - * - * @return boolean - */ - public function isEmpty() - { - return count($this->exceptions) == 0; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockInvocationExpectation.php b/tests/lib/vendor/lime/mock/LimeMockInvocationExpectation.php deleted file mode 100644 index 9e7546e1c479d..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockInvocationExpectation.php +++ /dev/null @@ -1,462 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Represents an expected method invocation. - * - * Instances of this class are returned when you record a new method call on - * a mock object while in record mode. You can then use this instance specify - * further modifiers, like how often the method is expected to be called, - * whether it is expected to be called with the same parameter types etc. - * - * The modifiers of this class support method chaining. - * - * - * $mock = LimeMock::create('MyClass', $output); - * $mock->doSomething(); - * // returns LimeMockInvocationExpectation - * - * // let's use the returned object to configure the invocation - * $mock->doSomething()->atLeastOnce()->returns('some value'); - * - * - * You must inform this object of an invoked method by calling invoke(). When - * that is done, you can use verify() to find out whether all the modifiers - * succeeded, i.e. whether the method was called a sufficient number of times - * etc. The results of the verification are then written to the output. - * - * Note: This class is implemented to verify a method automatically upon - * invoking. If all the method modifiers are satisfied, the success message - * is immediately printed to the output, even if you don't call verify(). If - * you want to suppress all output, you should pass an instance of LimeOutputNone - * to this class. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationExpectation.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -class LimeMockInvocationExpectation -{ - protected - $invocation = null, - $matched = false, - $output = null, - $countMatcher = null, - $parameterMatchers = array(), - $parameters = array(), - $withAnyParameters = false, - $returns = false, - $returnValue = null, - $exception = null, - $callback = null, - $strict = false, - $verified = false; - - /** - * Constructor. - * - * @param LimeMockInvocation $invocation The expected method invocation - * @param LimeOutputInterface $output The output to write at when - * verification passes or fails - */ - public function __construct(LimeMockInvocation $invocation, LimeOutputInterface $output) - { - $this->invocation = $invocation; - $this->output = $output; - } - - protected function getMatchers() - { - return array_merge($this->parameterMatchers, ($this->countMatcher ? array($this->countMatcher) : array())); - } - - /** - * Returns the string representation. - * - * The string representation consists of the method name and the messages of - * all applied modifiers. - * - * Example: - * - * "doSomething() was called at least once" - * - * @return string - */ - public function __toString() - { - $string = $this->invocation.' was called'; - - foreach ($this->getMatchers() as $matcher) - { - // avoid trailing spaces if the message is empty - $string = rtrim($string.' '.$matcher->getMessage()); - } - - return $string; - } - - /** - * Notifies this object of the given method invocation. - * - * If any of the matchers decides that this method should not have been - * invoked, an exception is thrown. If all matchers are satisfied, a success - * message is printed to the output. - * - * If this object was configured to throw an exception, this exception is - * thrown now. Otherwise the method's configured return value is returned. - * - * @param LimeMockInvocation $invocation The invoked method - * @return mixed The configured return value - * See returns() - * @throws LimeMockInvocationException If the method should not have been - * invoked - * @throws Exception If this object was configured to - * throw an exception - * See throw() - */ - public function invoke(LimeMockInvocation $invocation) - { - try - { - foreach ($this->getMatchers() as $matcher) - { - $matcher->invoke($invocation); - } - } - catch (LimeMockInvocationMatcherException $e) - { - throw new LimeMockInvocationException($this->invocation, $e->getMessage()); - } - - if (!$this->verified && $this->isSatisfied()) - { - list ($file, $line) = LimeTrace::findCaller('LimeMockInterface'); - - $this->output->pass((string)$this, $file, $line); - - $this->verified = true; - } - - if (!is_null($this->callback)) - { - $result = call_user_func_array($this->callback, $invocation->getParameters()); - - return $this->returns ? $this->returnValue : $result; - } - - if (!is_null($this->exception)) - { - if (is_string($this->exception)) - { - throw new $this->exception(); - } - else - { - throw $this->exception; - } - } - - return $this->returnValue; - } - - /** - * Returns whether the method signature and parameters of this object match - * the given invocation. - * - * @param LimeMockInvocation $invocation - * @return boolean - */ - public function matches(LimeMockMethodInterface $method) - { - if ($this->invocation->getClass() != $method->getClass() || $this->invocation->getMethod() != $method->getMethod()) - { - return false; - } - else if ($method instanceof LimeMockInvocation && !$this->withAnyParameters) - { - $index = 0; - - foreach ($this->parameterMatchers as $matcher) - { - $index = max($index, $matcher->getIndex()); - } - - return count($method->getParameters()) == $index; - } - else - { - return true; - } - } - - /** - * Returns whether this object may be invoked. - * - * This method returns FALSE if the next call to invoke() would throw a - * LimeMockInvocationException. - * - * @return boolean - */ - public function isInvokable() - { - $result = true; - - foreach ($this->getMatchers() as $matcher) - { - $result = $result && $matcher->isInvokable(); - } - - return $result; - } - - /** - * Returns whether the requirements of all configured modifiers have been - * fulfilled. - * - * @return boolean - */ - public function isSatisfied() - { - $result = true; - - foreach ($this->getMatchers() as $matcher) - { - $result = $result && $matcher->isSatisfied(); - } - - return $result; - } - - /** - * Verifies whether the requirements of all configured modifiers have been - * fulfilled. - * - * Depending on the result, either a failed or a passed test is written to the - * output. A method may only be verified once. - * - * Note: Methods are verified automatically once invoke() is called and - * all matchers are satisfied. In this case verify() simply does nothing. - */ - public function verify() - { - if (!$this->verified) - { - list ($file, $line) = LimeTrace::findCaller('LimeMockInterface'); - - if ($this->isSatisfied()) - { - $this->output->pass((string)$this, $file, $line); - } - else - { - $this->output->fail((string)$this, $file, $line); - } - - $this->verified = true; - } - } - - /** - * This method is expected to be called the given number of times. - * - * @param integer $times - * @return LimeMockInvocationExpectation This object - */ - public function times($times) - { - $this->countMatcher = new LimeMockInvocationMatcherTimes($times); - - return $this; - } - - /** - * This method is expected to be called exactly once. - * - * @return LimeMockInvocationExpectation This object - */ - public function once() - { - return $this->times(1); - } - - /** - * This method is expected to be called never. - * - * @return LimeMockInvocationExpectation This object - */ - public function never() - { - return $this->times(0); - } - - /** - * This method is expected to be called zero times or more. - * - * @return LimeMockInvocationExpectation This object - */ - public function any() - { - $this->countMatcher = new LimeMockInvocationMatcherAny(); - - return $this; - } - - /** - * This method is expected to be called once or more. - * - * @return LimeMockInvocationExpectation This object - */ - public function atLeastOnce() - { - $this->countMatcher = new LimeMockInvocationMatcherAtLeastOnce(); - - return $this; - } - - /** - * This method is expected to be called any time within the given limits. - * - * The limits are inclusive. If the method is called exactly $start times, - * the requirements of this modifier are fulfilled. - * - * @param integer $start - * @param integer $end - * @return LimeMockInvocationExpectation This object - */ - public function between($start, $end) - { - $this->countMatcher = new LimeMockInvocationMatcherBetween($start, $end); - - return $this; - } - - /** - * This method will return the given value when invoked. - * - * @param mixed $value - * @return LimeMockInvocationExpectation This object - */ - public function returns($value) - { - $this->returns = true; - $this->returnValue = $value; - - return $this; - } - - /** - * This method will throw the given exception when invoked. - * - * @param string|Exception $class - * @return LimeMockInvocationExpectation This object - */ - public function throws($class) - { - $this->exception = $class; - - return $this; - } - - /** - * This method will call the given callback and return its return value when - * invoked. - * - * @param callable $callback - * @return LimeMockInvocationExpectation This object - */ - public function callback($callback) - { - if (!is_callable($callback)) - { - throw new InvalidArgumentException('The given argument is no callable'); - } - - $this->callback = $callback; - - return $this; - } - - /** - * This method must be called with the exact same parameter types. - * - * @return LimeMockInvocationExpectation This object - */ - public function strict() - { - $this->strict = true; - - if (!$this->withAnyParameters) - { - // reload matchers - $this->withParameters($this->parameters); - } - - return $this; - } - - /** - * Configures a parameter to match some constraint. - * - * The constraint can be configured on the returned matcher object. - * - * @param integer $index The index of the parameter. The first parameter has - * index 1. - * @return LimeMockInvocationMatcherParameter - */ - public function parameter($index) - { - $this->parameterMatchers[$index] = $matcher = new LimeMockInvocationMatcherParameter($index, $this); - - return $matcher; - } - - /** - * This method can be called with any parameters. - * - * @return LimeMockInvocationExpectation This object - */ - public function withAnyParameters() - { - $this->parameterMatchers = array(); - $this->withAnyParameters = true; - - return $this; - } - - /** - * This method must be called with the given parameters. - * - * @param array $parameters - * @param $strict - * @return unknown_type - */ - public function withParameters(array $parameters) - { - $this->parameters = $parameters; - $this->parameterMatchers = array(); - $this->withAnyParameters = false; - - foreach ($parameters as $index => $value) - { - if ($this->strict) - { - $this->parameter($index+1)->same($value); - } - else - { - $this->parameter($index+1)->is($value); - } - } - - return $this; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockMethod.php b/tests/lib/vendor/lime/mock/LimeMockMethod.php deleted file mode 100644 index 05940c81312bf..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockMethod.php +++ /dev/null @@ -1,57 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Represents a method on a class. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockMethod.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -class LimeMockMethod implements LimeMockMethodInterface -{ - protected - $class = null, - $method = null; - - /** - * Constructor. - * - * @param string $class The class name - * @param string $method The method name - */ - public function __construct($class, $method) - { - $this->class = $class; - $this->method = $method; - } - - /** - * Returns the class name. - * - * @return string - */ - public function getClass() - { - return $this->class; - } - - /** - * Returns the method name. - * - * @return string - */ - public function getMethod() - { - return $this->method; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockMethodInterface.php b/tests/lib/vendor/lime/mock/LimeMockMethodInterface.php deleted file mode 100644 index 9abd871b37c3f..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockMethodInterface.php +++ /dev/null @@ -1,8 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * A behaviour that requires methods to be invoked in the same order as they - * were expected. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockOrderedBehaviour.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMockBehaviourInterface - */ -class LimeMockOrderedBehaviour extends LimeMockBehaviour -{ - protected - $cursor = 0; - - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviour#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - if (array_key_exists($this->cursor, $this->invocations)) - { - $invocationExpectation = $this->invocations[$this->cursor]; - - if ($invocationExpectation->matches($invocation) && $invocationExpectation->isInvokable()) - { - return $invocationExpectation->invoke($invocation); - } - else if ($invocationExpectation->isSatisfied()) - { - $this->cursor++; - - return $this->invoke($invocation); - } - } - - parent::invoke($invocation); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockRecordState.php b/tests/lib/vendor/lime/mock/LimeMockRecordState.php deleted file mode 100644 index 77f3b821f18db..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockRecordState.php +++ /dev/null @@ -1,99 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * The state of the mock during record mode. - * - * During record mode, all methods that are called on the mock are turned into - * invocation expectations. You may set modifiers on these expectations to - * configure whether invocations should return values, throw exceptions etc. - * in replay mode. See the description of LimeMockInvocationExpectation for - * more information. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockRecordState.php 23880 2009-11-14 10:14:34Z bschussek $ - * @see LimeMockInvocationExpectation - */ -class LimeMockRecordState implements LimeMockStateInterface -{ - protected - $behaviour = null, - $output = null; - - /** - * Constructor. - * - * @param LimeMockBehaviourInterface $behaviour The behaviour on which this - * state operates - * @param LimeOutputInterface $output The output where failed and - * successful tests are written - * to. - */ - public function __construct(LimeMockBehaviourInterface $behaviour, LimeOutputInterface $output) - { - $this->behaviour = $behaviour; - $this->output = $output; - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#invoke($method, $parameters) - */ - public function invoke(LimeMockMethod $method, array $parameters = null) - { - $invocation = new LimeMockInvocation($method, is_null($parameters) ? array() : $parameters); - $invocation = new LimeMockInvocationExpectation($invocation, $this->output); - - if (is_null($parameters)) - { - $invocation->withAnyParameters(); - } - else - { - $invocation->withParameters($parameters); - } - - $this->behaviour->expect($invocation); - - return $invocation; - } - - /** - * All method can be invoked during record mode. - * - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#isInvokable($method) - */ - public function isInvokable(LimeMockMethod $method) - { - return true; - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#setExpectNothing() - */ - public function setExpectNothing() - { - return $this->behaviour->setExpectNothing(); - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#verify() - */ - public function verify() - { - throw new BadMethodCallException('replay() must be called before verify()'); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockReplayState.php b/tests/lib/vendor/lime/mock/LimeMockReplayState.php deleted file mode 100644 index 072c3d36e2c32..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockReplayState.php +++ /dev/null @@ -1,75 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * The state of the mock during replay mode. - * - * In this state, invoked methods are verified automatically. If a method - * was expected to be called, the configured return value of the method is - * returned. If it was not expected, an exception is thrown instead. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockReplayState.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -class LimeMockReplayState implements LimeMockStateInterface -{ - protected - $behaviour = null; - - /** - * Constructor. - * - * @param LimeMockBehaviourInterface $behaviour The behaviour on which this - * state operates. - */ - public function __construct(LimeMockBehaviourInterface $behaviour) - { - $this->behaviour = $behaviour; - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#invoke($class, $method, $parameters) - */ - public function invoke(LimeMockMethod $method, array $parameters = null) - { - return $this->behaviour->invoke(new LimeMockInvocation($method, is_null($parameters) ? array() : $parameters)); - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#isInvokable($method) - */ - public function isInvokable(LimeMockMethod $method) - { - return $this->behaviour->isInvokable($method); - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#setExpectNothing() - */ - public function setExpectNothing() - { - throw new BadMethodCallException('setExpectNothing() must be called before replay()'); - } - - /** - * (non-PHPdoc) - * @see mock/LimeMockStateInterface#verify() - */ - public function verify() - { - return $this->behaviour->verify(); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockStateInterface.php b/tests/lib/vendor/lime/mock/LimeMockStateInterface.php deleted file mode 100644 index e979d91646640..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockStateInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Represents the current state of the mock. - * - * A mock can have different states during his lifetime. The functionality - * in these different states is implemented using the State Pattern. Each - * state should extend this interface. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockStateInterface.php 23880 2009-11-14 10:14:34Z bschussek $ - */ -interface LimeMockStateInterface -{ - /** - * Handles an invoked method on the mock. - * - * Depending on the state of the mock, invoked methods may be treated - * differently. - * - * @param LimeMockInvocation $invocation - * @return mixed - * @throws LimeMockInvocationException - * @throws Exception - */ - public function invoke(LimeMockMethod $method, array $parameters = null); - - /** - * Returns whether the given method is invokable. - * - * @param LimeMockMethod $method The method - * @return boolean TRUE if the method is invokable - */ - public function isInvokable(LimeMockMethod $method); - - /** - * Tells the state that the mock should not receive any method invocation. - */ - public function setExpectNothing(); - - /** - * Verifies the mock in the current state. - */ - public function verify(); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockTemplate.php b/tests/lib/vendor/lime/mock/LimeMockTemplate.php deleted file mode 100644 index 0b9cc9cf09a7a..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockTemplate.php +++ /dev/null @@ -1,57 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Reads template files and parses them with a set of template variables. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockTemplate.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeMockTemplate -{ - private - $parameters = array(), - $filename = ''; - - /** - * Constructor. - * - * Configures this template to use the given file. - * - * @param string $filename - */ - public function __construct($filename) - { - $this->filename = $filename; - } - - /** - * Renders the file of this template with the given parameters. - * - * The parameters are made available in the template and can be accessed there - * as normal PHP variables. The template is parsed and the output of the - * template is returned. - * - * @param array $parameters - * @return string - */ - public function render(array $parameters) - { - ob_start(); - extract($parameters); - include $this->filename; - - return ob_get_clean(); - } - -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/LimeMockUnorderedBehaviour.php b/tests/lib/vendor/lime/mock/LimeMockUnorderedBehaviour.php deleted file mode 100644 index 37a6d77bc8206..0000000000000 --- a/tests/lib/vendor/lime/mock/LimeMockUnorderedBehaviour.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version SVN: $Id: LimeMockUnorderedBehaviour.php 23864 2009-11-13 18:06:20Z bschussek $ - * @see LimeMockBehaviourInterface - */ -class LimeMockUnorderedBehaviour extends LimeMockBehaviour -{ - /** - * (non-PHPdoc) - * @see mock/LimeMockBehaviour#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - $exceptionStack = new LimeMockInvocationExceptionStack(); - - foreach ($this->invocations as $invocationExpectation) - { - try - { - if ($invocationExpectation->matches($invocation)) - { - return $invocationExpectation->invoke($invocation); - } - } - catch (LimeMockInvocationException $e) - { - // make sure to test all expectations - $exceptionStack->add($e); - } - } - - // no invocation matched and at least one exception was thrown - if (!$exceptionStack->isEmpty()) - { - throw $exceptionStack; - } - - parent::invoke($invocation); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAny.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAny.php deleted file mode 100644 index a3780e80fbfcb..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAny.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Requires a method call to be invoked any time. - * - * This matcher always passes. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherAny.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMockInvocationMatcherInterface - */ -class LimeMockInvocationMatcherAny implements LimeMockInvocationMatcherInterface -{ - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isInvokable() - */ - public function isInvokable() - { - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isSatisfied() - */ - public function isSatisfied() - { - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#getMessage() - */ - public function getMessage() - { - return ''; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAtLeastOnce.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAtLeastOnce.php deleted file mode 100644 index 1e3e92a31ab94..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherAtLeastOnce.php +++ /dev/null @@ -1,63 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Requires a method call to be invoked once or more. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherAtLeastOnce.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMockInvocationMatcherInterface - */ -class LimeMockInvocationMatcherAtLeastOnce implements LimeMockInvocationMatcherInterface -{ - private - $actual = 0; - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - $this->actual++; - - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isInvokable() - */ - public function isInvokable() - { - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isSatisfied() - */ - public function isSatisfied() - { - return $this->actual >= 1; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#getMessage() - */ - public function getMessage() - { - return 'at least once'; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherBetween.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherBetween.php deleted file mode 100644 index 9de1e50449547..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherBetween.php +++ /dev/null @@ -1,94 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Requires a method to be called between X and Y times. - * - * The parameters X and Y are passed to the constructor. These values are - * inclusive, that means that the matcher passes if the method is called - * exactly X or Y times. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherBetween.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMockInvocationMatcherInterface - */ -class LimeMockInvocationMatcherBetween implements LimeMockInvocationMatcherInterface -{ - private - $start = 0, - $end = 0, - $actual = 0; - - /** - * Constructor. - * - * @param integer $start The lower limit of accepted invokation counts - * @param integer $end The upper limit of accepted invokation counts - */ - public function __construct($start, $end) - { - if ($start > $end) - { - $this->start = $end; - $this->end = $start; - } - else - { - $this->start = $start; - $this->end = $end; - } - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - if ($this->actual < $this->end) - { - $this->actual++; - } - else - { - throw new LimeMockInvocationMatcherException(sprintf('should only be called %s', $this->getMessage())); - } - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isInvokable() - */ - public function isInvokable() - { - return $this->actual < $this->end; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isSatisfied() - */ - public function isSatisfied() - { - return $this->actual >= $this->start && $this->actual <= $this->end; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#getMessage() - */ - public function getMessage() - { - return sprintf('between %s and % times', $this->start, $this->end); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherException.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherException.php deleted file mode 100644 index bc7c40cb119ac..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Exception thrown by all invokation matchers. - * - * This exception is thrown by the method invoke() of all invokation matchers - * implementing LimeMockInvocationMatcherInterface if the invokation is not - * accepted. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherException.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMockInvocationMatcherInterface - */ -class LimeMockInvocationMatcherException extends Exception -{ -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherInterface.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherInterface.php deleted file mode 100644 index e83361862f939..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherInterface.php +++ /dev/null @@ -1,77 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Verifies whether some criteria has been fulfilled for a method invocation. - * - * You can configure a number of matchers for a method invocation in class - * LimeExpectedInvocation. If a method is invoked and the method - * signature and parameters match the expected invocation, the method call - * is passed to the invoke() method of all associated matchers. This method - * decides whether the invocation is valid and throws a - * LimeMockInvocationMatcherException if it is not. - * - * When the mock object is verified, the method isSatisfied() is queried on all - * matchers of every method. If all matchers are satisfied, the invocation - * expectation is considered to be fulfilled. - * - * The method isInvokable() returns whether the matcher accepts any more - * invocations. For example, if a matcher only accepts 3 invocation and throws - * exceptions after that, isInvokable() should return false as soon as these - * three invocations have been made. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherInterface.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -interface LimeMockInvocationMatcherInterface -{ - /** - * Notifies the matcher of a given method invocation. - * - * If the matcher decides that the method should not have been invoked, it - * must throw an exception in this method. - * - * @param LimeMockInvocation $invocation The method invocation - * @throws LimeMockInvocationMatcherException If the invocation was not valid - */ - public function invoke(LimeMockInvocation $invocation); - - /** - * Returns whether the matcher accepts any more invokations. - * - * @return boolean - */ - public function isInvokable(); - - /** - * Returns whether the matcher's criteria is fulfilled. - * - * The matcher's criteria could be, for instance, that a method must be - * invoked at least 3 times. As soon as this is the case, isSatisfied() - * returns TRUE. - * - * @return boolean - */ - public function isSatisfied(); - - /** - * The message describing the purpose of the matcher that is appended to - * the method name in the test output. - * - * If this message returns "with any parameters", the resulting output is - * "doSomething(x) was called with any parameters". - * - * @return string - */ - public function getMessage(); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherParameter.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherParameter.php deleted file mode 100644 index 9df4dd384321a..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherParameter.php +++ /dev/null @@ -1,288 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Requires a method call to satisfy a constraint for one parameter. - * - * The index of the parameter is given to the constructor. The desired - * constraint can be configured by calling any of the methods of this class. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherParameter.php 23864 2009-11-13 18:06:20Z bschussek $ - * @see LimeMockInvocationMatcherInterface - */ -class LimeMockInvocationMatcherParameter implements LimeMockInvocationMatcherInterface -{ - private - $index = null, - $parent = null, - $constraint = null; - - /** - * Constructor. - * - * @param integer $index - * @param LimeMockInvocationExpectation $parent - */ - public function __construct($index, LimeMockInvocationExpectation $parent) - { - $this->index = $index; - $this->parent = $parent; - } - - /** - * Returns the parameter index of this matcher. - * - * @return integer - */ - public function getIndex() - { - return $this->index; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - try - { - if (!is_null($this->constraint)) - { - $this->constraint->evaluate($invocation->getParameter($this->index-1)); - } - } - catch (LimeConstraintException $e) - { - $message = LimeTools::indent($e->getMessage(), 2); - - throw new LimeMockInvocationMatcherException("was called with wrong parameter $this->index\n".$message); - } - catch (OutOfRangeException $e) - { - throw new LimeMockInvocationMatcherException("was not called with $this->index or more parameters"); - } - } - - /** - * Returns whether this matcher matches the given invocation. - * - * @param LimeMockInvocation $invocation - * @return boolean - */ - public function matches(LimeMockInvocation $invocation) - { - try - { - if (!is_null($this->constraint)) - { - $this->constraint->evaluate($invocation->getParameter($this->index-1)); - } - } - catch (LimeConstraintException $e) - { - return false; - } - catch (OutOfRangeException $e) - { - return false; - } - - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isInvokable() - */ - public function isInvokable() - { - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isSatisfied() - */ - public function isSatisfied() - { - return true; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#getMessage() - */ - public function getMessage() - { - return ''; - } - - /** - * Sets the constraint and returns the related invocation expectation object. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - */ - private function setConstraint(LimeConstraintInterface $constraint) - { - $this->constraint = $constraint; - - return $this->parent; - } - - /** - * Requires the parameter to be equal to the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintIs - */ - public function is($expected) - { - return $this->setConstraint(new LimeConstraintIs($expected)); - } - - /** - * Requires the parameter to be not equal to the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintIsNot - */ - public function isnt($expected) - { - return $this->setConstraint(new LimeConstraintIsNot($expected)); - } - - /** - * Requires the parameter to be identical to the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintSame - */ - public function same($expected) - { - return $this->setConstraint(new LimeConstraintSame($expected)); - } - - /** - * Requires the parameter to be not identical to the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintNotSame - */ - public function isntSame($expected) - { - return $this->setConstraint(new LimeConstraintNotSame($expected)); - } - - /** - * Requires the parameter to be like the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintLike - */ - public function like($expected) - { - return $this->setConstraint(new LimeConstraintLike($expected)); - } - - /** - * Requires the parameter to be unlike the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintUnlike - */ - public function unlike($expected) - { - return $this->setConstraint(new LimeConstraintUnlike($expected)); - } - - /** - * Requires the parameter to contain the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintContains - */ - public function contains($expected) - { - return $this->setConstraint(new LimeConstraintContains($expected)); - } - - /** - * Requires the parameter to not contain the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintContainsNot - */ - public function containsNot($expected) - { - return $this->setConstraint(new LimeConstraintContainsNot($expected)); - } - - /** - * Requires the parameter to be greater than the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintGreaterThan - */ - public function greaterThan($expected) - { - return $this->setConstraint(new LimeConstraintGreaterThan($expected)); - } - - /** - * Requires the parameter to be greater than or equal to the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintGreaterThanEqual - */ - public function greaterThanEqual($expected) - { - return $this->setConstraint(new LimeConstraintGreaterThanEqual($expected)); - } - - /** - * Requires the parameter to be less than the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintLessThan - */ - public function lessThan($expected) - { - return $this->setConstraint(new LimeConstraintLessThan($expected)); - } - - /** - * Requires the parameter to be less than or equal to the given value. - * - * @param LimeConstraintInterface $constraint - * @return LimeMockInvocationExpectation - * @see LimeConstraintLessThanEqual - */ - public function lessThanEqual($expected) - { - return $this->setConstraint(new LimeConstraintLessThanEqual($expected)); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherTimes.php b/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherTimes.php deleted file mode 100644 index 772683c1437dd..0000000000000 --- a/tests/lib/vendor/lime/mock/matcher/LimeMockInvocationMatcherTimes.php +++ /dev/null @@ -1,90 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Requires a method to be invoked a specific number of times. - * - * The expected number of method invokations must be passed to the constructor. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeMockInvocationMatcherTimes.php 23701 2009-11-08 21:23:40Z bschussek $ - * @see LimeMockInvocationMatcherInterface - */ -class LimeMockInvocationMatcherTimes implements LimeMockInvocationMatcherInterface -{ - private - $expected = 0, - $actual = 0; - - /** - * Constructor. - * - * @param integer $times The expected number of method invokations0 - */ - public function __construct($times) - { - $this->expected = $times; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#invoke($invocation) - */ - public function invoke(LimeMockInvocation $invocation) - { - if ($this->actual < $this->expected) - { - $this->actual++; - } - else - { - if ($this->expected == 0) - { - throw new LimeMockInvocationMatcherException('should not be called'); - } - else - { - $times = $this->getMessage(); - - throw new LimeMockInvocationMatcherException(sprintf('should only be called %s', $times)); - } - } - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isInvokable() - */ - public function isInvokable() - { - return $this->actual < $this->expected; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#isSatisfied() - */ - public function isSatisfied() - { - return $this->actual >= $this->expected; - } - - /** - * (non-PHPdoc) - * @see mock/matcher/LimeMockInvocationMatcherInterface#getMessage() - */ - public function getMessage() - { - return $this->expected == 1 ? 'once' : $this->expected.' times'; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/mock/template/mocked_class.tpl b/tests/lib/vendor/lime/mock/template/mocked_class.tpl deleted file mode 100644 index 25bf0727c48e6..0000000000000 --- a/tests/lib/vendor/lime/mock/template/mocked_class.tpl +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of the Lime framework. - * - * (c) Fabien Potencier - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - - -{ - private - $class = null, - $state = null, - $output = null, - $behaviour = null, - $stubMethods = true; - - public function __construct($class, LimeMockBehaviourInterface $behaviour, LimeOutputInterface $output, $stubMethods = true) - { - $this->class = $class; - $this->behaviour = $behaviour; - $this->output = $output; - $this->stubMethods = $stubMethods; - - $this->__lime_reset(); - } - - public function __call($method, $parameters) - { - try - { - $method = new LimeMockMethod($this->class, $method); - - // if $stubMethods is set to FALSE, methods that are not configured are - // passed to the real implementation - if ($this->stubMethods || $this->state->isInvokable($method)) - { - return $this->state->invoke($method, $parameters); - } - else if (method_exists($this->class, $method->getMethod())) - { - // THIS METHOD CALL WILL LEAD TO SEGFAULTS WHEN EXECUTED IN A - // WEBSERVER ENVIRONMENT!!! - - if (PHP_VERSION_ID < 50300) - { - return call_user_func_array(array($this, 'parent::'.$method->getMethod()), $parameters); - } - else - { - return call_user_func_array('parent::'.$method->getMethod(), $parameters); - } - } - } - catch (LimeMockInvocationException $e) - { - // hide the internal trace to not distract when debugging test errors - throw new LimeMockException($e->getMessage()); - } - } - - public function __lime_replay() - { - $this->state = new LimeMockReplayState($this->behaviour); - } - - public function __lime_reset() - { - $this->behaviour->reset(); - - if (!$this->state instanceof LimeMockRecordState) - { - $this->state = new LimeMockRecordState($this->behaviour, $this->output); - } - } - - public function __lime_getState() - { - return $this->state; - } - - - public function replay() { return LimeMock::replay($this); } - public function any($methodName) { return LimeMock::any($this, $methodName); } - public function reset() { return LimeMock::reset($this); } - public function verify() { return LimeMock::verify($this); } - public function setExpectNothing() { return LimeMock::setExpectNothing($this); } - - - -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputArray.php b/tests/lib/vendor/lime/output/LimeOutputArray.php deleted file mode 100644 index 64629f1a3d3d2..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputArray.php +++ /dev/null @@ -1,222 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Formats test results as multidimensional array. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeOutputArray.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -class LimeOutputArray implements LimeOutputInterface -{ - protected - $serialize = false, - $results = array(), - $currentResults = null; - - /** - * Constructor. - * - * @param boolean $serialize Whether the array should be serialized before printing - */ - public function __construct($serialize = false) - { - $this->serialize = $serialize; - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#supportsThreading() - */ - public function supportsThreading() - { - return true; - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#focus($file) - */ - public function focus($file) - { - $this->currentResults =& $this->getResults($file); - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#close() - */ - public function close() - { - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#plan($amount) - */ - public function plan($amount) - { - $this->currentResults['stats']['plan'] = $amount; - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#pass($message, $file, $line) - */ - public function pass($message, $file, $line) - { - $this->currentResults['stats']['total']++; - $this->currentResults['stats']['passed'][] = $this->addTest(true, $line, $file, $message); - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#fail($message, $file, $line, $error) - */ - public function fail($message, $file, $line, $error = null) - { - $index = $this->addTest(false, $line, $file, $message); - - $this->currentResults['stats']['total']++; - $this->currentResults['stats']['failed'][] = $index; - - if (!is_null($error)) - { - $this->currentResults['tests'][$index]['error'] = $error; - } - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#skip($message, $file, $line) - */ - public function skip($message, $file, $line) - { - $this->currentResults['stats']['total']++; - $this->currentResults['stats']['skipped'][] = $this->addTest(true, $line, $file, $message); - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#todo($message, $file, $line) - */ - public function todo($message, $file, $line) - { - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#warning($message, $file, $line) - */ - public function warning($message, $file, $line) - { - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#error($error) - */ - public function error(LimeError $error) - { - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#comment($message) - */ - public function comment($message) - { - } - - /** - * (non-PHPdoc) - * @see output/LimeOutputInterface#flush() - */ - public function flush() - { - if ($this->serialize) - { - print serialize($this->results); - } - else - { - var_export($this->results); - } - } - - /** - * Returns the results as array. - * - * @return array - */ - public function toArray() - { - return $this->results; - } - - /** - * Returns the result array of the given test file. - * - * @param string $file - * @return array - */ - protected function &getResults($file) - { - foreach ($this->results as $key => &$fileResults) - { - if ($fileResults['file'] == $file) - { - return $fileResults; - } - } - - $newResults = array( - 'file' => $file, - 'tests' => array(), - 'stats' => array( - 'plan' => 0, - 'total' => 0, - 'failed' => array(), - 'passed' => array(), - 'skipped' => array(), - ), - ); - - $this->results[] =& $newResults; - - return $newResults; - } - - /** - * Addsthe given test to the test results. - * - * @param boolean $status - * @param integer $line - * @param string $file - * @param string $message - * @return integer - */ - protected function addTest($status, $line, $file, $message) - { - $index = count($this->currentResults['tests']) + 1; - - $this->currentResults['tests'][$index] = array( - 'line' => $line, - 'file' => $file, - 'message' => $message, - 'status' => $status, - ); - - return $index; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputConsoleSummary.php b/tests/lib/vendor/lime/output/LimeOutputConsoleSummary.php deleted file mode 100644 index bd8172ae3f689..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputConsoleSummary.php +++ /dev/null @@ -1,275 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Colorizes test results and summarizes them in the console. - * - * For each test file, one line is printed in the console with a few optional - * lines in case the file contains errors or failed tests. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeOutputConsoleSummary.php 25932 2009-12-27 19:55:32Z bschussek $ - */ -class LimeOutputConsoleSummary implements LimeOutputInterface -{ - protected - $printer = null, - $options = array(), - $startTime = 0, - $file = null, - $results = array(), - $actualFiles = 0, - $failedFiles = 0, - $actualTests = 0, - $expectedTests = 0, - $failedTests = 0; - - /** - * Constructor. - * - * @param LimePrinter $printer The printer for printing text to the console - * @param array $options The options of this output - */ - public function __construct(LimePrinter $printer, array $options = array()) - { - $this->printer = $printer; - $this->startTime = time(); - $this->options = array_merge(array( - 'base_dir' => null, - 'processes' => 1, - 'verbose' => false, - ), $options); - } - - public function supportsThreading() - { - return true; - } - - public function focus($file) - { - if (!array_key_exists($file, $this->results)) - { - $this->results[$file] = new LimeOutputResult(); - } - - $this->file = $file; - } - - public function close() - { - if (!is_null($this->file)) - { - $result = $this->results[$this->file]; - - $this->actualFiles++; - $this->actualTests += $result->getNbActual(); - $this->expectedTests += $result->getNbExpected(); - $this->failedTests += $result->getNbFailures(); - - $path = $this->truncate($this->file); - - if (strlen($path) > 71) - { - $path = substr($path, -71); - } - - $this->printer->printText(str_pad($path, 73, '.')); - - if ($result->hasErrors() || $result->hasFailures() || $result->isIncomplete()) - { - $this->failedFiles++; - $this->printer->printLine("not ok", LimePrinter::NOT_OK); - } - else if ($result->hasWarnings()) - { - $this->printer->printLine("warning", LimePrinter::WARNING); - } - else - { - $this->printer->printLine("ok", LimePrinter::OK); - } - - if ($result->isIncomplete()) - { - $this->printer->printLine(' Plan Mismatch:', LimePrinter::COMMENT); - if ($result->getNbActual() > $result->getNbExpected()) - { - $this->printer->printLine(sprintf(' Looks like you only planned %s tests but ran %s.', $result->getNbExpected(), $result->getNbActual())); - } - else - { - $this->printer->printLine(sprintf(' Looks like you planned %s tests but only ran %s.', $result->getNbExpected(), $result->getNbActual())); - } - } - - if ($result->hasFailures()) - { - $this->printer->printLine(' Failed Tests:', LimePrinter::COMMENT); - - $i = 0; - foreach ($result->getFailures() as $number => $failed) - { - if (!$this->options['verbose'] && $i > 2) - { - $this->printer->printLine(sprintf(' ... and %s more', $result->getNbFailures()-$i)); - break; - } - - ++$i; - - $this->printer->printLine(' not ok '.$number.' - '.$failed[0]); - } - } - - if ($result->hasWarnings()) - { - $this->printer->printLine(' Warnings:', LimePrinter::COMMENT); - - foreach ($result->getWarnings() as $i => $warning) - { - if (!$this->options['verbose'] && $i > 2) - { - $this->printer->printLine(sprintf(' ... and %s more', $result->getNbWarnings()-$i)); - break; - } - - $this->printer->printLine(' '.$warning[0]); - - if ($this->options['verbose']) - { - $this->printer->printText(' (in '); - $this->printer->printText($this->truncate($warning[1]), LimePrinter::TRACE); - $this->printer->printText(' on line '); - $this->printer->printText($warning[2], LimePrinter::TRACE); - $this->printer->printLine(')'); - } - } - } - - if ($result->hasErrors()) - { - $this->printer->printLine(' Errors:', LimePrinter::COMMENT); - - foreach ($result->getErrors() as $i => $error) - { - if (!$this->options['verbose'] && $i > 2) - { - $this->printer->printLine(sprintf(' ... and %s more', $result->getNbErrors()-$i)); - break; - } - - $this->printer->printLine(' '.$error->getMessage()); - - if ($this->options['verbose']) - { - $this->printer->printText(' (in '); - $this->printer->printText($this->truncate($error->getFile()), LimePrinter::TRACE); - $this->printer->printText(' on line '); - $this->printer->printText($error->getLine(), LimePrinter::TRACE); - $this->printer->printLine(')'); - } - } - } - - if ($result->hasTodos()) - { - $this->printer->printLine(' TODOs:', LimePrinter::COMMENT); - - foreach ($result->getTodos() as $i => $todo) - { - if (!$this->options['verbose'] && $i > 2) - { - $this->printer->printLine(sprintf(' ... and %s more', $result->getNbTodos()-$i)); - break; - } - - $this->printer->printLine(' '.$todo); - } - } - } - } - - public function plan($amount) - { - $this->results[$this->file]->addPlan($amount); - } - - public function pass($message, $file, $line) - { - $this->results[$this->file]->addPassed(); - } - - public function fail($message, $file, $line, $error = null) - { - $this->results[$this->file]->addFailure(array($message, $file, $line, $error)); - } - - public function skip($message, $file, $line) - { - $this->results[$this->file]->addSkipped(); - } - - public function todo($message, $file, $line) - { - $this->results[$this->file]->addTodo($message); - } - - public function warning($message, $file, $line) - { - $this->results[$this->file]->addWarning(array($message, $file, $line)); - } - - public function error(LimeError $error) - { - $this->results[$this->file]->addError($error); - } - - public function comment($message) {} - - public function flush() - { - if ($this->failedFiles > 0) - { - $stats = sprintf(' Failed %d/%d test scripts, %.2f%% okay. %d/%d subtests failed, %.2f%% okay.', - $this->failedFiles, $this->actualFiles, 100 - 100*$this->failedFiles/max(1,$this->actualFiles), - $this->failedTests, $this->expectedTests, 100 - 100*$this->failedTests/max(1,$this->expectedTests)); - - $this->printer->printBox($stats, LimePrinter::NOT_OK); - } - else - { - $time = max(1, time() - $this->startTime); - $stats = sprintf(' Files=%d, Tests=%d, Time=%02d:%02d, Processes=%d', - $this->actualFiles, $this->actualTests, floor($time/60), $time%60, $this->options['processes']); - - $this->printer->printBox(' All tests successful.', LimePrinter::HAPPY); - $this->printer->printBox($stats, LimePrinter::HAPPY); - } - } - - protected function truncate($file) - { - $extension = pathinfo($file, PATHINFO_EXTENSION); - $file = substr($file, 0, strlen($file)-strlen($extension)); - - if (!is_null($this->options['base_dir'])) - { - return str_replace($this->options['base_dir'], '', $file); - } - else - { - return $file; - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputCoverage.php b/tests/lib/vendor/lime/output/LimeOutputCoverage.php deleted file mode 100644 index 9008d6d49e80b..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputCoverage.php +++ /dev/null @@ -1,47 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputCoverage implements LimeOutputInterface -{ - public function supportsThreading() - { - return false; - } - - public function focus($file) - { - xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); - } - - public function flush() - { - echo serialize(xdebug_get_code_coverage()); - } - - public function close() {} - - public function plan($amount) {} - - public function pass($message, $file, $line) {} - - public function fail($message, $file, $line, $error = null) {} - - public function skip($message, $file, $line) {} - - public function todo($message, $file, $line) {} - - public function warning($message, $file, $line) {} - - public function error(LimeError $error) {} - - public function comment($message) {} -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputFactory.php b/tests/lib/vendor/lime/output/LimeOutputFactory.php deleted file mode 100644 index d9848a63f2bb2..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputFactory -{ - protected - $options = array(); - - public function __construct(array $options) - { - $this->options = array_merge(array( - 'serialize' => false, - 'force_colors' => false, - 'base_dir' => null, - ), $options); - } - - public function create($name) - { - $colorizer = LimeColorizer::isSupported() || $this->options['force_colors'] ? new LimeColorizer() : null; - $printer = new LimePrinter($colorizer); - - switch ($name) - { - case 'raw': - return new LimeOutputRaw(); - case 'xml': - return new LimeOutputXml(); - case 'array': - return new LimeOutputArray($this->options['serialize']); - case 'summary': - return new LimeOutputConsoleSummary($printer, $this->options); - case 'tap': - default: - return new LimeOutputTap($printer, $this->options); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputInterface.php b/tests/lib/vendor/lime/output/LimeOutputInterface.php deleted file mode 100644 index 7a61910dd2782..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputInterface.php +++ /dev/null @@ -1,131 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Specifies how the results of an executed test should be presented. - * - * The class LimeTest uses an output to communicate the results of a test to - * the user or to a different application. All outputs must implement this - * interface. - * - * One output instance may receive test results of one or many test files. - * Each time when the output switches context between one test file and - * another, the method focus() is called with the name of the new test file. - * Once the file has been processed completely, the method close() is called - * to allow the output to finalize the results for the active test script. - * - * Depending on whether the output supports threading (parallel inputs from - * different actively tested files) the method supportsThreading() should - * return TRUE or FALSE. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeOutputInterface.php 23701 2009-11-08 21:23:40Z bschussek $ - */ -interface LimeOutputInterface -{ - /** - * Returns whether this output supports processing results from different tests - * simultaneously. - * - * @return boolean - */ - public function supportsThreading(); - - /** - * Focuses the output on the given test file. - * - * All inputs until the next call to focus() concern this test file. - * - * @param string$file - */ - public function focus($file); - - /** - * Closes the output for the currently focused test file. - */ - public function close(); - - /** - * Sets the plan for the currently focused test file. - * - * The plan is the expected number of tests.0 - * - * @param integer $amount - */ - public function plan($amount); - - /** - * Informs the output about a successful test. - * - * @param string $message The test message - * @param string $file The file in which the successful test occured - * @param integer $line The line of the file - */ - public function pass($message, $file, $line); - - /** - * Informs the output about a failed test with an optional failure reason. - * - * @param string $message The test message - * @param string $file The file in which the failed test occured - * @param integer $line The line of the file - * @param string $error The reason why the test failed - */ - public function fail($message, $file, $line, $error = null); - - /** - * Informs the output about a skipped test. - * - * @param string $message The test message - * @param string $file The file in which the skipped test occured - * @param integer $line The line of the file - */ - public function skip($message, $file, $line); - - /** - * Informs the output about a todo. - * - * @param string $message The todo message - * @param string $file The file in which the todo occured - * @param integer $line The line of the file - */ - public function todo($message, $file, $line); - - /** - * Informs the output about a warning. - * - * @param string $message The warning message - * @param string $file The file in which the warning occured - * @param integer $line The line of the file - */ - public function warning($message, $file, $line); - - /** - * Informs the output about an error. - * - * @param LimeError $error The error that occurred - */ - public function error(LimeError $error); - - /** - * Informs the output about a comment. - * - * @param string $message The comment message - */ - public function comment($message); - - /** - * Flushes the test outputs to the console. - */ - public function flush(); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputNone.php b/tests/lib/vendor/lime/output/LimeOutputNone.php deleted file mode 100644 index 7963eeb5cf678..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputNone.php +++ /dev/null @@ -1,41 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputNone implements LimeOutputInterface -{ - public function supportsThreading() - { - return true; - } - - public function focus($file) {} - - public function close() {} - - public function plan($amount) {} - - public function pass($message, $file, $line) {} - - public function fail($message, $file, $line, $error = null) {} - - public function skip($message, $file, $line) {} - - public function todo($message, $file, $line) {} - - public function warning($message, $file, $line) {} - - public function error(LimeError $error) {} - - public function comment($message) {} - - public function flush() {} -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputProxy.php b/tests/lib/vendor/lime/output/LimeOutputProxy.php deleted file mode 100755 index c71fba1883f22..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputProxy.php +++ /dev/null @@ -1,110 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputProxy implements LimeOutputInterface -{ - private - $output = null, - $result = null; - - public function __construct(LimeOutputInterface $output = null) - { - $this->output = is_null($output) ? new LimeOutputNone() : $output; - $this->result = new LimeOutputResult(); - } - - public function supportsThreading() - { - return $this->output->supportsThreading(); - } - - public function getResult() - { - return $this->result; - } - - /** - * For BC with lime_harness. - * - * @deprecated - * @return array - */ - public function getFailedFiles() - { - return $this->failedFiles; - } - - public function focus($file) - { - $this->output->focus($file); - } - - public function close() - { - $this->output->close(); - } - - public function plan($amount) - { - $this->result->addPlan($amount); - $this->output->plan($amount); - } - - public function pass($message, $file, $line) - { - $this->result->addPassed(); - $this->output->pass($message, $file, $line); - } - - public function fail($message, $file, $line, $error = null) - { - $this->result->addFailure(array($message, $file, $line, $error)); - $this->failedFiles[] = $file; - $this->output->fail($message, $file, $line, $error); - } - - public function skip($message, $file, $line) - { - $this->result->addSkipped(); - $this->output->skip($message, $file, $line); - } - - public function todo($message, $file, $line) - { - $this->result->addTodo($message); - $this->output->todo($message, $file, $line); - } - - public function warning($message, $file, $line) - { - $this->result->addWarning(array($message, $file, $line)); - $this->failedFiles[] = $file; - $this->output->warning($message, $file, $line); - } - - public function error(LimeError $error) - { - $this->result->addError($error); - $this->failedFiles[] = $error->getFile(); - $this->output->error($error); - } - - public function comment($message) - { - $this->output->comment($message); - } - - public function flush() - { - $this->output->flush(); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputRaw.php b/tests/lib/vendor/lime/output/LimeOutputRaw.php deleted file mode 100644 index 4b10970a238c3..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputRaw.php +++ /dev/null @@ -1,96 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputRaw implements LimeOutputInterface -{ - protected - $initialized = false; - - protected function printCall($method, array $arguments = array()) - { - foreach ($arguments as &$argument) - { - if (is_string($argument)) - { - $argument = str_replace(array("\n", "\r"), array('\n', '\r'), $argument); - } - } - - if (!$this->initialized) - { - $this->initialized = true; - print "\0raw\0"; - } - - print serialize(array($method, $arguments))."\n"; - } - - public function supportsThreading() - { - return true; - } - - public function focus($file) - { - $this->printCall('focus', array($file)); - } - - public function close() - { - $this->printCall('close', array()); - } - - public function plan($amount) - { - $this->printCall('plan', array($amount)); - } - - public function pass($message, $file, $line) - { - $this->printCall('pass', array($message, $file, $line)); - } - - public function fail($message, $file, $line, $error = null) - { - $this->printCall('fail', array($message, $file, $line, $error)); - } - - public function skip($message, $file, $line) - { - $this->printCall('skip', array($message, $file, $line)); - } - - public function todo($message, $file, $line) - { - $this->printCall('todo', array($message, $file, $line)); - } - - public function warning($message, $file, $line) - { - $this->printCall('warning', array($message, $file, $line)); - } - - public function error(LimeError $error) - { - $this->printCall('error', array($error)); - } - - public function comment($message) - { - $this->printCall('comment', array($message)); - } - - public function flush() - { - $this->printCall('flush'); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputResult.php b/tests/lib/vendor/lime/output/LimeOutputResult.php deleted file mode 100755 index 8988e1ce33d7e..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputResult.php +++ /dev/null @@ -1,277 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Collects and interprets the input of a LimeOutput... instance. - * - * @package Lime - * @author Bernhard Schussek - * @version SVN: $Id: LimeOutputResult.php 25932 2009-12-27 19:55:32Z bschussek $ - */ -class LimeOutputResult -{ - private - $nbExpected = null, - $nbActual = 0, - $nbPassed = 0, - $failures = array(), - $errors = array(), - $warnings = array(), - $todos = array(); - - /** - * Adds the given amount of tests to the test plan. - * - * @param integer $plan - */ - public function addPlan($plan) - { - $this->nbExpected += $plan; - } - - /** - * Adds a passed test. - */ - public function addPassed() - { - $this->nbActual++; - $this->nbPassed++; - } - - /** - * Adds a failed test. - * - * @param array $failure The test failure. An array with the failure message, - * the script, the line in the script and optionally - * the specific error. - */ - public function addFailure(array $failure) - { - $this->nbActual++; - $this->failures[] = $failure; - } - - /** - * Adds a skipped test. - */ - public function addSkipped() - { - $this->nbActual++; - $this->nbPassed++; - } - - /** - * Adds a todo. - * - * @param string $text The todo message. - */ - public function addTodo($text) - { - $this->nbActual++; - $this->todos[] = $text; - } - - /** - * Adds a test error. - * - * @param LimeError $error The error. - */ - public function addError(LimeError $error) - { - $this->errors[] = $error; - } - - /** - * Adds a test warning. - * - * @param array $warning An array with the warning message, the path of the - * test script and the line of the test script where - * the warning occurred. - */ - public function addWarning(array $warning) - { - $this->warnings[] = $warning; - } - - /** - * Returns the actual number of tests. - * - * @return integer - */ - public function getNbActual() - { - return $this->nbActual; - } - - /** - * Returns the expected number of tests. - * - * @return integer - */ - public function getNbExpected() - { - return is_null($this->nbExpected) ? $this->nbActual : $this->nbExpected; - } - - /** - * Returns the number of passed tests. - * - * @return integer - */ - public function getNbPassed() - { - return $this->nbPassed; - } - - /** - * Returns the number of failed tests. - * - * @return integer - */ - public function getNbFailures() - { - return count($this->failures); - } - - /** - * Returns the test failures. - * - * @return array - */ - public function getFailures() - { - return $this->failures; - } - - /** - * Returns whether the test has any failures. - * - * @return boolean - */ - public function hasFailures() - { - return $this->getNbFailures() > 0; - } - - /** - * Returns the number of test errors. - * - * @return integer - */ - public function getNbErrors() - { - return count($this->errors); - } - - /** - * Returns the test errors. - * - * @return array - */ - public function getErrors() - { - return $this->errors; - } - - /** - * Returns whether the test has any errors. - * - * @return boolean - */ - public function hasErrors() - { - return $this->getNbErrors() > 0; - } - - /** - * Returns the number of test warnings. - * - * @return integer - */ - public function getNbWarnings() - { - return count($this->warnings); - } - - /** - * Returns the test warnings. - * - * @return array - */ - public function getWarnings() - { - return $this->warnings; - } - - /** - * Returns whether the test has any warnings. - * - * @return boolean - */ - public function hasWarnings() - { - return $this->getNbWarnings() > 0; - } - - /** - * Returns the number of todos. - * - * @return integer - */ - public function getNbTodos() - { - return count($this->todos); - } - - /** - * Returns the todos. - * - * @return integer - */ - public function getTodos() - { - return $this->todos; - } - - /** - * Returns whether the test has any todos. - * - * @return boolean - */ - public function hasTodos() - { - return $this->getNbTodos() > 0; - } - - /** - * Returns whether not all expected tests have been executed. - * - * @return boolean - */ - public function isIncomplete() - { - return $this->nbExpected > 0 && $this->nbActual != $this->nbExpected; - } - - /** - * Returns whether the test has failed. - * - * A test is considered failed, if any test case failed, any error occurred - * or the test is incomplete, i.e. not all expected tests have been executed. - * - * @return boolean - */ - public function isFailed() - { - return $this->hasErrors() || $this->hasFailures() || $this->isIncomplete(); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputTap.php b/tests/lib/vendor/lime/output/LimeOutputTap.php deleted file mode 100644 index 8f421efd1970a..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputTap.php +++ /dev/null @@ -1,275 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputTap implements LimeOutputInterface -{ - protected - $options = array(), - $result = null, - $expected = null, - $passed = 0, - $actual = 0, - $warnings = 0, - $errors = 0, - $file = null, - $printer = null; - - public function __construct(LimePrinter $printer, array $options = array()) - { - $this->printer = $printer; - $this->result = new LimeOutputResult(); - $this->options = array_merge(array( - 'verbose' => false, - 'base_dir' => null, - ), $options); - } - - public function supportsThreading() - { - return false; - } - - private function stripBaseDir($path) - { - return is_null($this->options['base_dir']) ? $path : str_replace($this->options['base_dir'], '', $path); - } - - public function focus($file) - { - if ($this->file !== $file) - { - $this->printer->printLine('# '.$this->stripBaseDir($file), LimePrinter::INFO); - - $this->file = $file; - } - } - - public function close() - { - } - - public function plan($amount) - { - $this->result->addPlan($amount); - } - - public function pass($message, $file, $line) - { - $this->result->addPassed(); - - if (empty($message)) - { - $this->printer->printLine('ok '.$this->result->getNbActual(), LimePrinter::OK); - } - else - { - $this->printer->printText('ok '.$this->result->getNbActual(), LimePrinter::OK); - $this->printer->printLine(' - '.$message); - } - } - - public function fail($message, $file, $line, $error = null) - { - $this->result->addFailure(array($message, $file, $line, $error)); - - if (empty($message)) - { - $this->printer->printLine('not ok '.$this->result->getNbActual(), LimePrinter::NOT_OK); - } - else - { - $this->printer->printText('not ok '.$this->result->getNbActual(), LimePrinter::NOT_OK); - $this->printer->printLine(' - '.$message); - } - - $this->printer->printLine(sprintf('# Failed test (%s at line %s)', $this->stripBaseDir($file), $line), LimePrinter::COMMENT); - - if (!is_null($error)) - { - foreach (explode("\n", $error) as $line) - { - $this->printer->printLine('# '.$line, LimePrinter::COMMENT); - } - } - } - - public function skip($message, $file, $line) - { - $this->result->addSkipped(); - - if (empty($message)) - { - $this->printer->printText('ok '.$this->result->getNbActual(), LimePrinter::SKIP); - $this->printer->printText(' '); - } - else - { - $this->printer->printText('ok '.$this->result->getNbActual(), LimePrinter::SKIP); - $this->printer->printText(' - '.$message.' '); - } - - $this->printer->printLine('# SKIP', LimePrinter::SKIP); - } - - public function todo($message, $file, $line) - { - $this->result->addTodo($message); - - if (empty($message)) - { - $this->printer->printText('not ok '.$this->result->getNbActual(), LimePrinter::TODO); - $this->printer->printText(' '); - } - else - { - $this->printer->printText('not ok '.$this->result->getNbActual(), LimePrinter::TODO); - $this->printer->printText(' - '.$message.' '); - } - - $this->printer->printLine('# TODO', LimePrinter::TODO); - } - - public function warning($message, $file, $line) - { - $this->result->addWarning(array($message, $file, $line)); - - $message .= sprintf("\n(in %s on line %s)", $this->stripBaseDir($file), $line); - - $this->printer->printLargeBox($message, LimePrinter::WARNING); - } - - public function error(LimeError $error) - { - $this->result->addError($error); - - $message = sprintf("%s: %s\n(in %s on line %s)", $error->getType(), - $error->getMessage(), $this->stripBaseDir($error->getFile()), $error->getLine()); - - $this->printer->printLargeBox($message, LimePrinter::ERROR); - - $this->printer->printLine('Exception trace:', LimePrinter::COMMENT); - - $this->printTrace(null, $error->getFile(), $error->getLine()); - - foreach ($error->getTrace() as $trace) - { - // hide the part of the trace that is responsible for getting the - // annotations to work - if (strpos($trace['function'], '__lime_annotation_') === 0 && !$this->options['verbose']) - { - break; - } - - if (array_key_exists('class', $trace)) - { - $method = sprintf('%s%s%s()', $trace['class'], $trace['type'], $trace['function']); - } - else - { - $method = sprintf('%s()', $trace['function']); - } - - if (array_key_exists('file', $trace)) - { - $this->printTrace($method, $trace['file'], $trace['line']); - } - else - { - $this->printTrace($method); - } - } - - $this->printer->printLine(''); - } - - private function printTrace($method = null, $file = null, $line = null) - { - if (!is_null($method)) - { - $method .= ' '; - } - - $this->printer->printText(' '.$method.'at '); - - if (!is_null($file) && !is_null($line)) - { - $this->printer->printText($this->stripBaseDir($file), LimePrinter::TRACE); - $this->printer->printText(':'); - $this->printer->printLine($line, LimePrinter::TRACE); - } - else - { - $this->printer->printLine('[internal function]'); - } - } - - public function info($message) - { - $this->printer->printLine('# '.$message, LimePrinter::INFO); - } - - public function comment($message) - { - $this->printer->printLine('# '.$message, LimePrinter::COMMENT); - } - - public static function getMessages($actual, $expected, $passed, $errors, $warnings) - { - $messages = array(); - - if ($passed == $expected && $passed === $actual && $errors == 0) - { - if ($warnings > 0) - { - $messages[] = array('Looks like you\'re nearly there.', LimePrinter::WARNING); - } - else - { - $messages[] = array('Looks like everything went fine.', LimePrinter::HAPPY); - } - } - else if ($passed != $actual) - { - $messages[] = array(sprintf('Looks like you failed %s tests of %s.', $actual - $passed, $actual), LimePrinter::ERROR); - } - else if ($errors > 0) - { - $messages[] = array('Looks like some errors occurred.', LimePrinter::ERROR); - } - - if ($actual > $expected && $expected > 0) - { - $messages[] = array(sprintf('Looks like you only planned %s tests but ran %s.', $expected, $actual), LimePrinter::ERROR); - } - else if ($actual < $expected) - { - $messages[] = array(sprintf('Looks like you planned %s tests but only ran %s.', $expected, $actual), LimePrinter::ERROR); - } - - return $messages; - } - - public function flush() - { - $result = $this->result; - $this->printer->printLine('1..'.$result->getNbExpected()); - - $messages = self::getMessages($result->getNbActual(), $result->getNbExpected(), $result->getNbPassed(), $result->getNbErrors(), $result->getNbWarnings()); - - foreach ($messages as $message) - { - list ($message, $style) = $message; - - $this->printer->printBox(' '.$message, $style); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/output/LimeOutputXml.php b/tests/lib/vendor/lime/output/LimeOutputXml.php deleted file mode 100644 index ec482d6708809..0000000000000 --- a/tests/lib/vendor/lime/output/LimeOutputXml.php +++ /dev/null @@ -1,139 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeOutputXml implements LimeOutputInterface -{ - protected - $output = null; - - public function __construct() - { - $this->output = new LimeOutputArray(); - } - - public function supportsThreading() - { - return $this->output->supportsThreading(); - } - - public function focus($file) - { - return $this->output->focus($file); - } - - public function close() - { - return $this->output->close(); - } - - public function plan($amount) - { - return $this->output->plan($amount); - } - - public function pass($message, $file, $line) - { - return $this->output->plan($message, $file, $line); - } - - public function fail($message, $file, $line, $error = null) - { - return $this->output->fail($message, $file, $line, $error); - } - - public function skip($message, $file, $line) - { - return $this->output->skip($message, $file, $line); - } - - public function todo($message, $file, $line) - { - return $this->output->todo($message, $file, $line); - } - - public function warning($message, $file, $line) - { - return $this->output->warning($message, $file, $line); - } - - public function error(LimeError $error) - { - return $this->output->error($error); - } - - public function comment($message) - { - return $this->output->comment($message); - } - - public function flush() - { - print $this->toXml(); - } - - public function toXml() - { - $results = $this->output->toArray(); - - $dom = new DOMDocument('1.0', 'UTF-8'); - $dom->formatOutput = true; - $dom->appendChild($testsuites = $dom->createElement('testsuites')); - - $errors = 0; - $failures = 0; - $errors = 0; - $skipped = 0; - $assertions = 0; - - foreach ($results as $result) - { - $testsuites->appendChild($testSuite = $dom->createElement('testsuite')); - $testSuite->setAttribute('name', basename($result['file'], '.php')); - $testSuite->setAttribute('file', $result['file']); - $testSuite->setAttribute('failures', count($result['stats']['failed'])); - $testSuite->setAttribute('errors', 0); - $testSuite->setAttribute('skipped', count($result['stats']['skipped'])); - $testSuite->setAttribute('tests', $result['stats']['plan']); - $testSuite->setAttribute('assertions', $result['stats']['plan']); - - $failures += count($result['stats']['failed']); - $skipped += count($result['stats']['skipped']); - $assertions += $result['stats']['plan']; - - foreach ($result['tests'] as $test) - { - $testSuite->appendChild($testCase = $dom->createElement('testcase')); - $testCase->setAttribute('name', $test['message']); - $testCase->setAttribute('file', $test['file']); - $testCase->setAttribute('line', $test['line']); - $testCase->setAttribute('assertions', 1); - if (!$test['status']) - { - $testCase->appendChild($failure = $dom->createElement('failure')); - $failure->setAttribute('type', 'lime'); - if (array_key_exists('error', $test)) - { - $failure->appendChild($dom->createTextNode($test['error'])); - } - } - } - } - - $testsuites->setAttribute('failures', $failures); - $testsuites->setAttribute('errors', $errors); - $testsuites->setAttribute('tests', $assertions); - $testsuites->setAttribute('assertions', $assertions); - $testsuites->setAttribute('skipped', $skipped); - - return $dom->saveXml(); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/parser/LimeParser.php b/tests/lib/vendor/lime/parser/LimeParser.php deleted file mode 100644 index 736758019c474..0000000000000 --- a/tests/lib/vendor/lime/parser/LimeParser.php +++ /dev/null @@ -1,43 +0,0 @@ -output = $output; - } - - protected function clearErrors() - { - while (!empty($this->buffer)) - { - if (preg_match('/^\s*([\w\s]+): (.+) in (.+) on line (\d+)/', $this->buffer, $matches)) - { - $this->buffer = trim(substr($this->buffer, strlen($matches[0]))); - - if ($matches[1] == 'Warning') - { - $this->output->warning($matches[1].': '.$matches[2], $matches[3], $matches[4]); - } - else - { - $this->output->error(new LimeError($matches[2], $matches[3], $matches[4], $matches[1])); - } - - // consume Xdebug call stack - while (preg_match('/^(Call Stack:|\d\.\d+\s+\d+\s+\d+\.\s+.+:\d+)/', $this->buffer, $matches)) - { - $this->buffer = trim(substr($this->buffer, strlen($matches[0]))); - } - } - else - { - break; - } - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/parser/LimeParserInterface.php b/tests/lib/vendor/lime/parser/LimeParserInterface.php deleted file mode 100644 index 43b6a641239a7..0000000000000 --- a/tests/lib/vendor/lime/parser/LimeParserInterface.php +++ /dev/null @@ -1,8 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeParserRaw extends LimeParser -{ - protected - $suppressedMethods = array(), - $error = false; - - public function __construct(LimeOutputInterface $output, array $suppressedMethods = array()) - { - parent::__construct($output); - - $this->suppressedMethods = $suppressedMethods; - } - - public function parse($data) - { - $this->buffer .= $data; - - $lines = explode("\n", $this->buffer); - - while ($line = array_shift($lines)) - { - if (!empty($line)) - { - $this->error = false; - - set_error_handler(array($this, 'failedUnserialize')); - list($method, $arguments) = unserialize($line); - restore_error_handler(); - - if ($this->error) - { - // prepend the line again, maybe we can unserialize later - array_unshift($lines, $line); - break; - } - - if (!in_array($method, $this->suppressedMethods)) - { - foreach ($arguments as &$argument) - { - if (is_string($argument)) - { - $argument = stripcslashes($argument); - } - } - call_user_func_array(array($this->output, $method), $arguments); - } - } - } - - $this->buffer = implode("\n", $lines); - - $this->clearErrors(); - } - - public function done() - { - return empty($this->buffer); - } - - public function failedUnserialize() - { - $this->error = true; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/parser/LimeParserTap.php b/tests/lib/vendor/lime/parser/LimeParserTap.php deleted file mode 100644 index 4bd5f3482ba47..0000000000000 --- a/tests/lib/vendor/lime/parser/LimeParserTap.php +++ /dev/null @@ -1,81 +0,0 @@ -buffer .= $data; - - while (!$this->done()) - { - if (preg_match('/^(.+)\n/', $this->buffer, $matches)) - { - $this->buffer = substr($this->buffer, strlen($matches[0])); - $line = $matches[0]; - - if (preg_match('/^1\.\.(\d+)\n/', $line, $matches)) - { - $this->output->plan((int)$matches[1]); - } - else if (preg_match('/^ok \d+( - (.+?))?( # (SKIP|TODO)( .+)?)?\n/', $line, $matches)) - { - $message = count($matches) > 2 ? $matches[2] : ''; - - if (count($matches) > 3) - { - if ($matches[4] == 'SKIP') - { - $this->output->skip($message, '', ''); - } - else - { - $this->output->todo($message, '', ''); - $this->output->warning('TODOs are expected to have status "not ok"', '', ''); - } - } - else - { - $this->output->pass($message, '', ''); - } - } - else if (preg_match('/^not ok \d+( - (.+?))?( # (SKIP|TODO)( .+)?)?\n/', $line, $matches)) - { - $message = count($matches) > 2 ? $matches[2] : ''; - - if (count($matches) > 3) - { - if ($matches[4] == 'SKIP') - { - $this->output->skip($message, '', ''); - $this->output->warning('Skipped tests are expected to have status "ok"', '', ''); - } - else - { - $this->output->todo($message, '', ''); - } - } - else - { - $this->output->fail($message, '', ''); - } - } - } - else - { - break; - } - } - - $this->clearErrors(); - } - - public function done() - { - return empty($this->buffer); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/shell/LimeShell.php b/tests/lib/vendor/lime/shell/LimeShell.php deleted file mode 100644 index f3fdbc7b50ffb..0000000000000 --- a/tests/lib/vendor/lime/shell/LimeShell.php +++ /dev/null @@ -1,123 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Provides an interface to execute PHP code or files. - * - * @package lime - * @author Bernhard Schussek - * @author Fabien Potencier - * @version SVN: $Id: LimeShell.php 24323 2009-11-24 11:27:51Z bschussek $ - */ -abstract class LimeShell -{ - const - SUCCESS = 0, - FAILED = 1, - UNKNOWN = 255; - - protected static - $executable = null; - - /** - * Sets the preferred PHP executable. - * - * @param string $executable - */ - public static function setExecutable($executable) - { - self::$executable = $executable; - } - - /** - * Tries to find the system's PHP executable and returns it. - * - * @return string - */ - public static function getExecutable() - { - if (is_null(self::$executable)) - { - if (getenv('PHP_PATH')) - { - self::$executable = getenv('PHP_PATH'); - - if (!is_executable(self::$executable)) - { - throw new Exception('The defined PHP_PATH environment variable is not a valid PHP executable.'); - } - } - else - { - self::$executable = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'; - } - } - - if (!is_executable(self::$executable)) - { - $path = getenv('PATH') ? getenv('PATH') : getenv('Path'); - $extensions = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array(''); - foreach (array('php5', 'php') as $executable) - { - foreach ($extensions as $extension) - { - foreach (explode(PATH_SEPARATOR, $path) as $dir) - { - $file = $dir.DIRECTORY_SEPARATOR.$executable.$extension; - if (is_executable($file)) - { - self::$executable = $file; - break 3; - } - } - } - } - - if (!is_executable(self::$executable)) - { - throw new Exception("Unable to find PHP executable."); - } - } - - return self::$executable; - } - - /** - * Parses the given CLI arguments and returns an array of options. - * - * @param array $arguments - * @return array - */ - public static function parseArguments(array $arguments) - { - $options = array(); - - foreach ($GLOBALS['argv'] as $parameter) - { - if (preg_match('/^--([a-zA-Z\-]+)=(.+)$/', $parameter, $matches)) - { - if (in_array($matches[2], array('true', 'false'))) - { - $matches[2] = eval($matches[2]); - } - - $options[$matches[1]] = $matches[2]; - } - else if (preg_match('/^--([a-zA-Z\-]+)$/', $parameter, $matches)) - { - $options[$matches[1]] = true; - } - } - - return $options; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/shell/LimeShellCode.php b/tests/lib/vendor/lime/shell/LimeShellCode.php deleted file mode 100644 index e5ba820550d9c..0000000000000 --- a/tests/lib/vendor/lime/shell/LimeShellCode.php +++ /dev/null @@ -1,12 +0,0 @@ - $value) - { - $arguments[$argument] = '--'.$argument; - - if ($value !== true) - { - if (!is_string($value)) - { - $value = var_export($value, true); - } - - $arguments[$argument] .= '='.escapeshellarg($value); - } - } - - $this->errorFile = tempnam(sys_get_temp_dir(), 'lime'); - - // see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing - $this->command = sprintf( - 'cd & %s %s %s 2>%s', - escapeshellarg(LimeShell::getExecutable()), - escapeshellarg($file), - implode(' ', $arguments), - $this->errorFile - ); - } - - public function execute() - { - // clear old errors - $this->errors = ''; - file_put_contents($this->errorFile, ''); - - ob_start(); - passthru($this->command, $this->status); - $this->output = ob_get_clean(); - $this->errors = file_get_contents($this->errorFile); - } - - public function getStatus() - { - return $this->status; - } - - public function getOutput() - { - return $this->output; - } - - public function getErrors() - { - return $this->errors; - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/shell/LimeShellProcess.php b/tests/lib/vendor/lime/shell/LimeShellProcess.php deleted file mode 100644 index a5ed8841b2f52..0000000000000 --- a/tests/lib/vendor/lime/shell/LimeShellProcess.php +++ /dev/null @@ -1,35 +0,0 @@ -errorHandle = fopen($this->errorFile, 'w+'); // clear error file - $this->handle = popen($this->command, 'r'); - } - - public function getStatus() - { - throw new BadMethodCallException('Status is not supported by processes'); - } - - public function getOutput() - { - return feof($this->handle) ? '' : fread($this->handle, 1024); - } - - public function getErrors() - { - // don't check feof here, for some reason some errors get dropped then - return fread($this->errorHandle, 1024); - } - - public function isClosed() - { - return feof($this->handle) && feof($this->errorHandle); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTester.php b/tests/lib/vendor/lime/tester/LimeTester.php deleted file mode 100644 index ee5b3e8958345..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTester.php +++ /dev/null @@ -1,111 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -abstract class LimeTester implements LimeTesterInterface -{ - protected static - $factory = null; - - protected - $value = null, - $type = null; - - public static function create($value) - { - return self::getFactory()->create($value); - } - - public static function register($type, $tester) - { - return self::getFactory()->register($type, $tester); - } - - public static function unregister($type) - { - return self::getFactory()->unregister($type); - } - - private static function getFactory() - { - if (is_null(self::$factory)) - { - self::$factory = new LimeTesterFactory(); - } - - return self::$factory; - } - - public function __construct($value) - { - $this->value = $value; - } - - public function is(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function isnt(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function same(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function isntSame(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function like(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function unlike(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function greaterThan(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function greaterThanEqual(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function lessThan(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function lessThanEqual(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function contains(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } - - public function containsNot(LimeTesterInterface $expected) - { - throw new LimeAssertionFailedException($this, $expected); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterArray.php b/tests/lib/vendor/lime/tester/LimeTesterArray.php deleted file mode 100644 index 4391d503ad87a..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterArray.php +++ /dev/null @@ -1,293 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterArray extends LimeTester implements ArrayAccess, Iterator -{ - protected - $type = 'array'; - - public function is(LimeTesterInterface $expected) - { - if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) - { - throw new LimeAssertionFailedException($this, $expected); - } - - $remaining = $this->value; - - foreach ($expected as $key => $value) - { - if (!isset($this[$key])) - { - throw new LimeAssertionFailedException($this, $expected->dumpExcerpt($key, $value)); - } - - try - { - $this[$key]->is($value); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeAssertionFailedException($this->dumpExcerpt($key, $e->getActual()), $expected->dumpExcerpt($key, $e->getExpected())); - } - - unset($remaining[$key]); - } - - foreach ($remaining as $key => $value) - { - throw new LimeAssertionFailedException($this->dumpExcerpt($key, $value), $expected); - } - } - - public function isnt(LimeTesterInterface $expected) - { - if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) - { - return; - } - - foreach ($expected as $key => $value) - { - if (!isset($this[$key])) - { - return; - } - - try - { - $this[$key]->isnt($value); - return; - } - catch (LimeAssertionFailedException $e) - { - } - } - - throw new LimeAssertionFailedException($this, $expected); - } - - public function same(LimeTesterInterface $expected) - { - if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) - { - throw new LimeAssertionFailedException($this, $expected); - } - - for ($expected->rewind(), $this->rewind(); $expected->valid(); $expected->next(), $this->next()) - { - if (!$this->valid()) - { - throw new LimeAssertionFailedException($this, $expected->dumpExcerpt($expected->key(), $expected->current())); - } - - if ($this->key() != $expected->key()) - { - throw new LimeAssertionFailedException($this->dumpExcerpt(key($this->value), current($this->value)), $expected->dumpExcerpt($expected->key(), $expected->current())); - } - - try - { - $this->current()->same($expected->current()); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeAssertionFailedException($this->dumpExcerpt($this->key(), $e->getActual()), $expected->dumpExcerpt($expected->key(), $e->getExpected())); - } - } - - if ($this->valid()) - { - throw new LimeAssertionFailedException($this->dumpExcerpt($this->key(), $this->current()), $expected); - } - } - - public function isntSame(LimeTesterInterface $expected) - { - if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) - { - return; - } - - for ($expected->rewind(), $this->rewind(); $expected->valid(); $expected->next(), $this->next()) - { - if (!$this->valid() || $this->key() !== $expected->key()) - { - return; - } - - try - { - $this->current()->isntSame($expected->current()); - } - catch (LimeAssertionFailedException $e) - { - throw new LimeAssertionFailedException($this->dumpExcerpt($this->key(), $e->getActual()), $expected->dumpExcerpt($expected->key(), $e->getExpected())); - } - } - } - - public function contains(LimeTesterInterface $expected) - { - foreach ($this as $key => $value) - { - try - { - $value->is($expected); - return; - } - catch (LimeAssertionFailedException $e) - { - } - } - - throw new LimeAssertionFailedException($this->dumpAll(), $expected); - } - - public function containsNot(LimeTesterInterface $expected) - { - foreach ($this as $key => $value) - { - $equal = true; - - try - { - $value->is($expected); - } - catch (LimeAssertionFailedException $e) - { - $equal = false; - } - - if ($equal) - { - throw new LimeAssertionFailedException($this->dumpAll(), $expected); - } - } - } - - public function __toString() - { - return $this->dumpExcerpt(); - } - - protected function getType() - { - return 'array'; - } - - protected function dumpAll() - { - $result = $this->getType().' ('; - - if (!empty($this->value)) - { - $result .= "\n"; - - foreach ($this->value as $k => $v) - { - $result .= sprintf(" %s => %s,\n", var_export($k, true), $this->indent($v)); - } - } - - $result .= ')'; - - return $result; - } - - protected function dumpExcerpt($key = null, $value = null) - { - $result = $this->getType().' ('; - - if (!empty($this->value)) - { - $truncated = false; - $result .= "\n"; - - foreach ($this->value as $k => $v) - { - if ((is_null($key) || $key !== $k) && !$truncated) - { - $result .= " ...\n"; - $truncated = true; - } - else if ($k === $key) - { - $value = is_null($value) ? $v : $value; - $result .= sprintf(" %s => %s,\n", var_export($k, true), $this->indent($value)); - $truncated = false; - } - } - } - - $result .= ')'; - - return $result; - } - - protected function indent($lines) - { - $lines = explode("\n", $lines); - - foreach ($lines as $key => $line) - { - $lines[$key] = ' '.$line; - } - - return trim(implode("\n", $lines)); - } - - public function offsetGet($key) - { - return LimeTester::create($this->value[$key]); - } - - public function offsetExists($key) - { - return array_key_exists($key, $this->value); - } - - public function offsetSet($key, $value) - { - throw new BadMethodCallException('This method is not supported'); - } - - public function offsetUnset($key) - { - throw new BadMethodCallException('This method is not supported'); - } - - public function current() - { - return $this[$this->key()]; - } - - public function key() - { - return key($this->value); - } - - public function next() - { - next($this->value); - } - - public function valid() - { - return $this->key() !== null; - } - - public function rewind() - { - reset($this->value); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterDouble.php b/tests/lib/vendor/lime/tester/LimeTesterDouble.php deleted file mode 100644 index 5945c6844db3b..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterDouble.php +++ /dev/null @@ -1,83 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterDouble extends LimeTesterInteger -{ - const - EPSILON = 0.0000000001; - - protected - $type = 'double'; - - public function __construct($value) - { - parent::__construct((double)$value); - } - - public function __toString() - { - if ($this->value == round($this->value)) - { - return sprintf('%.1f', $this->value); - } - else - { - return (string)$this->value; - } - } - - public function is(LimeTesterInterface $expected) - { - if (is_infinite($this->value) && is_infinite($expected->value)) - { - return; - } - - if (abs($this->value - $expected->value) >= self::EPSILON) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function isnt(LimeTesterInterface $expected) - { - if ((is_infinite($this->value) && is_infinite($expected->value)) || abs($this->value - $expected->value) < self::EPSILON) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function same(LimeTesterInterface $expected) - { - $this->is($expected); - - if (gettype($this->value) != gettype($expected->value)) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function isntSame(LimeTesterInterface $expected) - { - try - { - $this->is($expected); - } - catch (LimeAssertionFailedException $e) - { - if (gettype($this->value) == gettype($expected->value)) - { - throw $e; - } - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterException.php b/tests/lib/vendor/lime/tester/LimeTesterException.php deleted file mode 100644 index 347da2e5733c2..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterException.php +++ /dev/null @@ -1,24 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterException extends LimeTesterObject -{ - public function __construct(Exception $exception) - { - parent::__construct($exception); - - unset($this->value['file']); - unset($this->value['line']); - unset($this->value['trace']); - unset($this->value['string']); // some internal property of Exception - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterFactory.php b/tests/lib/vendor/lime/tester/LimeTesterFactory.php deleted file mode 100644 index efbe1df89ccd4..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterFactory.php +++ /dev/null @@ -1,113 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterFactory -{ - protected - $testers = array( - 'null' => 'LimeTesterScalar', - 'integer' => 'LimeTesterInteger', - 'boolean' => 'LimeTesterScalar', - 'string' => 'LimeTesterString', - 'double' => 'LimeTesterDouble', - 'array' => 'LimeTesterArray', - 'object' => 'LimeTesterObject', - 'resource' => 'LimeTesterResource', - 'Exception' => 'LimeTesterException', - ); - - public function create($value) - { - $type = null; - - if (is_null($value)) - { - $type = 'null'; - } - else if (is_object($value) && array_key_exists(get_class($value), $this->testers)) - { - $type = get_class($value); - } - else if (is_object($value)) - { - $class = new ReflectionClass($value); - - foreach ($class->getInterfaces() as $interface) - { - if (array_key_exists($interface->getName(), $this->testers)) - { - $type = $interface->getName(); - break; - } - } - - $parentClass = $class; - - while ($parentClass = $parentClass->getParentClass()) - { - if (array_key_exists($parentClass->getName(), $this->testers)) - { - $type = $parentClass->getName(); - break; - } - } - - if (!empty($type)) - { - // cache the tester - $this->testers[$class->getName()] = $this->testers[$type]; - } - } - - if (empty($type)) - { - if (array_key_exists(gettype($value), $this->testers)) - { - $type = gettype($value); - } - else - { - throw new InvalidArgumentException(sprintf('No tester is registered for type "%s"', gettype($value))); - } - } - - $class = $this->testers[$type]; - - return new $class($value); - } - - public function register($type, $tester) - { - if (!class_exists($tester)) - { - throw new InvalidArgumentException(sprintf('The class "%s" does not exist', $tester)); - } - - $class = new ReflectionClass($tester); - - if (!$class->implementsInterface('LimeTesterInterface')) - { - throw new InvalidArgumentException('Testers must implement "LimeTesterInterface"'); - } - - $this->testers[$type] = $tester; - } - - public function unregister($type) - { - if (array_key_exists($type, $this->testers)) - { - unset($this->testers[$type]); - } - } - -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterInteger.php b/tests/lib/vendor/lime/tester/LimeTesterInteger.php deleted file mode 100644 index d88461db168f3..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterInteger.php +++ /dev/null @@ -1,17 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterInteger extends LimeTesterScalar -{ - protected - $type = 'integer'; -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterInterface.php b/tests/lib/vendor/lime/tester/LimeTesterInterface.php deleted file mode 100644 index 38c110997b05f..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -interface LimeTesterInterface -{ - public function __toString(); - - public function is(LimeTesterInterface $expected); - - public function isnt(LimeTesterInterface $expected); - - public function same(LimeTesterInterface $expected); - - public function isntSame(LimeTesterInterface $expected); - - public function like(LimeTesterInterface $expected); - - public function unlike(LimeTesterInterface $expected); - - public function greaterThan(LimeTesterInterface $expected); - - public function greaterThanEqual(LimeTesterInterface $expected); - - public function lessThan(LimeTesterInterface $expected); - - public function lessThanEqual(LimeTesterInterface $expected); - - public function contains(LimeTesterInterface $expected); - - public function containsNot(LimeTesterInterface $expected); -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterObject.php b/tests/lib/vendor/lime/tester/LimeTesterObject.php deleted file mode 100644 index 1fe2bf1c3c3ae..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterObject.php +++ /dev/null @@ -1,121 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterObject extends LimeTesterArray -{ - private static - $equal = array(), - $unequal = array(); - - private - $object = null; - - public static function toArray($object) - { - if (!is_object($object)) - { - throw new InvalidArgumentException('The argument must be an object'); - } - - $array = array(); - - foreach ((array)$object as $key => $value) - { - // properties are transformed to keys in the following way: - - // private $property => "\0Classname\0property" - // protected $property => "\0*\0property" - // public $property => "property" - - if (preg_match('/^\0.+\0(.+)$/', $key, $matches)) - { - $key = $matches[1]; - } - - $array[$key] = $value; - } - - return $array; - } - - public function __construct($object) - { - $this->object = $object; - $this->type = get_class($object); - - parent::__construct(self::toArray($object)); - } - - protected function getType() - { - return 'object('.$this->type.')'; - } - - public function is(LimeTesterInterface $expected) - { - // allow comparison with strings if object implements __toString() - if ($expected instanceof LimeTesterString && method_exists($this->object, '__toString')) - { - if ($expected->value != (string)$this->object) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - else - { - // don't compare twice to allow for cyclic dependencies - if (in_array(array($this->value, $expected->value), self::$equal, true) || in_array(array($expected->value, $this->value), self::$equal, true)) - { - return; - } - - self::$equal[] = array($this->value, $expected->value); - - // don't compare objects if they are identical - // this helps to avoid the error "maximum function nesting level reached" - // CAUTION: this conditional clause is not tested - if (!$expected instanceof self || $this->object !== $expected->object) - { - parent::is($expected); - } - } - } - - public function isnt(LimeTesterInterface $expected) - { - // don't compare twice to allow for cyclic dependencies - if (in_array(array($this->value, $expected->value), self::$unequal, true) || in_array(array($expected->value, $this->value), self::$unequal, true)) - { - return; - } - - self::$unequal[] = array($this->value, $expected->value); - - parent::isnt($expected); - } - - public function same(LimeTesterInterface $expected) - { - if (!$expected instanceof self || $this->object !== $expected->object) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function isntSame(LimeTesterInterface $expected) - { - if ($expected instanceof self && $this->object === $expected->object) - { - throw new LimeAssertionFailedException($this, $expected); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterResource.php b/tests/lib/vendor/lime/tester/LimeTesterResource.php deleted file mode 100644 index 6f560ef38ffde..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterResource.php +++ /dev/null @@ -1,48 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterResource extends LimeTester -{ - protected - $type = 'resource'; - - public function is(LimeTesterInterface $expected) - { - if ($this->value != $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function isnt(LimeTesterInterface $expected) - { - if ($this->value == $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function same(LimeTesterInterface $expected) - { - $this->is($expected); - } - - public function isntSame(LimeTesterInterface $expected) - { - $this->isnt($expected); - } - - public function __toString() - { - return sprintf('resource(%s) of type (%s)', (integer)$this->value, get_resource_type($this->value)); - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterScalar.php b/tests/lib/vendor/lime/tester/LimeTesterScalar.php deleted file mode 100644 index c64cbb6e805e5..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterScalar.php +++ /dev/null @@ -1,116 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterScalar extends LimeTester -{ - protected - $type = 'scalar'; - - public function __construct($value) - { - $this->type = gettype($value); - - parent::__construct($value); - } - - public function __toString() - { - return var_export($this->value, true); - } - - private function equals(LimeTesterInterface $other) - { - $exp1 = $this->value; - $exp2 = $other->value; - - if (is_scalar($exp2) || is_null($exp2)) - { - // always compare as strings to avoid strange behaviour - // otherwise 0 == 'Foobar' - if (is_string($exp1) || is_string($exp2)) - { - $exp1 = (string)$exp1; - $exp2 = (string)$exp2; - } - - return $exp1 == $exp2; - } - else - { - return false; - } - } - - public function is(LimeTesterInterface $expected) - { - if (!$this->equals($expected)) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function same(LimeTesterInterface $expected) - { - if ($this->value !== $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function isnt(LimeTesterInterface $expected) - { - if ($this->equals($expected)) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function isntSame(LimeTesterInterface $expected) - { - if ($this->value === $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function greaterThan(LimeTesterInterface $expected) - { - if ($this->value <= $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function greaterThanEqual(LimeTesterInterface $expected) - { - if ($this->value < $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function lessThanEqual(LimeTesterInterface $expected) - { - if ($this->value > $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function lessThan(LimeTesterInterface $expected) - { - if ($this->value >= $expected->value) - { - throw new LimeAssertionFailedException($this, $expected); - } - } -} \ No newline at end of file diff --git a/tests/lib/vendor/lime/tester/LimeTesterString.php b/tests/lib/vendor/lime/tester/LimeTesterString.php deleted file mode 100644 index d38204d2a9a4f..0000000000000 --- a/tests/lib/vendor/lime/tester/LimeTesterString.php +++ /dev/null @@ -1,51 +0,0 @@ - - * (c) Bernhard Schussek - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -class LimeTesterString extends LimeTesterScalar -{ - protected - $type = 'string'; - - public function __toString() - { - return "'".$this->value."'"; - } - - public function is(LimeTesterInterface $expected) - { - // allow comparison with objects that implement __toString() - if ($expected instanceof LimeTesterObject) - { - $expected->is($this); - } - else - { - parent::is($expected); - } - } - - public function like(LimeTesterInterface $expected) - { - if (!preg_match($expected->value, $this->value)) - { - throw new LimeAssertionFailedException($this, $expected); - } - } - - public function unlike(LimeTesterInterface $expected) - { - if (preg_match($expected->value, $this->value)) - { - throw new LimeAssertionFailedException($this, $expected); - } - } -} \ No newline at end of file diff --git a/tests/unit/Symfony/Components/Templating/EngineTest.php b/tests/unit/Symfony/Components/Templating/EngineTest.php deleted file mode 100644 index d20223fe0f941..0000000000000 --- a/tests/unit/Symfony/Components/Templating/EngineTest.php +++ /dev/null @@ -1,239 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../bootstrap.php'; - -require_once __DIR__.'/../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php'; - -use Symfony\Components\Templating\Engine; -use Symfony\Components\Templating\Loader\Loader; -use Symfony\Components\Templating\Loader\CompilableLoaderInterface; -use Symfony\Components\Templating\Helper\HelperSet; -use Symfony\Components\Templating\Renderer\Renderer; -use Symfony\Components\Templating\Renderer\PhpRenderer; -use Symfony\Components\Templating\Storage\Storage; -use Symfony\Components\Templating\Storage\StringStorage; - -$t = new LimeTest(33); - -class ProjectTemplateEngine extends Engine -{ - public function getLoader() - { - return $this->loader; - } - - public function getRenderers() - { - return $this->renderers; - } -} - -class ProjectTemplateRenderer extends PhpRenderer -{ - public function getEngine() - { - return $this->engine; - } -} - -class ProjectTemplateLoader extends Loader -{ - public $templates = array(); - - public function setTemplate($name, $template) - { - $this->templates[$name] = $template; - } - - public function load($template, array $options = array()) - { - if (isset($this->templates[$template.'.'.$options['renderer']])) - { - return new StringStorage($this->templates[$template.'.'.$options['renderer']]); - } - - return false; - } -} - -$loader = new ProjectTemplateLoader(); -$renderer = new ProjectTemplateRenderer(); - -// __construct() -$t->diag('__construct()'); -$engine = new ProjectTemplateEngine($loader); -$t->is($engine->getLoader(), $loader, '__construct() takes a loader instance as its second first argument'); -$t->is(array_keys($engine->getRenderers()), array('php'), '__construct() automatically registers a PHP renderer if none is given'); -$t->ok($engine->getHelperSet() instanceof HelperSet, '__construct() automatically creates a helper set if none is given'); - -$engine = new ProjectTemplateEngine($loader, array('foo' => $renderer)); -$t->is(array_keys($engine->getRenderers()), array('foo', 'php'), '__construct() takes an array of renderers as its third argument'); -$t->ok($renderer->getEngine() === $engine, '__construct() registers itself on all renderers'); - -$engine = new ProjectTemplateEngine($loader, array('php' => $renderer)); -$t->ok($engine->getRenderers() === array('php' => $renderer), '__construct() can overridde the default PHP renderer'); - -$engine = new ProjectTemplateEngine($loader, array(), $helperSet = new HelperSet()); -$t->ok($engine->getHelperSet() === $helperSet, '__construct() takes a helper set as its third argument'); - -// ->getHelperSet() ->setHelperSet() -$t->diag('->getHelperSet() ->setHelperSet()'); -$engine = new ProjectTemplateEngine($loader); -$engine->setHelperSet(new HelperSet(array('foo' => $helper = new SimpleHelper('bar')))); -$t->is((string) $engine->getHelperSet()->get('foo'), 'bar', '->setHelperSet() sets a helper set'); - -// __get() -$t->diag('__get()'); -$t->is($engine->foo, $helper, '->__get() returns the value of a helper'); - -try -{ - $engine->bar; - $t->fail('->__get() throws an InvalidArgumentException if the helper is not defined'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->__get() throws an InvalidArgumentException if the helper is not defined'); -} - -// ->get() ->set() ->has() -$t->diag('->get() ->set() ->has()'); -$engine = new ProjectTemplateEngine($loader); -$engine->set('foo', 'bar'); -$t->is($engine->get('foo'), 'bar', '->set() sets a slot value'); -$t->is($engine->get('bar', 'bar'), 'bar', '->get() takes a default value to return if the slot does not exist'); - -$t->ok($engine->has('foo'), '->has() returns true if the slot exists'); -$t->ok(!$engine->has('bar'), '->has() returns false if the slot does not exist'); - -// ->output() -$t->diag('->output()'); -ob_start(); -$ret = $engine->output('foo'); -$output = ob_get_clean(); -$t->is($output, 'bar', '->output() outputs the content of a slot'); -$t->is($ret, true, '->output() returns true if the slot exists'); - -ob_start(); -$ret = $engine->output('bar', 'bar'); -$output = ob_get_clean(); -$t->is($output, 'bar', '->output() takes a default value to return if the slot does not exist'); -$t->is($ret, true, '->output() returns true if the slot does not exist but a default value is provided'); - -ob_start(); -$ret = $engine->output('bar'); -$output = ob_get_clean(); -$t->is($output, '', '->output() outputs nothing if the slot does not exist'); -$t->is($ret, false, '->output() returns false if the slot does not exist'); - -// ->start() ->stop() -$t->diag('->start() ->stop()'); -$engine->start('bar'); -echo 'foo'; -$engine->stop(); -$t->is($engine->get('bar'), 'foo', '->start() starts a slot'); -$t->ok($engine->has('bar'), '->starts() starts a slot'); - -$engine->start('bar'); -try -{ - $engine->start('bar'); - $engine->stop(); - $t->fail('->start() throws an InvalidArgumentException if a slot with the same name is already started'); -} -catch (InvalidArgumentException $e) -{ - $engine->stop(); - $t->pass('->start() throws an InvalidArgumentException if a slot with the same name is already started'); -} - -try -{ - $engine->stop(); - $t->fail('->stop() throws an LogicException if no slot is started'); -} -catch (LogicException $e) -{ - $t->pass('->stop() throws an LogicException if no slot is started'); -} - -// ->extend() ->render() -$t->diag('->extend() ->render()'); -$engine = new ProjectTemplateEngine($loader); -try -{ - $engine->render('name'); - $t->fail('->render() throws an InvalidArgumentException if the template does not exist'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->render() throws an InvalidArgumentException if the template does not exist'); -} - -try -{ - $loader->setTemplate('name.foo', 'foo'); - $engine->render('foo:name'); - $t->fail('->render() throws an InvalidArgumentException if no renderer is registered for the given renderer'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->render() throws an InvalidArgumentException if no renderer is registered for the given renderer'); -} - -$engine->getHelperSet()->set(new SimpleHelper('bar')); -$loader->setTemplate('foo.php', 'extend("layout"); echo $view->foo.$foo ?>'); -$loader->setTemplate('layout.php', '-get("content") ?>-'); -$t->is($engine->render('foo', array('foo' => 'foo')), '-barfoo-', '->render() uses the decorator to decorate the template'); - -$loader->setTemplate('bar.php', 'bar'); -$loader->setTemplate('foo.php', 'extend("layout"); echo $foo ?>'); -$loader->setTemplate('layout.php', 'render("bar") ?>-get("content") ?>-'); -$t->is($engine->render('foo', array('foo' => 'foo', 'bar' => 'bar')), 'bar-foo-', '->render() supports render() calls in templates'); - -class CompilableTemplateLoader extends Loader implements CompilableLoaderInterface -{ - public function load($template, array $options = array()) - { - return new StringStorage($template, 'foo'); - } - - public function compile($template) - { - return 'COMPILED'; - } -} - -class FooTemplateRenderer extends Renderer -{ - public function evaluate(Storage $template, array $parameters = array()) - { - return 'foo'; - } -} - -$t->diag('compilable templates'); -$engine = new ProjectTemplateEngine(new CompilableTemplateLoader(), array('foo' => new FooTemplateRenderer())); -$t->is($engine->render('index'), 'foo', '->load() takes into account the renderer embedded in the Storage instance if not null'); - -// ->escape() -$t->diag('->escape()'); -$engine = new ProjectTemplateEngine($loader); -$t->is($engine->escape('
'), '<br />', '->escape() escapes strings'); -$t->is($engine->escape($foo = new stdClass()), $foo, '->escape() does nothing on non strings'); - -// ->getCharset() ->setCharset() -$t->diag('->getCharset() ->setCharset()'); -$engine = new ProjectTemplateEngine($loader); -$t->is($engine->getCharset(), 'UTF-8', '->getCharset() returns UTF-8 by default'); -$engine->setCharset('ISO-8859-1'); -$t->is($engine->getCharset(), 'ISO-8859-1', '->setCharset() changes the default charset to use'); diff --git a/tests/unit/Symfony/Components/Templating/Helper/AssetsTest.php b/tests/unit/Symfony/Components/Templating/Helper/AssetsTest.php deleted file mode 100644 index 6e2c0c7a6b87f..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Helper/AssetsTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * 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\Helper\AssetsHelper; - -$t = new LimeTest(25); - -// __construct() -$t->diag('__construct()'); -$helper = new AssetsHelper('foo', 'http://www.example.com', 'abcd'); -$t->is($helper->getBasePath(), '/foo/', '__construct() takes a base path as its first argument'); -$t->is($helper->getBaseURLs(), array('http://www.example.com'), '__construct() takes a base URL as its second argument'); -$t->is($helper->getVersion(), 'abcd', '__construct() takes a version as its thrid argument'); - -// ->getBasePath() ->setBasePath() -$t->diag('->getBasePath() ->setBasePath()'); -$helper = new AssetsHelper(); -$helper->setBasePath('foo/'); -$t->is($helper->getBasePath(), '/foo/', '->setBasePath() prepends a / if needed'); -$helper->setBasePath('/foo'); -$t->is($helper->getBasePath(), '/foo/', '->setBasePath() appends a / is needed'); -$helper->setBasePath(''); -$t->is($helper->getBasePath(), '/', '->setBasePath() returns / if no base path is defined'); -$helper->setBasePath('0'); -$t->is($helper->getBasePath(), '/0/', '->setBasePath() returns /0/ if 0 is given'); - -// ->getVersion() ->getVersion() -$t->diag('->getVersion() ->getVersion()'); -$helper = new AssetsHelper(); -$helper->setVersion('foo'); -$t->is($helper->getVersion(), 'foo', '->setVersion() sets the version'); - -// ->setBaseURLs() ->getBaseURLs() -$t->diag('->setBaseURLs() ->getBaseURLs()'); -$helper = new AssetsHelper(); -$helper->setBaseURLs('http://www.example.com/'); -$t->is($helper->getBaseURLs(), array('http://www.example.com'), '->setBaseURLs() removes the / at the of an absolute base path'); -$helper->setBaseURLs(array('http://www1.example.com/', 'http://www2.example.com/')); -$URLs = array(); -for ($i = 0; $i < 20; $i++) -{ - $URLs[] = $helper->getBaseURL($i); -} -$URLs = array_values(array_unique($URLs)); -sort($URLs); -$t->is($URLs, array('http://www1.example.com', 'http://www2.example.com'), '->getBaseURL() returns a random base URL if several are given'); -$helper->setBaseURLs(''); -$t->is($helper->getBaseURL(1), '', '->getBaseURL() returns an empty string if no base URL exist'); - -// ->getUrl() -$t->diag('->getUrl()'); -$helper = new AssetsHelper(); -$t->is($helper->getUrl('http://example.com/foo.js'), 'http://example.com/foo.js', '->getUrl() does nothing if an absolute URL is given'); - -$helper = new AssetsHelper(); -$t->is($helper->getUrl('foo.js'), '/foo.js', '->getUrl() appends a / on relative paths'); -$t->is($helper->getUrl('/foo.js'), '/foo.js', '->getUrl() does nothing on absolute paths'); - -$helper = new AssetsHelper('/foo'); -$t->is($helper->getUrl('foo.js'), '/foo/foo.js', '->getUrl() appends the basePath on relative paths'); -$t->is($helper->getUrl('/foo.js'), '/foo.js', '->getUrl() does not append the basePath on absolute paths'); - -$helper = new AssetsHelper(null, 'http://assets.example.com/'); -$t->is($helper->getUrl('foo.js'), 'http://assets.example.com/foo.js', '->getUrl() prepends the base URL'); -$t->is($helper->getUrl('/foo.js'), 'http://assets.example.com/foo.js', '->getUrl() prepends the base URL'); - -$helper = new AssetsHelper(null, 'http://www.example.com/foo'); -$t->is($helper->getUrl('foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL with a path'); -$t->is($helper->getUrl('/foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL with a path'); - -$helper = new AssetsHelper('/foo', 'http://www.example.com/'); -$t->is($helper->getUrl('foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL and the base path if defined'); -$t->is($helper->getUrl('/foo.js'), 'http://www.example.com/foo.js', '->getUrl() prepends the base URL but not the base path on absolute paths'); - -$helper = new AssetsHelper('/bar', 'http://www.example.com/foo'); -$t->is($helper->getUrl('foo.js'), 'http://www.example.com/foo/bar/foo.js', '->getUrl() prepends the base URL and the base path if defined'); -$t->is($helper->getUrl('/foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL but not the base path on absolute paths'); - -$helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd'); -$t->is($helper->getUrl('foo.js'), 'http://www.example.com/foo/bar/foo.js?abcd', '->getUrl() appends the version if defined'); diff --git a/tests/unit/Symfony/Components/Templating/Helper/HelperSetTest.php b/tests/unit/Symfony/Components/Templating/Helper/HelperSetTest.php deleted file mode 100644 index a8f9577522230..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Helper/HelperSetTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../../bootstrap.php'; - -require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php'; - -use Symfony\Components\Templating\Helper\HelperSet; -use Symfony\Components\Templating\Engine; -use Symfony\Components\Templating\Loader\FilesystemLoader; - -$t = new LimeTest(7); - -$engine = new Engine(new FilesystemLoader('/')); - -// __construct() -$t->diag('__construct()'); -$helperSet = new HelperSet(array('foo' => $helper = new SimpleHelper('foo'))); -$t->ok($helperSet->has('foo'), '__construct() takes an array of helpers as its first argument'); - -// ->setEngine() -$t->diag('->getEngine()'); -$helperSet = new HelperSet(array('foo' => $helper = new SimpleHelper('foo'))); -$t->ok($helper->getHelperSet() === $helperSet, '->__construct() changes the embedded helper set of the given helpers'); - -// ->get() ->set() ->has() -$t->diag('->getHelper() ->setHelper() ->has()'); -$helperSet = new HelperSet(); -$helperSet->set($helper = new SimpleHelper('bar')); -$t->ok($helper->getHelperSet() === $helperSet, '->set() changes the embedded helper set of the helper'); -$t->is((string) $helperSet->get('foo'), 'bar', '->set() sets a helper value'); - -$t->ok($helperSet->has('foo'), '->has() returns true if the helper is defined'); -$t->ok(!$helperSet->has('bar'), '->has() returns false if the helper is not defined'); - -try -{ - $helperSet->get('bar'); - $t->fail('->get() throws an InvalidArgumentException if the helper is not defined'); -} -catch (InvalidArgumentException $e) -{ - $t->pass('->get() throws an InvalidArgumentException if the helper is not defined'); -} diff --git a/tests/unit/Symfony/Components/Templating/Helper/HelperTest.php b/tests/unit/Symfony/Components/Templating/Helper/HelperTest.php deleted file mode 100644 index e77856a634b67..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Helper/HelperTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * 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\Helper\Helper; -use Symfony\Components\Templating\Helper\HelperSet; - -$t = new LimeTest(1); - -class ProjectTemplateHelper extends Helper -{ - public function getName() - { - return 'foo'; - } -} - -// ->getHelperSet() ->setHelperSet() -$t->diag('->getHelperSet() ->setHelperSet()'); -$helper = new ProjectTemplateHelper(); -$helper->setHelperSet($helperSet = new HelperSet(array($helper))); -$t->ok($helperSet === $helper->getHelperSet(), '->setHelperSet() sets the helper set related to this helper'); diff --git a/tests/unit/Symfony/Components/Templating/Helper/JavascriptsHelperTest.php b/tests/unit/Symfony/Components/Templating/Helper/JavascriptsHelperTest.php deleted file mode 100644 index 6e4464e2199a2..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Helper/JavascriptsHelperTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\Helper\AssetsHelper; -use Symfony\Components\Templating\Helper\JavascriptsHelper; -use Symfony\Components\Templating\Helper\HelperSet; -use Symfony\Components\Templating\Engine; -use Symfony\Components\Templating\Loader\FilesystemLoader; - -$t = new LimeTest(4); - -$helperSet = new HelperSet(array( - new AssetsHelper(), -)); - -// ->add() -$t->diag('->add()'); -$helper = new JavascriptsHelper(); -$helperSet->set($helper); -$helper->add('foo'); -$t->is($helper->get(), array('/foo' => array()), '->add() adds a JavaScript'); -$helper->add('/foo'); -$t->is($helper->get(), array('/foo' => array()), '->add() does not add the same JavaScript twice'); -$helper = new JavascriptsHelper(); -$helperSet->set($helper); -$helperSet->get('assets')->setBaseURLs('http://assets.example.com/'); -$helper->add('foo'); -$t->is($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the JavaScript to a public path'); - -// ->__toString() -$t->diag('->__toString()'); -$helper = new JavascriptsHelper(); -$helperSet->set($helper); -$helperSet->get('assets')->setBaseURLs(''); -$helperSet->setEngine($engine = new Engine(new FilesystemLoader('/'))); -$helper->add('foo', array('class' => 'ba>')); -$t->is($helper->__toString(), '', '->__toString() converts the JavaScript configuration to HTML'); diff --git a/tests/unit/Symfony/Components/Templating/Helper/StylesheetsHelperTest.php b/tests/unit/Symfony/Components/Templating/Helper/StylesheetsHelperTest.php deleted file mode 100644 index 3464278444eb5..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Helper/StylesheetsHelperTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\Helper\AssetsHelper; -use Symfony\Components\Templating\Helper\StylesheetsHelper; -use Symfony\Components\Templating\Helper\HelperSet; -use Symfony\Components\Templating\Engine; -use Symfony\Components\Templating\Loader\FilesystemLoader; - -$t = new LimeTest(4); - -$helperSet = new HelperSet(array( - new AssetsHelper(), -)); - -// ->add() -$t->diag('->add()'); -$helper = new StylesheetsHelper(); -$helperSet->set($helper); -$helper->add('foo'); -$t->is($helper->get(), array('/foo' => array()), '->add() adds a stylesheet'); -$helper->add('/foo'); -$t->is($helper->get(), array('/foo' => array()), '->add() does not add the same stylesheet twice'); -$helper = new StylesheetsHelper(); -$helperSet->set($helper); -$helperSet->get('assets')->setBaseURLs('http://assets.example.com/'); -$helper->add('foo'); -$t->is($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the stylesheet to a public path'); - -// ->__toString() -$t->diag('->__toString()'); -$helper = new StylesheetsHelper(); -$helperSet->set($helper); -$helperSet->get('assets')->setBaseURLs(''); -$helperSet->setEngine($engine = new Engine(new FilesystemLoader('/'))); -$helper->add('foo', array('media' => 'ba>')); -$t->is($helper->__toString(), '', '->__toString() converts the stylesheet configuration to HTML'); diff --git a/tests/unit/Symfony/Components/Templating/Loader/CacheLoaderTest.php b/tests/unit/Symfony/Components/Templating/Loader/CacheLoaderTest.php deleted file mode 100644 index 5ea89f2fead34..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Loader/CacheLoaderTest.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../../bootstrap.php'; - -require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; - -use Symfony\Components\Templating\Loader\Loader; -use Symfony\Components\Templating\Loader\CacheLoader; -use Symfony\Components\Templating\Loader\CompilableLoaderInterface; -use Symfony\Components\Templating\Storage\StringStorage; - -$t = new LimeTest(9); - -class ProjectTemplateLoader extends CacheLoader -{ - public function getDir() - { - return $this->dir; - } - - public function getLoader() - { - return $this->loader; - } -} - -class ProjectTemplateLoaderVar extends Loader -{ - public function getIndexTemplate() - { - return 'Hello World'; - } - - public function getSpecialTemplate() - { - return 'Hello {{ name }}'; - } - - public function load($template, array $options = array()) - { - if (method_exists($this, $method = 'get'.ucfirst($template).'Template')) - { - return new StringStorage($this->$method()); - } - - return false; - } -} - -class CompilableTemplateLoader extends ProjectTemplateLoaderVar implements CompilableLoaderInterface -{ - public function compile($template) - { - return preg_replace('/{{\s*([a-zA-Z0-9_]+)\s*}}/', '', $template); - } -} - -// __construct() -$t->diag('__construct()'); -$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), sys_get_temp_dir()); -$t->ok($loader->getLoader() === $varLoader, '__construct() takes a template loader as its first argument'); -$t->is($loader->getDir(), sys_get_temp_dir(), '__construct() takes a directory where to store the cache as its second argument'); - -// ->load() -$t->diag('->load()'); - -$dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999); -mkdir($dir, 0777, true); - -$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir); -$loader->setDebugger($debugger = new ProjectTemplateDebugger()); -$t->ok($loader->load('foo') === false, '->load() returns false if the embed loader is not able to load the template'); -$loader->load('index'); -$t->ok($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); -$loader->load('index'); -$t->ok($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); - -$t->diag('load() template compilation'); -$dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999); -mkdir($dir, 0777, true); - -$loader = new ProjectTemplateLoader(new CompilableTemplateLoader(), $dir); -$loader->setDebugger($debugger = new ProjectTemplateDebugger()); -$template = $loader->load('special', array('renderer' => 'comp')); -$t->ok($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); -$t->is($template->getRenderer(), 'php', '->load() changes the renderer to php if the template is compilable'); - -$template = $loader->load('special', array('renderer' => 'comp')); -$t->ok($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); -$t->is($template->getRenderer(), 'php', '->load() changes the renderer to php if the template is compilable'); diff --git a/tests/unit/Symfony/Components/Templating/Loader/ChainLoaderTest.php b/tests/unit/Symfony/Components/Templating/Loader/ChainLoaderTest.php deleted file mode 100644 index 882b58a2c42b0..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Loader/ChainLoaderTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../../bootstrap.php'; - -require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; - -use Symfony\Components\Templating\Loader\ChainLoader; -use Symfony\Components\Templating\Loader\FilesystemLoader; -use Symfony\Components\Templating\Storage\FileStorage; - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/'); - -$t = new LimeTest(5); - -class ProjectTemplateLoader extends ChainLoader -{ - public function getLoaders() - { - return $this->loaders; - } -} - -$loader1 = new FilesystemLoader($fixturesPath.'/null/%name%'); -$loader2 = new FilesystemLoader($fixturesPath.'/templates/%name%.%renderer%'); - -// __construct() -$t->diag('__construct()'); -$loader = new ProjectTemplateLoader(array($loader1, $loader2)); -$t->is($loader->getLoaders(), array($loader1, $loader2), '__construct() takes an array of template loaders as its second argument'); - -// ->addLoader() -$t->diag('->addLoader()'); -$loader = new ProjectTemplateLoader(array($loader1)); -$loader->addLoader($loader2); -$t->is($loader->getLoaders(), array($loader1, $loader2), '->addLoader() adds a template loader at the end of the loaders'); - -// ->load() -$t->diag('->load()'); -$loader = new ProjectTemplateLoader(array($loader1, $loader2)); -$t->ok($loader->load('bar') === false, '->load() returns false if the template is not found'); -$t->ok($loader->load('foo', array('renderer' => 'xml')) === false, '->load() returns false if the template does not exists for the given renderer'); -$t->ok($loader->load('foo') instanceof FileStorage, '->load() returns a FileStorage if the template exists'); diff --git a/tests/unit/Symfony/Components/Templating/Loader/FilesystemLoaderTest.php b/tests/unit/Symfony/Components/Templating/Loader/FilesystemLoaderTest.php deleted file mode 100644 index 4888b09a0671d..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Loader/FilesystemLoaderTest.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../../bootstrap.php'; - -require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; - -use Symfony\Components\Templating\Loader\FilesystemLoader; -use Symfony\Components\Templating\Storage\FileStorage; - -$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/'); - -$t = new LimeTest(14); - -class ProjectTemplateLoader extends FilesystemLoader -{ - public function getTemplatePathPatterns() - { - return $this->templatePathPatterns; - } - - static public function isAbsolutePath($path) - { - return parent::isAbsolutePath($path); - } -} - -// ->isAbsolutePath() -$t->diag('->isAbsolutePath()'); -$t->ok(ProjectTemplateLoader::isAbsolutePath('/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); -$t->ok(ProjectTemplateLoader::isAbsolutePath('c:\\\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); -$t->ok(ProjectTemplateLoader::isAbsolutePath('c:/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); -$t->ok(ProjectTemplateLoader::isAbsolutePath('\\server\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path'); - -// __construct() -$t->diag('__construct()'); -$pathPattern = $fixturesPath.'/templates/%name%.%renderer%'; -$path = $fixturesPath.'/templates'; -$loader = new ProjectTemplateLoader($pathPattern); -$t->is($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes a path as its second argument'); -$loader = new ProjectTemplateLoader(array($pathPattern)); -$t->is($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes an array of paths as its second argument'); - -// ->load() -$t->diag('->load()'); -$loader = new ProjectTemplateLoader($pathPattern); -$storage = $loader->load($path.'/foo.php'); -$t->ok($storage instanceof FileStorage, '->load() returns a FileStorage if you pass an absolute path'); -$t->is((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the passed absolute path'); - -$t->ok($loader->load('bar') === false, '->load() returns false if the template is not found'); - -$storage = $loader->load('foo'); -$t->ok($storage instanceof FileStorage, '->load() returns a FileStorage if you pass a relative template that exists'); -$t->is((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the absolute path of the template'); - -$loader = new ProjectTemplateLoader($pathPattern); -$loader->setDebugger($debugger = new ProjectTemplateDebugger()); -$t->ok($loader->load('foo', array('renderer' => 'xml')) === false, '->load() returns false if the template does not exists for the given renderer'); -$t->ok($debugger->hasMessage('Failed loading template'), '->load() logs a "Failed loading template" message if the template is not found'); - -$loader = new ProjectTemplateLoader(array($fixturesPath.'/null/%name%', $pathPattern)); -$loader->setDebugger($debugger = new ProjectTemplateDebugger()); -$loader->load('foo'); -$t->ok($debugger->hasMessage('Loaded template file'), '->load() logs a "Loaded template file" message if the template is found'); diff --git a/tests/unit/Symfony/Components/Templating/Renderer/PhpRendererTest.php b/tests/unit/Symfony/Components/Templating/Renderer/PhpRendererTest.php deleted file mode 100644 index 9f40a38d2120a..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Renderer/PhpRendererTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * 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\Renderer\PhpRenderer; -use Symfony\Components\Templating\Storage\Storage; -use Symfony\Components\Templating\Storage\StringStorage; -use Symfony\Components\Templating\Storage\FileStorage; - -$t = new LimeTest(2); - -$renderer = new PhpRenderer(); - -// ->evaluate() -$t->diag('->evaluate()'); - -$template = new StringStorage(''); -$t->is($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of StringStorage'); - -$template = new FileStorage(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/templates/foo.php'); -$t->is($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of FileStorage'); diff --git a/tests/unit/Symfony/Components/Templating/Storage/FileStorageTest.php b/tests/unit/Symfony/Components/Templating/Storage/FileStorageTest.php deleted file mode 100644 index 86c02afb5e6af..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Storage/FileStorageTest.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * 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\Storage\FileStorage; - -$t = new LimeTest(2); - -$storage = new FileStorage('foo'); -$t->ok($storage instanceof Storage, 'FileStorage is an instance of Storage'); - -// ->getContent() -$t->diag('->getContent()'); -$storage = new FileStorage(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/templates/foo.php'); -$t->is($storage->getContent(), '', '->getContent() returns the content of the template'); diff --git a/tests/unit/Symfony/Components/Templating/Storage/StorageTest.php b/tests/unit/Symfony/Components/Templating/Storage/StorageTest.php deleted file mode 100644 index a4f398ea2745d..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Storage/StorageTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * 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'); diff --git a/tests/unit/Symfony/Components/Templating/Storage/StringStorageTest.php b/tests/unit/Symfony/Components/Templating/Storage/StringStorageTest.php deleted file mode 100644 index 3b18b808450ab..0000000000000 --- a/tests/unit/Symfony/Components/Templating/Storage/StringStorageTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * 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\Storage\StringStorage; - -$t = new LimeTest(2); - -$storage = new StringStorage('foo'); -$t->ok($storage instanceof Storage, 'StringStorage is an instance of Storage'); - - -// ->getContent() -$t->diag('->getContent()'); -$storage = new StringStorage('foo'); -$t->is($storage->getContent(), 'foo', '->getContent() returns the content of the template'); diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php deleted file mode 100644 index 32a6688314ee3..0000000000000 --- a/tests/unit/bootstrap.php +++ /dev/null @@ -1,17 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../lib/vendor/lime/LimeAutoloader.php'; -LimeAutoloader::register(); - -require_once __DIR__.'/../../src/Symfony/Foundation/ClassLoader.php'; -$loader = new Symfony\Foundation\ClassLoader(); -$loader->registerNamespace('Symfony', __DIR__.'/../../src'); -$loader->register(); From d65ab5bc820c04f85a5782f2208b369fdf6b73e4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Mar 2010 23:33:24 +0800 Subject: [PATCH 13/54] [DependencyInjection] fixed a unit test --- .../Components/DependencyInjection/Loader/FileLoaderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php index c24610b9d4a64..876d3f21b36e1 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php @@ -28,7 +28,7 @@ public function testConstructor() public function testGetAbsolutePath() { - $loader = new ProjectLoader(array(__DIR__.'/../../../../../bin')); + $loader = new ProjectLoader(array(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/containers')); $this->assertEquals($loader->getAbsolutePath('/foo.xml'), '/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); $this->assertEquals($loader->getAbsolutePath('c:\\\\foo.xml'), 'c:\\\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); $this->assertEquals($loader->getAbsolutePath('c:/foo.xml'), 'c:/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); @@ -36,7 +36,7 @@ public function testGetAbsolutePath() $this->assertEquals($loader->getAbsolutePath('FileLoaderTest.php', __DIR__), __DIR__.'/FileLoaderTest.php', '->getAbsolutePath() returns an absolute filename if the file exists in the current path'); - $this->assertEquals($loader->getAbsolutePath('prove.php', __DIR__), __DIR__.'/../../../../../bin/prove.php', '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor'); + $this->assertEquals($loader->getAbsolutePath('container10.php', __DIR__), __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/containers/container10.php', '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor'); $this->assertEquals($loader->getAbsolutePath('foo.xml', __DIR__), 'foo.xml', '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths'); } From 031ed09c15327680822644903af00c9e67be116e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Mar 2010 23:47:20 +0800 Subject: [PATCH 14/54] added a global phpunit.xml file --- phpunit.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000000000..94c770c747db4 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + + + ./tests/Symfony/ + ./src/Symfony/Framework/ + + + From 3d89f34f3f0cd7aa220a4f4f4ea9612caf00194c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 19 Mar 2010 00:03:29 +0800 Subject: [PATCH 15/54] added coverage configuration in phpunit.xml --- phpunit.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpunit.xml b/phpunit.xml index 94c770c747db4..f8674c02f836e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -16,4 +16,23 @@ ./src/Symfony/Framework/ + + + + ./src/Symfony/ + + ./src/Symfony/Framework/DoctrineBundle + ./src/Symfony/Framework/ZendBundle + + ./src/Symfony/Framework/DoctrineBundle/Resources + ./src/Symfony/Framework/ProfilerBundle/Resources + ./src/Symfony/Framework/SwiftmailerBundle/Resources + ./src/Symfony/Framework/WebBundle/Resources + ./src/Symfony/Framework/ZendBundle/Resources + + src/Symfony/Foundation/bootstrap.php + src/Symfony/Foundation/packager.php + + + From 5eaf109e1797c36562ca9399a6a449e63e9a5dd6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 19 Mar 2010 03:55:41 +0800 Subject: [PATCH 16/54] tweaked phpunit.xml --- phpunit.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index f8674c02f836e..446c84e0c575e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="true" + stopOnFailure="false" syntaxCheck="false" > @@ -30,8 +30,8 @@ ./src/Symfony/Framework/WebBundle/Resources ./src/Symfony/Framework/ZendBundle/Resources - src/Symfony/Foundation/bootstrap.php - src/Symfony/Foundation/packager.php + ./src/Symfony/Foundation/bootstrap.php + ./src/Symfony/Foundation/packager.php From e9d3e001d0d951399059c8c23bb92f3121a50831 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 19 Mar 2010 22:04:37 +0800 Subject: [PATCH 17/54] fixed assertEquals() calls arguments order The conversion has been done automatically with the following command: perl -p -i -e 's#this\->assertEquals\((.+?), (.+?)(, '\''(\-|\:|_)|\);)#this->assertEquals($2, $1$3#g' tests/Symfony/Tests/*/*.php tests/Symfony/Tests/*/*/*.php tests/Symfony/Tests/*/*/*.php ... and with some manual tweaking after that --- .../Components/Console/ApplicationTest.php | 80 +++++++++--------- .../Console/Command/CommandTest.php | 64 +++++++------- .../Console/Helper/FormatterHelperTest.php | 8 +- .../Console/Input/ArgvInputTest.php | 34 ++++---- .../Console/Input/ArrayInputTest.php | 16 ++-- .../Console/Input/InputArgumentTest.php | 18 ++-- .../Console/Input/InputDefinitionTest.php | 84 +++++++++---------- .../Console/Input/InputOptionTest.php | 50 +++++------ .../Components/Console/Input/InputTest.php | 22 ++--- .../Console/Input/StringInputTest.php | 46 +++++----- .../Console/Output/ConsoleOutputTest.php | 2 +- .../Components/Console/Output/OutputTest.php | 22 ++--- .../Console/Output/StreamOutputTest.php | 8 +- .../Console/Tester/ApplicationTesterTest.php | 12 +-- .../Console/Tester/CommandTesterTest.php | 12 +-- .../BuilderConfigurationTest.php | 56 ++++++------- .../DependencyInjection/BuilderTest.php | 62 +++++++------- .../DependencyInjection/ContainerTest.php | 46 +++++----- .../DependencyInjection/CrossCheckTest.php | 6 +- .../DependencyInjection/DefinitionTest.php | 48 +++++------ .../Dumper/GraphvizDumperTest.php | 6 +- .../Dumper/PhpDumperTest.php | 8 +- .../Dumper/XmlDumperTest.php | 6 +- .../Dumper/YamlDumperTest.php | 6 +- .../DependencyInjection/FileResourceTest.php | 2 +- .../Loader/FileLoaderTest.php | 18 ++-- .../Loader/IniFileLoaderTest.php | 2 +- .../Loader/LoaderExtensionTest.php | 2 +- .../Loader/XmlFileLoaderTest.php | 54 ++++++------ .../Loader/YamlFileLoaderTest.php | 26 +++--- .../DependencyInjection/ParameterTest.php | 2 +- .../DependencyInjection/ReferenceTest.php | 2 +- .../EventDispatcher/EventDispatcherTest.php | 36 ++++---- .../Components/EventDispatcher/EventTest.php | 21 ++--- .../OutputEscaper/ArrayDecoratorTest.php | 16 ++-- .../Components/OutputEscaper/EscaperTest.php | 40 ++++----- .../OutputEscaper/ObjectDecoratorTest.php | 6 +- .../OutputEscaper/SafeDecoratorTest.php | 24 +++--- .../Components/Templating/EngineTest.php | 27 +++--- .../Templating/Helper/AssetsTest.php | 50 +++++------ .../Helper/JavascriptsHelperTest.php | 8 +- .../Templating/Helper/SlotsHelperTest.php | 18 ++-- .../Helper/StylesheetsHelperTest.php | 8 +- .../Templating/Loader/CacheLoaderTest.php | 6 +- .../Templating/Loader/ChainLoaderTest.php | 4 +- .../Loader/FilesystemLoaderTest.php | 8 +- .../Templating/Renderer/PhpRendererTest.php | 4 +- .../Templating/Storage/FileStorageTest.php | 2 +- .../Templating/Storage/StorageTest.php | 2 +- .../Templating/Storage/StringStorageTest.php | 2 +- .../Tests/Components/Yaml/DumperTest.php | 18 ++-- .../Tests/Components/Yaml/InlineTest.php | 8 +- .../Tests/Components/Yaml/ParserTest.php | 2 +- 53 files changed, 571 insertions(+), 569 deletions(-) diff --git a/tests/Symfony/Tests/Components/Console/ApplicationTest.php b/tests/Symfony/Tests/Components/Console/ApplicationTest.php index 9084040943d83..05e554b697e4b 100644 --- a/tests/Symfony/Tests/Components/Console/ApplicationTest.php +++ b/tests/Symfony/Tests/Components/Console/ApplicationTest.php @@ -33,53 +33,53 @@ static public function setUpBeforeClass() public function testConstructor() { $application = new Application('foo', 'bar'); - $this->assertEquals($application->getName(), 'foo', '__construct() takes the application name as its first argument'); - $this->assertEquals($application->getVersion(), 'bar', '__construct() takes the application version as its first argument'); - $this->assertEquals(array_keys($application->getCommands()), array('help', 'list'), '__construct() registered the help and list commands by default'); + $this->assertEquals('foo', $application->getName(), '__construct() takes the application name as its first argument'); + $this->assertEquals('bar', $application->getVersion(), '__construct() takes the application version as its first argument'); + $this->assertEquals(array('help', 'list'), array_keys($application->getCommands()), '__construct() registered the help and list commands by default'); } public function testSetGetName() { $application = new Application(); $application->setName('foo'); - $this->assertEquals($application->getName(), 'foo', '->setName() sets the name of the application'); + $this->assertEquals('foo', $application->getName(), '->setName() sets the name of the application'); } public function testSetGetVersion() { $application = new Application(); $application->setVersion('bar'); - $this->assertEquals($application->getVersion(), 'bar', '->setVersion() sets the version of the application'); + $this->assertEquals('bar', $application->getVersion(), '->setVersion() sets the version of the application'); } public function testGetLongVersion() { $application = new Application('foo', 'bar'); - $this->assertEquals($application->getLongVersion(), 'foo version bar', '->getLongVersion() returns the long version of the application'); + $this->assertEquals('foo version bar', $application->getLongVersion(), '->getLongVersion() returns the long version of the application'); } public function testHelp() { $application = new Application(); - $this->assertEquals($application->getHelp(), file_get_contents(self::$fixturesPath.'/application_gethelp.txt'), '->setHelp() returns a help message'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_gethelp.txt'), $application->getHelp(), '->setHelp() returns a help message'); } public function testGetCommands() { $application = new Application(); $commands = $application->getCommands(); - $this->assertEquals(get_class($commands['help']), 'Symfony\\Components\\Console\\Command\\HelpCommand', '->getCommands() returns the registered commands'); + $this->assertEquals('Symfony\\Components\\Console\\Command\\HelpCommand', get_class($commands['help']), '->getCommands() returns the registered commands'); $application->addCommand(new \FooCommand()); $commands = $application->getCommands('foo'); - $this->assertEquals(count($commands), 1, '->getCommands() takes a namespace as its first argument'); + $this->assertEquals(1, count($commands), '->getCommands() takes a namespace as its first argument'); } public function testRegister() { $application = new Application(); $command = $application->register('foo'); - $this->assertEquals($command->getName(), 'foo', '->register() regiters a new command'); + $this->assertEquals('foo', $command->getName(), '->register() regiters a new command'); } public function testAddCommand() @@ -87,12 +87,12 @@ public function testAddCommand() $application = new Application(); $application->addCommand($foo = new \FooCommand()); $commands = $application->getCommands(); - $this->assertEquals($commands['foo:bar'], $foo, '->addCommand() registers a command'); + $this->assertEquals($foo, $commands['foo:bar'], '->addCommand() registers a command'); $application = new Application(); $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command())); $commands = $application->getCommands(); - $this->assertEquals(array($commands['foo:bar'], $commands['foo:bar1']), array($foo, $foo1), '->addCommands() registers an array of commands'); + $this->assertEquals(array($foo, $foo1), array($commands['foo:bar'], $commands['foo:bar1']), '->addCommands() registers an array of commands'); } public function testHasGetCommand() @@ -103,8 +103,8 @@ public function testHasGetCommand() $application->addCommand($foo = new \FooCommand()); $this->assertTrue($application->hasCommand('afoobar'), '->hasCommand() returns true if an alias is registered'); - $this->assertEquals($application->getCommand('foo:bar'), $foo, '->getCommand() returns a command by name'); - $this->assertEquals($application->getCommand('afoobar'), $foo, '->getCommand() returns a command by alias'); + $this->assertEquals($foo, $application->getCommand('foo:bar'), '->getCommand() returns a command by name'); + $this->assertEquals($foo, $application->getCommand('afoobar'), '->getCommand() returns a command by alias'); try { @@ -119,7 +119,7 @@ public function testHasGetCommand() $application->addCommand($foo = new \FooCommand()); $application->setWantHelps(); $command = $application->getCommand('foo:bar'); - $this->assertEquals(get_class($command), 'Symfony\Components\Console\Command\HelpCommand', '->getCommand() returns the help command if --help is provided as the input'); + $this->assertEquals('Symfony\Components\Console\Command\HelpCommand', get_class($command), '->getCommand() returns the help command if --help is provided as the input'); } public function testGetNamespaces() @@ -127,17 +127,17 @@ public function testGetNamespaces() $application = new TestApplication(); $application->addCommand(new \FooCommand()); $application->addCommand(new \Foo1Command()); - $this->assertEquals($application->getNamespaces(), array('foo'), '->getNamespaces() returns an array of unique used namespaces'); + $this->assertEquals(array('foo'), $application->getNamespaces(), '->getNamespaces() returns an array of unique used namespaces'); } public function testFindNamespace() { $application = new TestApplication(); $application->addCommand(new \FooCommand()); - $this->assertEquals($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); - $this->assertEquals($application->findNamespace('f'), 'foo', '->findNamespace() finds a namespace given an abbreviation'); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); + $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation'); $application->addCommand(new \Foo2Command()); - $this->assertEquals($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); try { $application->findNamespace('f'); @@ -161,11 +161,11 @@ public function testFindCommand() { $application = new TestApplication(); $application->addCommand(new \FooCommand()); - $this->assertEquals(get_class($application->findCommand('foo:bar')), 'FooCommand', '->findCommand() returns a command if its name exists'); - $this->assertEquals(get_class($application->findCommand('h')), 'Symfony\Components\Console\Command\HelpCommand', '->findCommand() returns a command if its name exists'); - $this->assertEquals(get_class($application->findCommand('f:bar')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace exists'); - $this->assertEquals(get_class($application->findCommand('f:b')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace and the command name exist'); - $this->assertEquals(get_class($application->findCommand('a')), 'FooCommand', '->findCommand() returns a command if the abbreviation exists for an alias'); + $this->assertEquals('FooCommand', get_class($application->findCommand('foo:bar')), '->findCommand() returns a command if its name exists'); + $this->assertEquals('Symfony\Components\Console\Command\HelpCommand', get_class($application->findCommand('h')), '->findCommand() returns a command if its name exists'); + $this->assertEquals('FooCommand', get_class($application->findCommand('f:bar')), '->findCommand() returns a command if the abbreviation for the namespace exists'); + $this->assertEquals('FooCommand', get_class($application->findCommand('f:b')), '->findCommand() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertEquals('FooCommand', get_class($application->findCommand('a')), '->findCommand() returns a command if the abbreviation exists for an alias'); $application->addCommand(new \Foo1Command()); $application->addCommand(new \Foo2Command()); @@ -206,7 +206,7 @@ public function testSetCatchExceptions() $application->setCatchExceptions(true); $tester->run(array('command' => 'foo')); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_renderexception1.txt'), '->setCatchExceptions() sets the catch exception flag'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_renderexception1.txt'), $tester->getDisplay(), '->setCatchExceptions() sets the catch exception flag'); $application->setCatchExceptions(false); try @@ -223,16 +223,16 @@ public function testAsText() { $application = new Application(); $application->addCommand(new \FooCommand); - $this->assertEquals($application->asText(), file_get_contents(self::$fixturesPath.'/application_astext1.txt'), '->asText() returns a text representation of the application'); - $this->assertEquals($application->asText('foo'), file_get_contents(self::$fixturesPath.'/application_astext2.txt'), '->asText() returns a text representation of the application'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_astext1.txt'), $application->asText(), '->asText() returns a text representation of the application'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_astext2.txt'), $application->asText('foo'), '->asText() returns a text representation of the application'); } public function testAsXml() { $application = new Application(); $application->addCommand(new \FooCommand); - $this->assertEquals($application->asXml(), file_get_contents(self::$fixturesPath.'/application_asxml1.txt'), '->asXml() returns an XML representation of the application'); - $this->assertEquals($application->asXml('foo'), file_get_contents(self::$fixturesPath.'/application_asxml2.txt'), '->asXml() returns an XML representation of the application'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_asxml1.txt'), $application->asXml(), '->asXml() returns an XML representation of the application'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_asxml2.txt'), $application->asXml('foo'), '->asXml() returns an XML representation of the application'); } public function testRenderException() @@ -242,13 +242,13 @@ public function testRenderException() $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo')); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_renderexception1.txt'), '->renderException() renders a pretty exception'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_renderexception1.txt'), $tester->getDisplay(), '->renderException() renders a pretty exception'); $tester->run(array('command' => 'foo'), array('verbosity' => Output::VERBOSITY_VERBOSE)); $this->assertRegExp('/Exception trace/', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); $tester->run(array('command' => 'list', '--foo' => true)); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_renderexception2.txt'), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_renderexception2.txt'), $tester->getDisplay(), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); } public function testRun() @@ -263,25 +263,25 @@ public function testRun() $application->run(); ob_end_clean(); - $this->assertEquals(get_class($command->input), 'Symfony\Components\Console\Input\ArgvInput', '->run() creates an ArgvInput by default if none is given'); - $this->assertEquals(get_class($command->output), 'Symfony\Components\Console\Output\ConsoleOutput', '->run() creates a ConsoleOutput by default if none is given'); + $this->assertEquals('Symfony\Components\Console\Input\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given'); + $this->assertEquals('Symfony\Components\Console\Output\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given'); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $tester = new ApplicationTester($application); $tester->run(array()); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run1.txt'), '->run() runs the list command if no argument is passed'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_run1.txt'), $tester->getDisplay(), '->run() runs the list command if no argument is passed'); $tester->run(array('--help' => true)); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run2.txt'), '->run() runs the help command if --help is passed'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_run2.txt'), $tester->getDisplay(), '->run() runs the help command if --help is passed'); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'list', '--help' => true)); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run3.txt'), '->run() displays the help if --help is passed'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_run3.txt'), $tester->getDisplay(), '->run() displays the help if --help is passed'); $application = new Application(); $application->setAutoExit(false); @@ -295,21 +295,21 @@ public function testRun() $application->setCatchExceptions(false); $tester = new ApplicationTester($application); $tester->run(array('--version' => true)); - $this->assertEquals($tester->getDisplay(), file_get_contents(self::$fixturesPath.'/application_run4.txt'), '->run() displays the program version if --version is passed'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/application_run4.txt'), $tester->getDisplay(), '->run() displays the program version if --version is passed'); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'list', '--quiet' => true)); - $this->assertEquals($tester->getDisplay(), '', '->run() removes all output if --quiet is passed'); + $this->assertEquals('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); $tester = new ApplicationTester($application); $tester->run(array('command' => 'list', '--verbose' => true)); - $this->assertEquals($tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->run() sets the output to verbose is --verbose is passed'); + $this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is --verbose is passed'); $application = new Application(); $application->setAutoExit(false); @@ -317,7 +317,7 @@ public function testRun() $application->addCommand(new \FooCommand()); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo:bar', '--no-interaction' => true)); - $this->assertEquals($tester->getDisplay(), "called\n", '->run() does not called interact() if --no-interaction is passed'); + $this->assertEquals("called\n", $tester->getDisplay(), '->run() does not called interact() if --no-interaction is passed'); } } diff --git a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php index dbb7e321417ab..d39278f5983bb 100644 --- a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php +++ b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php @@ -46,7 +46,7 @@ public function testConstructor() { } $command = new Command('foo:bar'); - $this->assertEquals($command->getFullName(), 'foo:bar', '__construct() takes the command name as its first argument'); + $this->assertEquals('foo:bar', $command->getFullName(), '__construct() takes the command name as its first argument'); } public function testSetApplication() @@ -54,15 +54,15 @@ public function testSetApplication() $application = new Application(); $command = new \TestCommand(); $command->setApplication($application); - $this->assertEquals($command->getApplication(), $application, '->setApplication() sets the current application'); + $this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application'); } public function testSetGetDefinition() { $command = new \TestCommand(); $ret = $command->setDefinition($definition = new InputDefinition()); - $this->assertEquals($ret, $command, '->setDefinition() implements a fluent interface'); - $this->assertEquals($command->getDefinition(), $definition, '->setDefinition() sets the current InputDefinition instance'); + $this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface'); + $this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance'); $command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); @@ -73,7 +73,7 @@ public function testAddArgument() { $command = new \TestCommand(); $ret = $command->addArgument('foo'); - $this->assertEquals($ret, $command, '->addArgument() implements a fluent interface'); + $this->assertEquals($command, $ret, '->addArgument() implements a fluent interface'); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command'); } @@ -81,27 +81,27 @@ public function testAddOption() { $command = new \TestCommand(); $ret = $command->addOption('foo'); - $this->assertEquals($ret, $command, '->addOption() implements a fluent interface'); + $this->assertEquals($command, $ret, '->addOption() implements a fluent interface'); $this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command'); } public function testgetNamespaceGetNameGetFullNameSetName() { $command = new \TestCommand(); - $this->assertEquals($command->getNamespace(), 'namespace', '->getNamespace() returns the command namespace'); - $this->assertEquals($command->getName(), 'name', '->getName() returns the command name'); - $this->assertEquals($command->getFullName(), 'namespace:name', '->getNamespace() returns the full command name'); + $this->assertEquals('namespace', $command->getNamespace(), '->getNamespace() returns the command namespace'); + $this->assertEquals('name', $command->getName(), '->getName() returns the command name'); + $this->assertEquals('namespace:name', $command->getFullName(), '->getNamespace() returns the full command name'); $command->setName('foo'); - $this->assertEquals($command->getName(), 'foo', '->setName() sets the command name'); + $this->assertEquals('foo', $command->getName(), '->setName() sets the command name'); $command->setName(':bar'); - $this->assertEquals($command->getName(), 'bar', '->setName() sets the command name'); - $this->assertEquals($command->getNamespace(), '', '->setName() can set the command namespace'); + $this->assertEquals('bar', $command->getName(), '->setName() sets the command name'); + $this->assertEquals('', $command->getNamespace(), '->setName() can set the command namespace'); $ret = $command->setName('foobar:bar'); - $this->assertEquals($ret, $command, '->setName() implements a fluent interface'); - $this->assertEquals($command->getName(), 'bar', '->setName() sets the command name'); - $this->assertEquals($command->getNamespace(), 'foobar', '->setName() can set the command namespace'); + $this->assertEquals($command, $ret, '->setName() implements a fluent interface'); + $this->assertEquals('bar', $command->getName(), '->setName() sets the command name'); + $this->assertEquals('foobar', $command->getNamespace(), '->setName() can set the command namespace'); try { @@ -125,28 +125,28 @@ public function testgetNamespaceGetNameGetFullNameSetName() public function testGetSetDescription() { $command = new \TestCommand(); - $this->assertEquals($command->getDescription(), 'description', '->getDescription() returns the description'); + $this->assertEquals('description', $command->getDescription(), '->getDescription() returns the description'); $ret = $command->setDescription('description1'); - $this->assertEquals($ret, $command, '->setDescription() implements a fluent interface'); - $this->assertEquals($command->getDescription(), 'description1', '->setDescription() sets the description'); + $this->assertEquals($command, $ret, '->setDescription() implements a fluent interface'); + $this->assertEquals('description1', $command->getDescription(), '->setDescription() sets the description'); } public function testGetSetHelp() { $command = new \TestCommand(); - $this->assertEquals($command->getHelp(), 'help', '->getHelp() returns the help'); + $this->assertEquals('help', $command->getHelp(), '->getHelp() returns the help'); $ret = $command->setHelp('help1'); - $this->assertEquals($ret, $command, '->setHelp() implements a fluent interface'); - $this->assertEquals($command->getHelp(), 'help1', '->setHelp() sets the help'); + $this->assertEquals($command, $ret, '->setHelp() implements a fluent interface'); + $this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help'); } public function testGetSetAliases() { $command = new \TestCommand(); - $this->assertEquals($command->getAliases(), array('name'), '->getAliases() returns the aliases'); + $this->assertEquals(array('name'), $command->getAliases(), '->getAliases() returns the aliases'); $ret = $command->setAliases(array('name1')); - $this->assertEquals($ret, $command, '->setAliases() implements a fluent interface'); - $this->assertEquals($command->getAliases(), array('name1'), '->setAliases() sets the aliases'); + $this->assertEquals($command, $ret, '->setAliases() implements a fluent interface'); + $this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases'); } public function testGetSynopsis() @@ -154,7 +154,7 @@ public function testGetSynopsis() $command = new \TestCommand(); $command->addOption('foo'); $command->addArgument('foo'); - $this->assertEquals($command->getSynopsis(), 'namespace:name [--foo] [foo]', '->getSynopsis() returns the synopsis'); + $this->assertEquals('namespace:name [--foo] [foo]', $command->getSynopsis(), '->getSynopsis() returns the synopsis'); } public function testMergeApplicationDefinition() @@ -172,7 +172,7 @@ public function testMergeApplicationDefinition() $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options'); $command->mergeApplicationDefinition(); - $this->assertEquals($command->getDefinition()->getArgumentCount(), 3, '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); + $this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); $command = new \TestCommand(); $command->mergeApplicationDefinition(); @@ -193,8 +193,8 @@ public function testRun() { } - $this->assertEquals($tester->execute(array(), array('interactive' => true)), "interact called\nexecute called\n", '->run() calls the interact() method if the input is interactive'); - $this->assertEquals($tester->execute(array(), array('interactive' => false)), "execute called\n", '->run() does not call the interact() method if the input is not interactive'); + $this->assertEquals("interact called\nexecute called\n", $tester->execute(array(), array('interactive' => true)), '->run() calls the interact() method if the input is interactive'); + $this->assertEquals("execute called\n", $tester->execute(array(), array('interactive' => false)), '->run() does not call the interact() method if the input is not interactive'); $command = new Command('foo'); try @@ -216,10 +216,10 @@ public function testSetCode() { $output->writeln('from the code...'); }); - $this->assertEquals($ret, $command, '->setCode() implements a fluent interface'); + $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute(array()); - $this->assertEquals($tester->getDisplay(), "interact called\nfrom the code...\n"); + $this->assertEquals("interact called\nfrom the code...\n", $tester->getDisplay()); } public function testAsText() @@ -228,7 +228,7 @@ public function testAsText() $command->setApplication(new Application()); $tester = new CommandTester($command); $tester->execute(array()); - $this->assertEquals($command->asText(), file_get_contents(self::$fixturesPath.'/command_astext.txt'), '->asText() returns a text representation of the command'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/command_astext.txt'), $command->asText(), '->asText() returns a text representation of the command'); } public function testAsXml() @@ -237,6 +237,6 @@ public function testAsXml() $command->setApplication(new Application()); $tester = new CommandTester($command); $tester->execute(array()); - $this->assertEquals($command->asXml(), file_get_contents(self::$fixturesPath.'/command_asxml.txt'), '->asXml() returns an XML representation of the command'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/command_asxml.txt'), $command->asXml(), '->asXml() returns an XML representation of the command'); } } diff --git a/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php b/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php index 7d237c13ed032..eecec2243a774 100644 --- a/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php +++ b/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php @@ -20,16 +20,16 @@ public function testFormatSection() { $formatter = new FormatterHelper(); - $this->assertEquals($formatter->formatSection('cli', 'Some text to display'), '[cli] Some text to display', '::formatSection() formats a message in a section'); + $this->assertEquals('[cli] Some text to display', $formatter->formatSection('cli', 'Some text to display'), '::formatSection() formats a message in a section'); } public function testFormatBlock() { $formatter = new FormatterHelper(); - $this->assertEquals($formatter->formatBlock('Some text to display', 'error'), ' Some text to display ', '::formatBlock() formats a message in a block'); - $this->assertEquals($formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), " Some text to display \n foo bar ", '::formatBlock() formats a message in a block'); + $this->assertEquals(' Some text to display ', $formatter->formatBlock('Some text to display', 'error'), '::formatBlock() formats a message in a block'); + $this->assertEquals(" Some text to display \n foo bar ", $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), '::formatBlock() formats a message in a block'); - $this->assertEquals($formatter->formatBlock('Some text to display', 'error', true), " \n Some text to display \n ", '::formatBlock() formats a message in a block'); + $this->assertEquals(" \n Some text to display \n ", $formatter->formatBlock('Some text to display', 'error', true), '::formatBlock() formats a message in a block'); } } diff --git a/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php b/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php index 40864fba334f3..66e5c6bf5e2d5 100644 --- a/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php @@ -23,29 +23,29 @@ public function testConstructor() { $_SERVER['argv'] = array('cli.php', 'foo'); $input = new TestInput(); - $this->assertEquals($input->getTokens(), array('foo'), '__construct() automatically get its input from the argv server variable'); + $this->assertEquals(array('foo'), $input->getTokens(), '__construct() automatically get its input from the argv server variable'); } public function testParser() { $input = new TestInput(array('cli.php', 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments'); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); $input->bind(new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals($input->getArguments(), array('name' => 'foo'), '->parse() is stateless'); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() is stateless'); $input = new TestInput(array('cli.php', '--foo')); $input->bind(new InputDefinition(array(new InputOption('foo')))); - $this->assertEquals($input->getOptions(), array('foo' => true), '->parse() parses long options without parameter'); + $this->assertEquals(array('foo' => true), $input->getOptions(), '->parse() parses long options without parameter'); $input = new TestInput(array('cli.php', '--foo=bar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a = separator)'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a required parameter (with a = separator)'); $input = new TestInput(array('cli.php', '--foo', 'bar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a space separator)'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a required parameter (with a space separator)'); try { @@ -59,19 +59,19 @@ public function testParser() $input = new TestInput(array('cli.php', '-f')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f')))); - $this->assertEquals($input->getOptions(), array('foo' => true), '->parse() parses short options without parameter'); + $this->assertEquals(array('foo' => true), $input->getOptions(), '->parse() parses short options without parameter'); $input = new TestInput(array('cli.php', '-fbar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with no separator)'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required parameter (with no separator)'); $input = new TestInput(array('cli.php', '-f', 'bar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED)))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with a space separator)'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required parameter (with a space separator)'); $input = new TestInput(array('cli.php', '-f', '-b', 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL), new InputOption('bar', 'b')))); - $this->assertEquals($input->getOptions(), array('foo' => null, 'bar' => true), '->parse() parses short options with an optional parameter which is not present'); + $this->assertEquals(array('foo' => null, 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional parameter which is not present'); try { @@ -125,32 +125,32 @@ public function testParser() $input = new TestInput(array('cli.php', '-fb')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b')))); - $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => true), '->parse() parses short options when they are aggregated as a single one'); + $this->assertEquals(array('foo' => true, 'bar' => true), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one'); $input = new TestInput(array('cli.php', '-fb', 'bar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_REQUIRED)))); - $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has a required parameter'); + $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has a required parameter'); $input = new TestInput(array('cli.php', '-fb', 'bar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); - $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter'); + $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter'); $input = new TestInput(array('cli.php', '-fbbar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); - $this->assertEquals($input->getOptions(), array('foo' => true, 'bar' => 'bar'), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter with no separator'); + $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has an optional parameter with no separator'); $input = new TestInput(array('cli.php', '-fbbar')); $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL)))); - $this->assertEquals($input->getOptions(), array('foo' => 'bbar', 'bar' => null), '->parse() parses short options when they are aggregated as a single one and one of them takes a parameter'); + $this->assertEquals(array('foo' => 'bbar', 'bar' => null), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and one of them takes a parameter'); } public function testGetFirstArgument() { $input = new TestInput(array('cli.php', '-fbbar')); - $this->assertEquals($input->getFirstArgument(), '', '->getFirstArgument() returns the first argument from the raw input'); + $this->assertEquals('', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input'); $input = new TestInput(array('cli.php', '-fbbar', 'foo')); - $this->assertEquals($input->getFirstArgument(), 'foo', '->getFirstArgument() returns the first argument from the raw input'); + $this->assertEquals('foo', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input'); } public function testHasParameterOption() diff --git a/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php b/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php index f75f66219d559..4168c0fa426ce 100644 --- a/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php @@ -22,11 +22,11 @@ class ArrayInputTest extends \PHPUnit_Framework_TestCase public function testGetFirstArgument() { $input = new ArrayInput(array()); - $this->assertEquals($input->getFirstArgument(), null, '->getFirstArgument() returns null if no argument were passed'); + $this->assertEquals(null, $input->getFirstArgument(), '->getFirstArgument() returns null if no argument were passed'); $input = new ArrayInput(array('name' => 'Fabien')); - $this->assertEquals($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument'); + $this->assertEquals('Fabien', $input->getFirstArgument(), '->getFirstArgument() returns the first passed argument'); $input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien')); - $this->assertEquals($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument'); + $this->assertEquals('Fabien', $input->getFirstArgument(), '->getFirstArgument() returns the first passed argument'); } public function testHasParameterOption() @@ -42,7 +42,7 @@ public function testHasParameterOption() public function testParse() { $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments'); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); try { @@ -54,13 +54,13 @@ public function testParse() } $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo')))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options'); $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL, '', 'default')))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a default value'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a default value'); $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL, '', 'default')))); - $this->assertEquals($input->getOptions(), array('foo' => 'default'), '->parse() parses long options with a default value'); + $this->assertEquals(array('foo' => 'default'), $input->getOptions(), '->parse() parses long options with a default value'); try { @@ -81,7 +81,7 @@ public function testParse() } $input = new ArrayInput(array('-f' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f')))); - $this->assertEquals($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options'); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options'); try { diff --git a/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php b/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php index 5e0964551d95c..77ef5cf42b0b6 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php @@ -20,20 +20,20 @@ class InputArgumentTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $argument = new InputArgument('foo'); - $this->assertEquals($argument->getName(), 'foo', '__construct() takes a name as its first argument'); + $this->assertEquals('foo', $argument->getName(), '__construct() takes a name as its first argument'); // mode argument $argument = new InputArgument('foo'); - $this->assertEquals($argument->isRequired(), false, '__construct() gives a "Argument::OPTIONAL" mode by default'); + $this->assertEquals(false, $argument->isRequired(), '__construct() gives a "Argument::OPTIONAL" mode by default'); $argument = new InputArgument('foo', null); - $this->assertEquals($argument->isRequired(), false, '__construct() can take "Argument::OPTIONAL" as its mode'); + $this->assertEquals(false, $argument->isRequired(), '__construct() can take "Argument::OPTIONAL" as its mode'); $argument = new InputArgument('foo', InputArgument::OPTIONAL); - $this->assertEquals($argument->isRequired(), false, '__construct() can take "Argument::PARAMETER_OPTIONAL" as its mode'); + $this->assertEquals(false, $argument->isRequired(), '__construct() can take "Argument::PARAMETER_OPTIONAL" as its mode'); $argument = new InputArgument('foo', InputArgument::REQUIRED); - $this->assertEquals($argument->isRequired(), true, '__construct() can take "Argument::PARAMETER_REQUIRED" as its mode'); + $this->assertEquals(true, $argument->isRequired(), '__construct() can take "Argument::PARAMETER_REQUIRED" as its mode'); try { @@ -58,13 +58,13 @@ public function testIsArray() public function testGetDescription() { $argument = new InputArgument('foo', null, 'Some description'); - $this->assertEquals($argument->getDescription(), 'Some description', '->getDescription() return the message description'); + $this->assertEquals('Some description', $argument->getDescription(), '->getDescription() return the message description'); } public function testGetDefault() { $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); - $this->assertEquals($argument->getDefault(), 'default', '->getDefault() return the default value'); + $this->assertEquals('default', $argument->getDefault(), '->getDefault() return the default value'); } public function testSetDefault() @@ -73,11 +73,11 @@ public function testSetDefault() $argument->setDefault(null); $this->assertTrue(is_null($argument->getDefault()), '->setDefault() can reset the default value by passing null'); $argument->setDefault('another'); - $this->assertEquals($argument->getDefault(), 'another', '->setDefault() changes the default value'); + $this->assertEquals('another', $argument->getDefault(), '->setDefault() changes the default value'); $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); $argument->setDefault(array(1, 2)); - $this->assertEquals($argument->getDefault(), array(1, 2), '->setDefault() changes the default value'); + $this->assertEquals(array(1, 2), $argument->getDefault(), '->setDefault() changes the default value'); try { diff --git a/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php b/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php index 6f19f2b05b8bb..655d5eb1bba2f 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php @@ -33,18 +33,18 @@ public function testConstructor() $this->initializeArguments(); $definition = new InputDefinition(); - $this->assertEquals($definition->getArguments(), array(), '__construct() creates a new InputDefinition object'); + $this->assertEquals(array(), $definition->getArguments(), '__construct() creates a new InputDefinition object'); $definition = new InputDefinition(array($this->foo, $this->bar)); - $this->assertEquals($definition->getArguments(), array('foo' => $this->foo, 'bar' => $this->bar), '__construct() takes an array of InputArgument objects as its first argument'); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '__construct() takes an array of InputArgument objects as its first argument'); $this->initializeOptions(); $definition = new InputDefinition(); - $this->assertEquals($definition->getOptions(), array(), '__construct() creates a new InputDefinition object'); + $this->assertEquals(array(), $definition->getOptions(), '__construct() creates a new InputDefinition object'); $definition = new InputDefinition(array($this->foo, $this->bar)); - $this->assertEquals($definition->getOptions(), array('foo' => $this->foo, 'bar' => $this->bar), '__construct() takes an array of InputOption objects as its first argument'); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '__construct() takes an array of InputOption objects as its first argument'); } public function testSetArguments() @@ -53,10 +53,10 @@ public function testSetArguments() $definition = new InputDefinition(); $definition->setArguments(array($this->foo)); - $this->assertEquals($definition->getArguments(), array('foo' => $this->foo), '->setArguments() sets the array of InputArgument objects'); + $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->setArguments() sets the array of InputArgument objects'); $definition->setArguments(array($this->bar)); - $this->assertEquals($definition->getArguments(), array('bar' => $this->bar), '->setArguments() clears all InputArgument objects'); + $this->assertEquals(array('bar' => $this->bar), $definition->getArguments(), '->setArguments() clears all InputArgument objects'); } public function testAddArguments() @@ -65,9 +65,9 @@ public function testAddArguments() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); - $this->assertEquals($definition->getArguments(), array('foo' => $this->foo), '->addArguments() adds an array of InputArgument objects'); + $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArguments() adds an array of InputArgument objects'); $definition->addArguments(array($this->bar)); - $this->assertEquals($definition->getArguments(), array('foo' => $this->foo, 'bar' => $this->bar), '->addArguments() does not clear existing InputArgument objects'); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArguments() does not clear existing InputArgument objects'); } public function testAddArgument() @@ -76,9 +76,9 @@ public function testAddArgument() $definition = new InputDefinition(); $definition->addArgument($this->foo); - $this->assertEquals($definition->getArguments(), array('foo' => $this->foo), '->addArgument() adds a InputArgument object'); + $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArgument() adds a InputArgument object'); $definition->addArgument($this->bar); - $this->assertEquals($definition->getArguments(), array('foo' => $this->foo, 'bar' => $this->bar), '->addArgument() adds a InputArgument object'); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArgument() adds a InputArgument object'); // arguments must have different names try @@ -120,7 +120,7 @@ public function testGetArgument() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); - $this->assertEquals($definition->getArgument('foo'), $this->foo, '->getArgument() returns a InputArgument by its name'); + $this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name'); try { $definition->getArgument('bar'); @@ -137,8 +137,8 @@ public function testHasArgument() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); - $this->assertEquals($definition->hasArgument('foo'), true, '->hasArgument() returns true if a InputArgument exists for the given name'); - $this->assertEquals($definition->hasArgument('bar'), false, '->hasArgument() returns false if a InputArgument exists for the given name'); + $this->assertEquals(true, $definition->hasArgument('foo'), '->hasArgument() returns true if a InputArgument exists for the given name'); + $this->assertEquals(false, $definition->hasArgument('bar'), '->hasArgument() returns false if a InputArgument exists for the given name'); } public function testGetArgumentRequiredCount() @@ -147,9 +147,9 @@ public function testGetArgumentRequiredCount() $definition = new InputDefinition(); $definition->addArgument($this->foo2); - $this->assertEquals($definition->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); + $this->assertEquals(1, $definition->getArgumentRequiredCount(), '->getArgumentRequiredCount() returns the number of required arguments'); $definition->addArgument($this->foo); - $this->assertEquals($definition->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); + $this->assertEquals(1, $definition->getArgumentRequiredCount(), '->getArgumentRequiredCount() returns the number of required arguments'); } public function testGetArgumentCount() @@ -158,9 +158,9 @@ public function testGetArgumentCount() $definition = new InputDefinition(); $definition->addArgument($this->foo2); - $this->assertEquals($definition->getArgumentCount(), 1, '->getArgumentCount() returns the number of arguments'); + $this->assertEquals(1, $definition->getArgumentCount(), '->getArgumentCount() returns the number of arguments'); $definition->addArgument($this->foo); - $this->assertEquals($definition->getArgumentCount(), 2, '->getArgumentCount() returns the number of arguments'); + $this->assertEquals(2, $definition->getArgumentCount(), '->getArgumentCount() returns the number of arguments'); } public function testGetArgumentDefaults() @@ -171,12 +171,12 @@ public function testGetArgumentDefaults() new InputArgument('foo3', InputArgument::OPTIONAL | InputArgument::IS_ARRAY), // new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), )); - $this->assertEquals($definition->getArgumentDefaults(), array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), '->getArgumentDefaults() return the default values for each argument'); + $this->assertEquals(array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), $definition->getArgumentDefaults(), '->getArgumentDefaults() return the default values for each argument'); $definition = new InputDefinition(array( new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), )); - $this->assertEquals($definition->getArgumentDefaults(), array('foo4' => array(1, 2)), '->getArgumentDefaults() return the default values for each argument'); + $this->assertEquals(array('foo4' => array(1, 2)), $definition->getArgumentDefaults(), '->getArgumentDefaults() return the default values for each argument'); } public function testSetOptions() @@ -184,9 +184,9 @@ public function testSetOptions() $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); - $this->assertEquals($definition->getOptions(), array('foo' => $this->foo), '->setOptions() sets the array of InputOption objects'); + $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->setOptions() sets the array of InputOption objects'); $definition->setOptions(array($this->bar)); - $this->assertEquals($definition->getOptions(), array('bar' => $this->bar), '->setOptions() clears all InputOption objects'); + $this->assertEquals(array('bar' => $this->bar), $definition->getOptions(), '->setOptions() clears all InputOption objects'); try { $definition->getOptionForShortcut('f'); @@ -202,9 +202,9 @@ public function testAddOptions() $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); - $this->assertEquals($definition->getOptions(), array('foo' => $this->foo), '->addOptions() adds an array of InputOption objects'); + $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOptions() adds an array of InputOption objects'); $definition->addOptions(array($this->bar)); - $this->assertEquals($definition->getOptions(), array('foo' => $this->foo, 'bar' => $this->bar), '->addOptions() does not clear existing InputOption objects'); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOptions() does not clear existing InputOption objects'); } public function testAddOption() @@ -213,9 +213,9 @@ public function testAddOption() $definition = new InputDefinition(); $definition->addOption($this->foo); - $this->assertEquals($definition->getOptions(), array('foo' => $this->foo), '->addOption() adds a InputOption object'); + $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object'); $definition->addOption($this->bar); - $this->assertEquals($definition->getOptions(), array('foo' => $this->foo, 'bar' => $this->bar), '->addOption() adds a InputOption object'); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object'); try { $definition->addOption($this->foo2); @@ -239,7 +239,7 @@ public function testGetOption() $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); - $this->assertEquals($definition->getOption('foo'), $this->foo, '->getOption() returns a InputOption by its name'); + $this->assertEquals($this->foo, $definition->getOption('foo'), '->getOption() returns a InputOption by its name'); try { $definition->getOption('bar'); @@ -255,8 +255,8 @@ public function testHasOption() $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); - $this->assertEquals($definition->hasOption('foo'), true, '->hasOption() returns true if a InputOption exists for the given name'); - $this->assertEquals($definition->hasOption('bar'), false, '->hasOption() returns false if a InputOption exists for the given name'); + $this->assertEquals(true, $definition->hasOption('foo'), '->hasOption() returns true if a InputOption exists for the given name'); + $this->assertEquals(false, $definition->hasOption('bar'), '->hasOption() returns false if a InputOption exists for the given name'); } public function testHasShortcut() @@ -264,8 +264,8 @@ public function testHasShortcut() $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); - $this->assertEquals($definition->hasShortcut('f'), true, '->hasShortcut() returns true if a InputOption exists for the given shortcut'); - $this->assertEquals($definition->hasShortcut('b'), false, '->hasShortcut() returns false if a InputOption exists for the given shortcut'); + $this->assertEquals(true, $definition->hasShortcut('f'), '->hasShortcut() returns true if a InputOption exists for the given shortcut'); + $this->assertEquals(false, $definition->hasShortcut('b'), '->hasShortcut() returns false if a InputOption exists for the given shortcut'); } public function testGetOptionForShortcut() @@ -273,7 +273,7 @@ public function testGetOptionForShortcut() $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); - $this->assertEquals($definition->getOptionForShortcut('f'), $this->foo, '->getOptionForShortcut() returns a InputOption by its shortcut'); + $this->assertEquals($this->foo, $definition->getOptionForShortcut('f'), '->getOptionForShortcut() returns a InputOption by its shortcut'); try { $definition->getOptionForShortcut('l'); @@ -304,28 +304,28 @@ public function testGetOptionDefaults() 'foo6' => array(), 'foo7' => array(1, 2), ); - $this->assertEquals($definition->getOptionDefaults(), $defaults, '->getOptionDefaults() returns the default values for all options'); + $this->assertEquals($defaults, $definition->getOptionDefaults(), '->getOptionDefaults() returns the default values for all options'); } public function testGetSynopsis() { $definition = new InputDefinition(array(new InputOption('foo'))); - $this->assertEquals($definition->getSynopsis(), '[--foo]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('[--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputOption('foo', 'f'))); - $this->assertEquals($definition->getSynopsis(), '[-f|--foo]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('[-f|--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED))); - $this->assertEquals($definition->getSynopsis(), '[-f|--foo="..."]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('[-f|--foo="..."]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL))); - $this->assertEquals($definition->getSynopsis(), '[-f|--foo[="..."]]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('[-f|--foo[="..."]]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputArgument('foo'))); - $this->assertEquals($definition->getSynopsis(), '[foo]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('[foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))); - $this->assertEquals($definition->getSynopsis(), 'foo', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('foo', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))); - $this->assertEquals($definition->getSynopsis(), '[foo1] ... [fooN]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('[foo1] ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))); - $this->assertEquals($definition->getSynopsis(), 'foo1 ... [fooN]', '->getSynopsis() returns a synopsis of arguments and options'); + $this->assertEquals('foo1 ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); } public function testAsText() @@ -336,7 +336,7 @@ public function testAsText() new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED, 'The foo option'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL, 'The foo option', 'bar'), )); - $this->assertEquals($definition->asText(), file_get_contents(self::$fixtures.'/definition_astext.txt'), '->asText() returns a textual representation of the InputDefinition'); + $this->assertEquals(file_get_contents(self::$fixtures.'/definition_astext.txt'), $definition->asText(), '->asText() returns a textual representation of the InputDefinition'); } public function testAsXml() @@ -347,7 +347,7 @@ public function testAsXml() new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED, 'The foo option'), new InputOption('bar', 'b', InputOption::PARAMETER_OPTIONAL, 'The foo option', 'bar'), )); - $this->assertEquals($definition->asXml(), file_get_contents(self::$fixtures.'/definition_asxml.txt'), '->asText() returns a textual representation of the InputDefinition'); + $this->assertEquals(file_get_contents(self::$fixtures.'/definition_asxml.txt'), $definition->asXml(), '->asText() returns a textual representation of the InputDefinition'); } protected function initializeArguments() diff --git a/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php b/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php index ac650854cca51..d05c5c618d101 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php @@ -20,9 +20,9 @@ class InputOptionTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $option = new InputOption('foo'); - $this->assertEquals($option->getName(), 'foo', '__construct() takes a name as its first argument'); + $this->assertEquals('foo', $option->getName(), '__construct() takes a name as its first argument'); $option = new InputOption('--foo'); - $this->assertEquals($option->getName(), 'foo', '__construct() removes the leading -- of the option name'); + $this->assertEquals('foo', $option->getName(), '__construct() removes the leading -- of the option name'); try { @@ -35,35 +35,35 @@ public function testConstructor() // shortcut argument $option = new InputOption('foo', 'f'); - $this->assertEquals($option->getShortcut(), 'f', '__construct() can take a shortcut as its second argument'); + $this->assertEquals('f', $option->getShortcut(), '__construct() can take a shortcut as its second argument'); $option = new InputOption('foo', '-f'); - $this->assertEquals($option->getShortcut(), 'f', '__construct() removes the leading - of the shortcut'); + $this->assertEquals('f', $option->getShortcut(), '__construct() removes the leading - of the shortcut'); // mode argument $option = new InputOption('foo', 'f'); - $this->assertEquals($option->acceptParameter(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); - $this->assertEquals($option->isParameterRequired(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); - $this->assertEquals($option->isParameterOptional(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default'); + $this->assertEquals(false, $option->acceptParameter(), '__construct() gives a "Option::PARAMETER_NONE" mode by default'); + $this->assertEquals(false, $option->isParameterRequired(), '__construct() gives a "Option::PARAMETER_NONE" mode by default'); + $this->assertEquals(false, $option->isParameterOptional(), '__construct() gives a "Option::PARAMETER_NONE" mode by default'); $option = new InputOption('foo', 'f', null); - $this->assertEquals($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); - $this->assertEquals($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); - $this->assertEquals($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals(false, $option->acceptParameter(), '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals(false, $option->isParameterRequired(), '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals(false, $option->isParameterOptional(), '__construct() can take "Option::PARAMETER_NONE" as its mode'); $option = new InputOption('foo', 'f', InputOption::PARAMETER_NONE); - $this->assertEquals($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); - $this->assertEquals($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); - $this->assertEquals($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals(false, $option->acceptParameter(), '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals(false, $option->isParameterRequired(), '__construct() can take "Option::PARAMETER_NONE" as its mode'); + $this->assertEquals(false, $option->isParameterOptional(), '__construct() can take "Option::PARAMETER_NONE" as its mode'); $option = new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED); - $this->assertEquals($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); - $this->assertEquals($option->isParameterRequired(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); - $this->assertEquals($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); + $this->assertEquals(true, $option->acceptParameter(), '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); + $this->assertEquals(true, $option->isParameterRequired(), '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); + $this->assertEquals(false, $option->isParameterOptional(), '__construct() can take "Option::PARAMETER_REQUIRED" as its mode'); $option = new InputOption('foo', 'f', InputOption::PARAMETER_OPTIONAL); - $this->assertEquals($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); - $this->assertEquals($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); - $this->assertEquals($option->isParameterOptional(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); + $this->assertEquals(true, $option->acceptParameter(), '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); + $this->assertEquals(false, $option->isParameterRequired(), '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); + $this->assertEquals(true, $option->isParameterOptional(), '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode'); try { @@ -86,22 +86,22 @@ public function testIsArray() public function testGetDescription() { $option = new InputOption('foo', 'f', null, 'Some description'); - $this->assertEquals($option->getDescription(), 'Some description', '->getDescription() returns the description message'); + $this->assertEquals('Some description', $option->getDescription(), '->getDescription() returns the description message'); } public function testGetDefault() { $option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL, '', 'default'); - $this->assertEquals($option->getDefault(), 'default', '->getDefault() returns the default value'); + $this->assertEquals('default', $option->getDefault(), '->getDefault() returns the default value'); $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED, '', 'default'); - $this->assertEquals($option->getDefault(), 'default', '->getDefault() returns the default value'); + $this->assertEquals('default', $option->getDefault(), '->getDefault() returns the default value'); $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED); $this->assertTrue(is_null($option->getDefault()), '->getDefault() returns null if no default value is configured'); $option = new InputOption('foo', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY); - $this->assertEquals($option->getDefault(), array(), '->getDefault() returns an empty array if option is an array'); + $this->assertEquals(array(), $option->getDefault(), '->getDefault() returns an empty array if option is an array'); $option = new InputOption('foo', null, InputOption::PARAMETER_NONE); $this->assertTrue($option->getDefault() === false, '->getDefault() returns false if the option does not take a parameter'); @@ -113,11 +113,11 @@ public function testSetDefault() $option->setDefault(null); $this->assertTrue(is_null($option->getDefault()), '->setDefault() can reset the default value by passing null'); $option->setDefault('another'); - $this->assertEquals($option->getDefault(), 'another', '->setDefault() changes the default value'); + $this->assertEquals('another', $option->getDefault(), '->setDefault() changes the default value'); $option = new InputOption('foo', null, InputOption::PARAMETER_REQUIRED | InputOption::PARAMETER_IS_ARRAY); $option->setDefault(array(1, 2)); - $this->assertEquals($option->getDefault(), array(1, 2), '->setDefault() changes the default value'); + $this->assertEquals(array(1, 2), $option->getDefault(), '->setDefault() changes the default value'); $option = new InputOption('foo', 'f', InputOption::PARAMETER_NONE); try diff --git a/tests/Symfony/Tests/Components/Console/Input/InputTest.php b/tests/Symfony/Tests/Components/Console/Input/InputTest.php index 467ce0427c458..8d482487482a1 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputTest.php @@ -22,21 +22,21 @@ class InputTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals($input->getArgument('name'), 'foo', '->__construct() takes a InputDefinition as an argument'); + $this->assertEquals('foo', $input->getArgument('name'), '->__construct() takes a InputDefinition as an argument'); } public function testOptions() { $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name')))); - $this->assertEquals($input->getOption('name'), 'foo', '->getOption() returns the value for the given option'); + $this->assertEquals('foo', $input->getOption('name'), '->getOption() returns the value for the given option'); $input->setOption('name', 'bar'); - $this->assertEquals($input->getOption('name'), 'bar', '->setOption() sets the value for a given option'); - $this->assertEquals($input->getOptions(), array('name' => 'bar'), '->getOptions() returns all option values'); + $this->assertEquals('bar', $input->getOption('name'), '->setOption() sets the value for a given option'); + $this->assertEquals(array('name' => 'bar'), $input->getOptions(), '->getOptions() returns all option values'); $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::PARAMETER_OPTIONAL, '', 'default')))); - $this->assertEquals($input->getOption('bar'), 'default', '->getOption() returns the default value for optional options'); - $this->assertEquals($input->getOptions(), array('name' => 'foo', 'bar' => 'default'), '->getOptions() returns all option values, even optional ones'); + $this->assertEquals('default', $input->getOption('bar'), '->getOption() returns the default value for optional options'); + $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getOptions(), '->getOptions() returns all option values, even optional ones'); try { @@ -60,15 +60,15 @@ public function testOptions() public function testArguments() { $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals($input->getArgument('name'), 'foo', '->getArgument() returns the value for the given argument'); + $this->assertEquals('foo', $input->getArgument('name'), '->getArgument() returns the value for the given argument'); $input->setArgument('name', 'bar'); - $this->assertEquals($input->getArgument('name'), 'bar', '->setArgument() sets the value for a given argument'); - $this->assertEquals($input->getArguments(), array('name' => 'bar'), '->getArguments() returns all argument values'); + $this->assertEquals('bar', $input->getArgument('name'), '->setArgument() sets the value for a given argument'); + $this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->getArguments() returns all argument values'); $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); - $this->assertEquals($input->getArgument('bar'), 'default', '->getArgument() returns the default value for optional arguments'); - $this->assertEquals($input->getArguments(), array('name' => 'foo', 'bar' => 'default'), '->getArguments() returns all argument values, even optional ones'); + $this->assertEquals('default', $input->getArgument('bar'), '->getArgument() returns the default value for optional arguments'); + $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getArguments(), '->getArguments() returns all argument values, even optional ones'); try { diff --git a/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php b/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php index e2dbc73b02b34..6f3381489aa20 100644 --- a/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php @@ -19,73 +19,73 @@ class StringInputTest extends \PHPUnit_Framework_TestCase public function testTokenize() { $input = new TestInput1(''); - $this->assertEquals($input->getTokens(), array(), '->tokenize() parses an empty string'); + $this->assertEquals(array(), $input->getTokens(), '->tokenize() parses an empty string'); $input = new TestInput1('foo'); - $this->assertEquals($input->getTokens(), array('foo'), '->tokenize() parses arguments'); + $this->assertEquals(array('foo'), $input->getTokens(), '->tokenize() parses arguments'); $input = new TestInput1(' foo bar '); - $this->assertEquals($input->getTokens(), array('foo', 'bar'), '->tokenize() ignores whitespaces between arguments'); + $this->assertEquals(array('foo', 'bar'), $input->getTokens(), '->tokenize() ignores whitespaces between arguments'); $input = new TestInput1('"quoted"'); - $this->assertEquals($input->getTokens(), array('quoted'), '->tokenize() parses quoted arguments'); + $this->assertEquals(array('quoted'), $input->getTokens(), '->tokenize() parses quoted arguments'); $input = new TestInput1("'quoted'"); - $this->assertEquals($input->getTokens(), array('quoted'), '->tokenize() parses quoted arguments'); + $this->assertEquals(array('quoted'), $input->getTokens(), '->tokenize() parses quoted arguments'); $input = new TestInput1('\"quoted\"'); - $this->assertEquals($input->getTokens(), array('"quoted"'), '->tokenize() parses escaped-quoted arguments'); + $this->assertEquals(array('"quoted"'), $input->getTokens(), '->tokenize() parses escaped-quoted arguments'); $input = new TestInput1("\'quoted\'"); - $this->assertEquals($input->getTokens(), array('\'quoted\''), '->tokenize() parses escaped-quoted arguments'); + $this->assertEquals(array('\'quoted\''), $input->getTokens(), '->tokenize() parses escaped-quoted arguments'); $input = new TestInput1('-a'); - $this->assertEquals($input->getTokens(), array('-a'), '->tokenize() parses short options'); + $this->assertEquals(array('-a'), $input->getTokens(), '->tokenize() parses short options'); $input = new TestInput1('-azc'); - $this->assertEquals($input->getTokens(), array('-azc'), '->tokenize() parses aggregated short options'); + $this->assertEquals(array('-azc'), $input->getTokens(), '->tokenize() parses aggregated short options'); $input = new TestInput1('-awithavalue'); - $this->assertEquals($input->getTokens(), array('-awithavalue'), '->tokenize() parses short options with a value'); + $this->assertEquals(array('-awithavalue'), $input->getTokens(), '->tokenize() parses short options with a value'); $input = new TestInput1('-a"foo bar"'); - $this->assertEquals($input->getTokens(), array('-afoo bar'), '->tokenize() parses short options with a value'); + $this->assertEquals(array('-afoo bar'), $input->getTokens(), '->tokenize() parses short options with a value'); $input = new TestInput1('-a"foo bar""foo bar"'); - $this->assertEquals($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); + $this->assertEquals(array('-afoo barfoo bar'), $input->getTokens(), '->tokenize() parses short options with a value'); $input = new TestInput1('-a\'foo bar\''); - $this->assertEquals($input->getTokens(), array('-afoo bar'), '->tokenize() parses short options with a value'); + $this->assertEquals(array('-afoo bar'), $input->getTokens(), '->tokenize() parses short options with a value'); $input = new TestInput1('-a\'foo bar\'\'foo bar\''); - $this->assertEquals($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); + $this->assertEquals(array('-afoo barfoo bar'), $input->getTokens(), '->tokenize() parses short options with a value'); $input = new TestInput1('-a\'foo bar\'"foo bar"'); - $this->assertEquals($input->getTokens(), array('-afoo barfoo bar'), '->tokenize() parses short options with a value'); + $this->assertEquals(array('-afoo barfoo bar'), $input->getTokens(), '->tokenize() parses short options with a value'); $input = new TestInput1('--long-option'); - $this->assertEquals($input->getTokens(), array('--long-option'), '->tokenize() parses long options'); + $this->assertEquals(array('--long-option'), $input->getTokens(), '->tokenize() parses long options'); $input = new TestInput1('--long-option=foo'); - $this->assertEquals($input->getTokens(), array('--long-option=foo'), '->tokenize() parses long options with a value'); + $this->assertEquals(array('--long-option=foo'), $input->getTokens(), '->tokenize() parses long options with a value'); $input = new TestInput1('--long-option="foo bar"'); - $this->assertEquals($input->getTokens(), array('--long-option=foo bar'), '->tokenize() parses long options with a value'); + $this->assertEquals(array('--long-option=foo bar'), $input->getTokens(), '->tokenize() parses long options with a value'); $input = new TestInput1('--long-option="foo bar""another"'); - $this->assertEquals($input->getTokens(), array('--long-option=foo baranother'), '->tokenize() parses long options with a value'); + $this->assertEquals(array('--long-option=foo baranother'), $input->getTokens(), '->tokenize() parses long options with a value'); $input = new TestInput1('--long-option=\'foo bar\''); - $this->assertEquals($input->getTokens(), array('--long-option=foo bar'), '->tokenize() parses long options with a value'); + $this->assertEquals(array('--long-option=foo bar'), $input->getTokens(), '->tokenize() parses long options with a value'); $input = new TestInput1("--long-option='foo bar''another'"); - $this->assertEquals($input->getTokens(), array("--long-option=foo baranother"), '->tokenize() parses long options with a value'); + $this->assertEquals(array("--long-option=foo baranother"), $input->getTokens(), '->tokenize() parses long options with a value'); $input = new TestInput1("--long-option='foo bar'\"another\""); - $this->assertEquals($input->getTokens(), array("--long-option=foo baranother"), '->tokenize() parses long options with a value'); + $this->assertEquals(array("--long-option=foo baranother"), $input->getTokens(), '->tokenize() parses long options with a value'); $input = new TestInput1('foo -a -ffoo --long bar'); - $this->assertEquals($input->getTokens(), array('foo', '-a', '-ffoo', '--long', 'bar'), '->tokenize() parses when several arguments and options'); + $this->assertEquals(array('foo', '-a', '-ffoo', '--long', 'bar'), $input->getTokens(), '->tokenize() parses when several arguments and options'); } } diff --git a/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php index 1d34aaa0c10e4..b8f0e884d52e5 100644 --- a/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php @@ -20,6 +20,6 @@ class ConsoleOutputTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); - $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); } } diff --git a/tests/Symfony/Tests/Components/Console/Output/OutputTest.php b/tests/Symfony/Tests/Components/Console/Output/OutputTest.php index 16749a2479dcf..da84bcff54c79 100644 --- a/tests/Symfony/Tests/Components/Console/Output/OutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/OutputTest.php @@ -19,57 +19,57 @@ class OutputTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $output = new TestOutput(Output::VERBOSITY_QUIET, true); - $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); - $this->assertEquals($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument'); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + $this->assertEquals(true, $output->isDecorated(), '__construct() takes the decorated flag as its second argument'); } public function testSetIsDecorated() { $output = new TestOutput(); $output->setDecorated(true); - $this->assertEquals($output->isDecorated(), true, 'setDecorated() sets the decorated flag'); + $this->assertEquals(true, 'setDecorated() sets the decorated flag', $output->isDecorated()); } public function testSetGetVerbosity() { $output = new TestOutput(); $output->setVerbosity(Output::VERBOSITY_QUIET); - $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '->setVerbosity() sets the verbosity'); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '->setVerbosity() sets the verbosity'); } public function testSetStyle() { Output::setStyle('FOO', array('bg' => 'red', 'fg' => 'yellow', 'blink' => true)); - $this->assertEquals(TestOutput::getStyle('foo'), array('bg' => 'red', 'fg' => 'yellow', 'blink' => true), '::setStyle() sets a new style'); + $this->assertEquals(array('bg' => 'red', 'fg' => 'yellow', 'blink' => true), TestOutput::getStyle('foo'), '::setStyle() sets a new style'); } public function testWrite() { $output = new TestOutput(Output::VERBOSITY_QUIET); $output->writeln('foo'); - $this->assertEquals($output->output, '', '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); + $this->assertEquals('', $output->output, '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); $output = new TestOutput(); $output->writeln(array('foo', 'bar')); - $this->assertEquals($output->output, "foo\nbar\n", '->writeln() can take an array of messages to output'); + $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output'); $output = new TestOutput(); $output->writeln('foo', Output::OUTPUT_RAW); - $this->assertEquals($output->output, "foo\n", '->writeln() outputs the raw message if OUTPUT_RAW is specified'); + $this->assertEquals("foo\n", $output->output, '->writeln() outputs the raw message if OUTPUT_RAW is specified'); $output = new TestOutput(); $output->writeln('foo', Output::OUTPUT_PLAIN); - $this->assertEquals($output->output, "foo\n", '->writeln() strips decoration tags if OUTPUT_PLAIN is specified'); + $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if OUTPUT_PLAIN is specified'); $output = new TestOutput(); $output->setDecorated(false); $output->writeln('foo'); - $this->assertEquals($output->output, "foo\n", '->writeln() strips decoration tags if decoration is set to false'); + $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if decoration is set to false'); $output = new TestOutput(); $output->setDecorated(true); $output->writeln('foo'); - $this->assertEquals($output->output, "\033[33;41;5mfoo\033[0m\n", '->writeln() decorates the output'); + $this->assertEquals("\033[33;41;5mfoo\033[0m\n", $output->output, '->writeln() decorates the output'); try { diff --git a/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php index 20a81b1731068..ffb29308a3313 100644 --- a/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php @@ -36,14 +36,14 @@ public function testConstructor() } $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true); - $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument'); - $this->assertEquals($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument'); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + $this->assertEquals(true, $output->isDecorated(), '__construct() takes the decorated flag as its second argument'); } public function testGetStream() { $output = new StreamOutput($this->stream); - $this->assertEquals($output->getStream(), $this->stream, '->getStream() returns the current stream'); + $this->assertEquals($this->stream, $output->getStream(), '->getStream() returns the current stream'); } public function testDoWrite() @@ -51,6 +51,6 @@ public function testDoWrite() $output = new StreamOutput($this->stream); $output->writeln('foo'); rewind($output->getStream()); - $this->assertEquals(stream_get_contents($output->getStream()), "foo\n", '->doWrite() writes to the stream'); + $this->assertEquals("foo\n", stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); } } diff --git a/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php b/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php index efe8aa229e202..210eb0256a516 100644 --- a/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php +++ b/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php @@ -37,24 +37,24 @@ public function setUp() public function testRun() { - $this->assertEquals($this->tester->getInput()->isInteractive(), false, '->execute() takes an interactive option'); - $this->assertEquals($this->tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option'); - $this->assertEquals($this->tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option'); + $this->assertEquals(false, $this->tester->getInput()->isInteractive(), '->execute() takes an interactive option'); + $this->assertEquals(false, $this->tester->getOutput()->isDecorated(), '->execute() takes a decorated option'); + $this->assertEquals(Output::VERBOSITY_VERBOSE, $this->tester->getOutput()->getVerbosity(), '->execute() takes a verbosity option'); } public function testGetInput() { - $this->assertEquals($this->tester->getInput()->getArgument('foo'), 'bar', '->getInput() returns the current input instance'); + $this->assertEquals('bar', $this->tester->getInput()->getArgument('foo'), '->getInput() returns the current input instance'); } public function testGetOutput() { rewind($this->tester->getOutput()->getStream()); - $this->assertEquals(stream_get_contents($this->tester->getOutput()->getStream()), "foo\n", '->getOutput() returns the current output instance'); + $this->assertEquals("foo\n", stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); } public function testGetDisplay() { - $this->assertEquals($this->tester->getDisplay(), "foo\n", '->getDisplay() returns the display of the last execution'); + $this->assertEquals("foo\n", $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } } diff --git a/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php b/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php index ab52cec481c96..a58dadaab09d1 100644 --- a/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php +++ b/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php @@ -34,24 +34,24 @@ public function setUp() public function testExecute() { - $this->assertEquals($this->tester->getInput()->isInteractive(), false, '->execute() takes an interactive option'); - $this->assertEquals($this->tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option'); - $this->assertEquals($this->tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option'); + $this->assertEquals(false, $this->tester->getInput()->isInteractive(), '->execute() takes an interactive option'); + $this->assertEquals(false, $this->tester->getOutput()->isDecorated(), '->execute() takes a decorated option'); + $this->assertEquals(Output::VERBOSITY_VERBOSE, $this->tester->getOutput()->getVerbosity(), '->execute() takes a verbosity option'); } public function testGetInput() { - $this->assertEquals($this->tester->getInput()->getArgument('foo'), 'bar', '->getInput() returns the current input instance'); + $this->assertEquals('bar', $this->tester->getInput()->getArgument('foo'), '->getInput() returns the current input instance'); } public function testGetOutput() { rewind($this->tester->getOutput()->getStream()); - $this->assertEquals(stream_get_contents($this->tester->getOutput()->getStream()), "foo\n", '->getOutput() returns the current output instance'); + $this->assertEquals("foo\n", stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); } public function testGetDisplay() { - $this->assertEquals($this->tester->getDisplay(), "foo\n", '->getDisplay() returns the display of the last execution'); + $this->assertEquals("foo\n", $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php index ee5d227b7a863..5ac6c9cc9c923 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php @@ -38,74 +38,74 @@ public function testConstructor() 'bar' => 'bar', ); $configuration = new BuilderConfiguration($definitions, $parameters); - $this->assertEquals($configuration->getDefinitions(), $definitions, '__construct() takes an array of definitions as its first argument'); - $this->assertEquals($configuration->getParameters(), $parameters, '__construct() takes an array of parameters as its second argument'); + $this->assertEquals($definitions, $configuration->getDefinitions(), '__construct() takes an array of definitions as its first argument'); + $this->assertEquals($parameters, $configuration->getParameters(), '__construct() takes an array of parameters as its second argument'); } public function testMerge() { $configuration = new BuilderConfiguration(); $configuration->merge(null); - $this->assertEquals($configuration->getParameters(), array(), '->merge() accepts null as an argument'); - $this->assertEquals($configuration->getDefinitions(), array(), '->merge() accepts null as an argument'); + $this->assertEquals(array(), $configuration->getParameters(), '->merge() accepts null as an argument'); + $this->assertEquals(array(), $configuration->getDefinitions(), '->merge() accepts null as an argument'); $configuration = new BuilderConfiguration(array(), array('bar' => 'foo')); $configuration1 = new BuilderConfiguration(array(), array('foo' => 'bar')); $configuration->merge($configuration1); - $this->assertEquals($configuration->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones'); + $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $configuration->getParameters(), '->merge() merges current parameters with the loaded ones'); $configuration = new BuilderConfiguration(array(), array('bar' => 'foo', 'foo' => 'baz')); $config = new BuilderConfiguration(array(), array('foo' => 'bar')); $configuration->merge($config); - $this->assertEquals($configuration->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() overrides existing parameters'); + $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $configuration->getParameters(), '->merge() overrides existing parameters'); $configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'), 'bar' => new Definition('BarClass'))); $config = new BuilderConfiguration(array('baz' => new Definition('BazClass'))); $config->setAlias('alias_for_foo', 'foo'); $configuration->merge($config); - $this->assertEquals(array_keys($configuration->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones'); - $this->assertEquals($configuration->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases'); + $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($configuration->getDefinitions()), '->merge() merges definitions already defined ones'); + $this->assertEquals(array('alias_for_foo' => 'foo'), $configuration->getAliases(), '->merge() registers defined aliases'); $configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'))); $config->setDefinition('foo', new Definition('BazClass')); $configuration->merge($config); - $this->assertEquals($configuration->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services'); + $this->assertEquals('BazClass', $configuration->getDefinition('foo')->getClass(), '->merge() overrides already defined services'); $configuration = new BuilderConfiguration(); $configuration->addResource($a = new FileResource('foo.xml')); $config = new BuilderConfiguration(); $config->addResource($b = new FileResource('foo.yml')); $configuration->merge($config); - $this->assertEquals($configuration->getResources(), array($a, $b), '->merge() merges resources'); + $this->assertEquals(array($a, $b), $configuration->getResources(), '->merge() merges resources'); } public function testSetGetParameters() { $configuration = new BuilderConfiguration(); - $this->assertEquals($configuration->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined'); + $this->assertEquals(array(), $configuration->getParameters(), '->getParameters() returns an empty array if no parameter has been defined'); $configuration->setParameters(array('foo' => 'bar')); - $this->assertEquals($configuration->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters'); + $this->assertEquals(array('foo' => 'bar'), $configuration->getParameters(), '->setParameters() sets the parameters'); $configuration->setParameters(array('bar' => 'foo')); - $this->assertEquals($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters'); + $this->assertEquals(array('bar' => 'foo'), $configuration->getParameters(), '->setParameters() overrides the previous defined parameters'); $configuration->setParameters(array('Bar' => 'foo')); - $this->assertEquals($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase'); + $this->assertEquals(array('bar' => 'foo'), $configuration->getParameters(), '->setParameters() converts the key to lowercase'); } public function testSetGetParameter() { $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); $configuration->setParameter('bar', 'foo'); - $this->assertEquals($configuration->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter'); + $this->assertEquals('foo', $configuration->getParameter('bar'), '->setParameter() sets the value of a new parameter'); $configuration->setParameter('foo', 'baz'); - $this->assertEquals($configuration->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter'); + $this->assertEquals('baz', $configuration->getParameter('foo'), '->setParameter() overrides previously set parameter'); $configuration->setParameter('Foo', 'baz1'); - $this->assertEquals($configuration->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase'); - $this->assertEquals($configuration->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); + $this->assertEquals('baz1', $configuration->getParameter('foo'), '->setParameter() converts the key to lowercase'); + $this->assertEquals('baz1', $configuration->getParameter('FOO'), '->getParameter() converts the key to lowercase'); try { @@ -129,16 +129,16 @@ public function testAddParameters() { $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); $configuration->addParameters(array('bar' => 'foo')); - $this->assertEquals($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo'), $configuration->getParameters(), '->addParameters() adds parameters to the existing ones'); $configuration->addParameters(array('Bar' => 'fooz')); - $this->assertEquals($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'fooz'), $configuration->getParameters(), '->addParameters() converts keys to lowercase'); } public function testAliases() { $configuration = new BuilderConfiguration(); $configuration->setAlias('bar', 'foo'); - $this->assertEquals($configuration->getAlias('bar'), 'foo', '->setAlias() defines a new alias'); + $this->assertEquals('foo', $configuration->getAlias('bar'), '->setAlias() defines a new alias'); $this->assertTrue($configuration->hasAlias('bar'), '->hasAlias() returns true if the alias is defined'); $this->assertTrue(!$configuration->hasAlias('baba'), '->hasAlias() returns false if the alias is not defined'); @@ -152,10 +152,10 @@ public function testAliases() } $configuration->setAlias('barbar', 'foofoo'); - $this->assertEquals($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo'), '->getAliases() returns an array of all defined aliases'); + $this->assertEquals(array('bar' => 'foo', 'barbar' => 'foofoo'), $configuration->getAliases(), '->getAliases() returns an array of all defined aliases'); $configuration->addAliases(array('foo' => 'bar')); - $this->assertEquals($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo', 'foo' => 'bar'), '->addAliases() adds some aliases'); + $this->assertEquals(array('bar' => 'foo', 'barbar' => 'foofoo', 'foo' => 'bar'), $configuration->getAliases(), '->addAliases() adds some aliases'); } public function testDefinitions() @@ -166,16 +166,16 @@ public function testDefinitions() 'bar' => new Definition('BarClass'), ); $configuration->setDefinitions($definitions); - $this->assertEquals($configuration->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions'); + $this->assertEquals($definitions, $configuration->getDefinitions(), '->setDefinitions() sets the service definitions'); $this->assertTrue($configuration->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists'); $this->assertTrue(!$configuration->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist'); $configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')); - $this->assertEquals($configuration->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined'); + $this->assertEquals($foo, $configuration->getDefinition('foobar'), '->getDefinition() returns a service definition if defined'); $this->assertTrue($configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); $configuration->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); - $this->assertEquals($configuration->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions'); + $this->assertEquals(array_merge($definitions, $defs), $configuration->getDefinitions(), '->addDefinitions() adds the service definitions'); try { @@ -192,7 +192,7 @@ public function testFindDefinition() $configuration = new BuilderConfiguration(array('foo' => $definition = new Definition('FooClass'))); $configuration->setAlias('bar', 'foo'); $configuration->setAlias('foobar', 'bar'); - $this->assertEquals($configuration->findDefinition('foobar'), $definition, '->findDefinition() returns a Definition'); + $this->assertEquals($definition, $configuration->findDefinition('foobar'), '->findDefinition() returns a Definition'); } public function testResources() @@ -200,6 +200,6 @@ public function testResources() $configuration = new BuilderConfiguration(); $configuration->addResource($a = new FileResource('foo.xml')); $configuration->addResource($b = new FileResource('foo.yml')); - $this->assertEquals($configuration->getResources(), array($a, $b), '->getResources() returns an array of resources read for the current configuration'); + $this->assertEquals(array($a, $b), $configuration->getResources(), '->getResources() returns an array of resources read for the current configuration'); } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php index acdb17ad5662e..f3d8029292379 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php @@ -34,16 +34,16 @@ public function testDefinitions() 'bar' => new Definition('BarClass'), ); $builder->setDefinitions($definitions); - $this->assertEquals($builder->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions'); + $this->assertEquals($definitions, $builder->getDefinitions(), '->setDefinitions() sets the service definitions'); $this->assertTrue($builder->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists'); $this->assertTrue(!$builder->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist'); $builder->setDefinition('foobar', $foo = new Definition('FooBarClass')); - $this->assertEquals($builder->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined'); + $this->assertEquals($foo, $builder->getDefinition('foobar'), '->getDefinition() returns a service definition if defined'); $this->assertTrue($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); $builder->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); - $this->assertEquals($builder->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions'); + $this->assertEquals(array_merge($definitions, $defs), $builder->getDefinitions(), '->addDefinitions() adds the service definitions'); try { @@ -87,9 +87,9 @@ public function testGetService() $builder->register('foo', 'stdClass'); $this->assertTrue(is_object($builder->getService('foo')), '->getService() returns the service definition associated with the id'); $builder->bar = $bar = new \stdClass(); - $this->assertEquals($builder->getService('bar'), $bar, '->getService() returns the service associated with the id'); + $this->assertEquals($bar, $builder->getService('bar'), '->getService() returns the service associated with the id'); $builder->register('bar', 'stdClass'); - $this->assertEquals($builder->getService('bar'), $bar, '->getService() returns the service associated with the id even if a definition has been defined'); + $this->assertEquals($bar, $builder->getService('bar'), '->getService() returns the service associated with the id even if a definition has been defined'); $builder->register('baz', 'stdClass')->setArguments(array(new Reference('baz'))); try @@ -111,7 +111,7 @@ public function testGetServiceIds() $builder->register('foo', 'stdClass'); $builder->bar = $bar = new \stdClass(); $builder->register('bar', 'stdClass'); - $this->assertEquals($builder->getServiceIds(), array('foo', 'bar', 'service_container'), '->getServiceIds() returns all defined service ids'); + $this->assertEquals(array('foo', 'bar', 'service_container'), $builder->getServiceIds(), '->getServiceIds() returns all defined service ids'); } public function testAliases() @@ -121,7 +121,7 @@ public function testAliases() $builder->setAlias('bar', 'foo'); $this->assertTrue($builder->hasAlias('bar'), '->hasAlias() returns true if the alias exists'); $this->assertTrue(!$builder->hasAlias('foobar'), '->hasAlias() returns false if the alias does not exist'); - $this->assertEquals($builder->getAlias('bar'), 'foo', '->getAlias() returns the aliased service'); + $this->assertEquals('foo', $builder->getAlias('bar'), '->getAlias() returns the aliased service'); $this->assertTrue($builder->hasService('bar'), '->setAlias() defines a new service'); $this->assertTrue($builder->getService('bar') === $builder->getService('foo'), '->setAlias() creates a service that is an alias to another one'); @@ -140,11 +140,11 @@ public function testGetAliases() $builder = new Builder(); $builder->setAlias('bar', 'foo'); $builder->setAlias('foobar', 'foo'); - $this->assertEquals($builder->getAliases(), array('bar' => 'foo', 'foobar' => 'foo'), '->getAliases() returns all service aliases'); + $this->assertEquals(array('bar' => 'foo', 'foobar' => 'foo'), $builder->getAliases(), '->getAliases() returns all service aliases'); $builder->register('bar', 'stdClass'); - $this->assertEquals($builder->getAliases(), array('foobar' => 'foo'), '->getAliases() does not return aliased services that have been overridden'); + $this->assertEquals(array('foobar' => 'foo'), $builder->getAliases(), '->getAliases() does not return aliased services that have been overridden'); $builder->setService('foobar', 'stdClass'); - $this->assertEquals($builder->getAliases(), array(), '->getAliases() does not return aliased services that have been overridden'); + $this->assertEquals(array(), $builder->getAliases(), '->getAliases() does not return aliased services that have been overridden'); } public function testCreateService() @@ -171,7 +171,7 @@ public function testCreateServiceArguments() $builder->register('bar', 'stdClass'); $builder->register('foo1', 'FooClass')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); $builder->setParameter('value', 'bar'); - $this->assertEquals($builder->getService('foo1')->arguments, array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), '->createService() replaces parameters and service references in the arguments provided by the service definition'); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), $builder->getService('foo1')->arguments, '->createService() replaces parameters and service references in the arguments provided by the service definition'); } public function testCreateServiceConstructor() @@ -181,7 +181,7 @@ public function testCreateServiceConstructor() $builder->register('foo1', 'FooClass')->setConstructor('getInstance')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); $builder->setParameter('value', 'bar'); $this->assertTrue($builder->getService('foo1')->called, '->createService() calls the constructor to create the service instance'); - $this->assertEquals($builder->getService('foo1')->arguments, array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), '->createService() passes the arguments to the constructor'); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->getService('bar')), $builder->getService('foo1')->arguments, '->createService() passes the arguments to the constructor'); } public function testCreateServiceMethodCalls() @@ -190,7 +190,7 @@ public function testCreateServiceMethodCalls() $builder->register('bar', 'stdClass'); $builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%value%', new Reference('bar')))); $builder->setParameter('value', 'bar'); - $this->assertEquals($builder->getService('foo1')->bar, array('bar', $builder->getService('bar')), '->createService() replaces the values in the method calls arguments'); + $this->assertEquals(array('bar', $builder->getService('bar')), $builder->getService('foo1')->bar, '->createService() replaces the values in the method calls arguments'); } public function testCreateServiceConfigurator() @@ -222,16 +222,16 @@ public function testCreateServiceConfigurator() public function testResolveValue() { - $this->assertEquals(Builder::resolveValue('foo', array()), 'foo', '->resolveValue() returns its argument unmodified if no placeholders are found'); - $this->assertEquals(Builder::resolveValue('I\'m a %foo%', array('foo' => 'bar')), 'I\'m a bar', '->resolveValue() replaces placeholders by their values'); + $this->assertEquals('foo', Builder::resolveValue('foo', array()), '->resolveValue() returns its argument unmodified if no placeholders are found'); + $this->assertEquals('I\'m a bar', Builder::resolveValue('I\'m a %foo%', array('foo' => 'bar')), '->resolveValue() replaces placeholders by their values'); $this->assertTrue(Builder::resolveValue('%foo%', array('foo' => true)) === true, '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); - $this->assertEquals(Builder::resolveValue(array('%foo%' => '%foo%'), array('foo' => 'bar')), array('bar' => 'bar'), '->resolveValue() replaces placeholders in keys and values of arrays'); + $this->assertEquals(array('bar' => 'bar'), Builder::resolveValue(array('%foo%' => '%foo%'), array('foo' => 'bar')), '->resolveValue() replaces placeholders in keys and values of arrays'); - $this->assertEquals(Builder::resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%'))), array('foo' => 'bar')), array('bar' => array('bar' => array('bar' => 'bar'))), '->resolveValue() replaces placeholders in nested arrays'); + $this->assertEquals(array('bar' => array('bar' => array('bar' => 'bar'))), Builder::resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%'))), array('foo' => 'bar')), '->resolveValue() replaces placeholders in nested arrays'); - $this->assertEquals(Builder::resolveValue('I\'m a %%foo%%', array('foo' => 'bar')), 'I\'m a %foo%', '->resolveValue() supports % escaping by doubling it'); - $this->assertEquals(Builder::resolveValue('I\'m a %foo% %%foo %foo%', array('foo' => 'bar')), 'I\'m a bar %foo bar', '->resolveValue() supports % escaping by doubling it'); + $this->assertEquals('I\'m a %foo%', Builder::resolveValue('I\'m a %%foo%%', array('foo' => 'bar')), '->resolveValue() supports % escaping by doubling it'); + $this->assertEquals('I\'m a bar %foo bar', Builder::resolveValue('I\'m a %foo% %%foo %foo%', array('foo' => 'bar')), '->resolveValue() supports % escaping by doubling it'); try { @@ -256,40 +256,40 @@ public function testResolveServices() { $builder = new Builder(); $builder->register('foo', 'FooClass'); - $this->assertEquals($builder->resolveServices(new Reference('foo')), $builder->getService('foo'), '->resolveServices() resolves service references to service instances'); - $this->assertEquals($builder->resolveServices(array('foo' => array('foo', new Reference('foo')))), array('foo' => array('foo', $builder->getService('foo'))), '->resolveServices() resolves service references to service instances in nested arrays'); + $this->assertEquals($builder->getService('foo'), $builder->resolveServices(new Reference('foo')), '->resolveServices() resolves service references to service instances'); + $this->assertEquals(array('foo' => array('foo', $builder->getService('foo'))), $builder->resolveServices(array('foo' => array('foo', new Reference('foo')))), '->resolveServices() resolves service references to service instances in nested arrays'); } public function testMerge() { $container = new Builder(); $container->merge(null); - $this->assertEquals($container->getParameters(), array(), '->merge() accepts null as an argument'); - $this->assertEquals($container->getDefinitions(), array(), '->merge() accepts null as an argument'); + $this->assertEquals(array(), $container->getParameters(), '->merge() accepts null as an argument'); + $this->assertEquals(array(), $container->getDefinitions(), '->merge() accepts null as an argument'); $container = new Builder(array('bar' => 'foo')); $config = new BuilderConfiguration(); $config->setParameters(array('foo' => 'bar')); $container->merge($config); - $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones'); + $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $container->getParameters(), '->merge() merges current parameters with the loaded ones'); $container = new Builder(array('bar' => 'foo', 'foo' => 'baz')); $config = new BuilderConfiguration(); $config->setParameters(array('foo' => 'bar')); $container->merge($config); - $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'baz'), '->merge() does not change the already defined parameters'); + $this->assertEquals(array('bar' => 'foo', 'foo' => 'baz'), $container->getParameters(), '->merge() does not change the already defined parameters'); $container = new Builder(array('bar' => 'foo')); $config = new BuilderConfiguration(); $config->setParameters(array('foo' => '%bar%')); $container->merge($config); - $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones'); + $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo'), $container->getParameters(), '->merge() evaluates the values of the parameters towards already defined ones'); $container = new Builder(array('bar' => 'foo')); $config = new BuilderConfiguration(); $config->setParameters(array('foo' => '%bar%', 'baz' => '%foo%')); $container->merge($config); - $this->assertEquals($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones'); + $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), $container->getParameters(), '->merge() evaluates the values of the parameters towards already defined ones'); $container = new Builder(); $container->register('foo', 'FooClass'); @@ -298,14 +298,14 @@ public function testMerge() $config->setDefinition('baz', new Definition('BazClass')); $config->setAlias('alias_for_foo', 'foo'); $container->merge($config); - $this->assertEquals(array_keys($container->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones'); - $this->assertEquals($container->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases'); + $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones'); + $this->assertEquals(array('alias_for_foo' => 'foo'), $container->getAliases(), '->merge() registers defined aliases'); $container = new Builder(); $container->register('foo', 'FooClass'); $config->setDefinition('foo', new Definition('BazClass')); $container->merge($config); - $this->assertEquals($container->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services'); + $this->assertEquals('BazClass', $container->getDefinition('foo')->getClass(), '->merge() overrides already defined services'); } public function testFindAnnotatedServiceIds() @@ -323,6 +323,6 @@ public function testFindAnnotatedServiceIds() array('foofoo' => 'foofoo'), ) ), '->findAnnotatedServiceIds() returns an array of service ids and its annotation attributes'); - $this->assertEquals($builder->findAnnotatedServiceIds('foobar'), array(), '->findAnnotatedServiceIds() returns an empty array if there is annotated services'); + $this->assertEquals(array(), $builder->findAnnotatedServiceIds('foobar'), '->findAnnotatedServiceIds() returns an empty array if there is annotated services'); } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php index c550b3d4ea18d..4fb0838e89461 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php @@ -19,47 +19,47 @@ class ContainerTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $sc = new Container(); - $this->assertEquals(spl_object_hash($sc->getService('service_container')), spl_object_hash($sc), '__construct() automatically registers itself as a service'); + $this->assertEquals(spl_object_hash($sc), spl_object_hash($sc->getService('service_container')), '__construct() automatically registers itself as a service'); $sc = new Container(array('foo' => 'bar')); - $this->assertEquals($sc->getParameters(), array('foo' => 'bar'), '__construct() takes an array of parameters as its first argument'); + $this->assertEquals(array('foo' => 'bar'), $sc->getParameters(), '__construct() takes an array of parameters as its first argument'); } public function testGetSetParameters() { $sc = new Container(); - $this->assertEquals($sc->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined'); + $this->assertEquals(array(), $sc->getParameters(), '->getParameters() returns an empty array if no parameter has been defined'); $sc->setParameters(array('foo' => 'bar')); - $this->assertEquals($sc->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters'); + $this->assertEquals(array('foo' => 'bar'), $sc->getParameters(), '->setParameters() sets the parameters'); $sc->setParameters(array('bar' => 'foo')); - $this->assertEquals($sc->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters'); + $this->assertEquals(array('bar' => 'foo'), $sc->getParameters(), '->setParameters() overrides the previous defined parameters'); $sc->setParameters(array('Bar' => 'foo')); - $this->assertEquals($sc->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase'); + $this->assertEquals(array('bar' => 'foo'), $sc->getParameters(), '->setParameters() converts the key to lowercase'); } public function testGetSetParameter() { $sc = new Container(array('foo' => 'bar')); $sc->setParameter('bar', 'foo'); - $this->assertEquals($sc->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter'); - $this->assertEquals($sc['bar'], 'foo', '->offsetGet() gets the value of a parameter'); + $this->assertEquals('foo', $sc->getParameter('bar'), '->setParameter() sets the value of a new parameter'); + $this->assertEquals('foo', $sc['bar'], '->offsetGet() gets the value of a parameter'); $sc['bar1'] = 'foo1'; - $this->assertEquals($sc['bar1'], 'foo1', '->offsetset() sets the value of a parameter'); + $this->assertEquals('foo1', $sc['bar1'], '->offsetset() sets the value of a parameter'); unset($sc['bar1']); $this->assertTrue(!isset($sc['bar1']), '->offsetUnset() removes a parameter'); $sc->setParameter('foo', 'baz'); - $this->assertEquals($sc->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter'); + $this->assertEquals('baz', $sc->getParameter('foo'), '->setParameter() overrides previously set parameter'); $sc->setParameter('Foo', 'baz1'); - $this->assertEquals($sc->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase'); - $this->assertEquals($sc->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); - $this->assertEquals($sc['FOO'], 'baz1', '->offsetGet() converts the key to lowercase'); + $this->assertEquals('baz1', $sc->getParameter('foo'), '->setParameter() converts the key to lowercase'); + $this->assertEquals('baz1', $sc->getParameter('FOO'), '->getParameter() converts the key to lowercase'); + $this->assertEquals('baz1', $sc['FOO'], '->offsetGet() converts the key to lowercase'); try { @@ -95,21 +95,21 @@ public function testAddParameters() { $sc = new Container(array('foo' => 'bar')); $sc->addParameters(array('bar' => 'foo')); - $this->assertEquals($sc->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo'), $sc->getParameters(), '->addParameters() adds parameters to the existing ones'); $sc->addParameters(array('Bar' => 'fooz')); - $this->assertEquals($sc->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'fooz'), $sc->getParameters(), '->addParameters() converts keys to lowercase'); } public function testServices() { $sc = new Container(); $sc->setService('foo', $obj = new \stdClass()); - $this->assertEquals(spl_object_hash($sc->getService('foo')), spl_object_hash($obj), '->setService() registers a service under a key name'); + $this->assertEquals(spl_object_hash($obj), spl_object_hash($sc->getService('foo')), '->setService() registers a service under a key name'); $sc->foo1 = $obj1 = new \stdClass(); - $this->assertEquals(spl_object_hash($sc->foo1), spl_object_hash($obj1), '->__set() sets a service'); + $this->assertEquals(spl_object_hash($obj1), spl_object_hash($sc->foo1), '->__set() sets a service'); - $this->assertEquals(spl_object_hash($sc->foo), spl_object_hash($obj), '->__get() gets a service by name'); + $this->assertEquals(spl_object_hash($obj), spl_object_hash($sc->foo), '->__get() gets a service by name'); $this->assertTrue($sc->hasService('foo'), '->hasService() returns true if the service is defined'); $this->assertTrue(isset($sc->foo), '->__isset() returns true if the service is defined'); $this->assertTrue(!$sc->hasService('bar'), '->hasService() returns false if the service is not defined'); @@ -121,10 +121,10 @@ public function testGetServiceIds() $sc = new Container(); $sc->setService('foo', $obj = new \stdClass()); $sc->setService('bar', $obj = new \stdClass()); - $this->assertEquals($sc->getServiceIds(), array('service_container', 'foo', 'bar'), '->getServiceIds() returns all defined service ids'); + $this->assertEquals(array('service_container', 'foo', 'bar'), $sc->getServiceIds(), '->getServiceIds() returns all defined service ids'); $sc = new ProjectServiceContainer(); - $this->assertEquals(spl_object_hash($sc->getService('bar')), spl_object_hash($sc->__bar), '->getService() looks for a getXXXService() method'); + $this->assertEquals(spl_object_hash($sc->__bar), spl_object_hash($sc->getService('bar')), '->getService() looks for a getXXXService() method'); $this->assertTrue($sc->hasService('bar'), '->hasService() returns true if the service has been defined as a getXXXService() method'); $sc->setService('bar', $bar = new \stdClass()); @@ -157,15 +157,15 @@ public function testGetServiceIds() { } - $this->assertEquals(spl_object_hash($sc->getService('foo_bar')), spl_object_hash($sc->__foo_bar), '->getService() camelizes the service id when looking for a method'); - $this->assertEquals(spl_object_hash($sc->getService('foo.baz')), spl_object_hash($sc->__foo_baz), '->getService() camelizes the service id when looking for a method'); + $this->assertEquals(spl_object_hash($sc->__foo_bar), spl_object_hash($sc->getService('foo_bar')), '->getService() camelizes the service id when looking for a method'); + $this->assertEquals(spl_object_hash($sc->__foo_baz), spl_object_hash($sc->getService('foo.baz')), '->getService() camelizes the service id when looking for a method'); } public function testMagicCall() { $sc = new Container(); $sc->setService('foo_bar.foo', $foo = new \stdClass()); - $this->assertEquals($sc->getFooBar_FooService(), $foo, '__call() finds services is the method is getXXXService()'); + $this->assertEquals($foo, $sc->getFooBar_FooService(), '__call() finds services is the method is getXXXService()'); try { diff --git a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php index fc25578598538..22612bfef2ad7 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php @@ -65,9 +65,9 @@ public function testCrossCheck() unlink($tmp); - $this->assertEquals(serialize($container1), serialize($container2), 'loading a dump from a previously loaded container returns the same container'); + $this->assertEquals(serialize($container2), serialize($container1), 'loading a dump from a previously loaded container returns the same container'); - $this->assertEquals($container1->getParameters(), $container2->getParameters(), '->getParameters() returns the same value for both containers'); + $this->assertEquals($container2->getParameters(), $container1->getParameters(), '->getParameters() returns the same value for both containers'); $services1 = array(); foreach ($container1 as $id => $service) @@ -82,7 +82,7 @@ public function testCrossCheck() unset($services1['service_container'], $services2['service_container']); - $this->assertEquals($services1, $services2, 'Iterator on the containers returns the same services'); + $this->assertEquals($services2, $services1, 'Iterator on the containers returns the same services'); } } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php index d6a948a4a19f6..02075a809a707 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php @@ -19,73 +19,73 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $def = new Definition('stdClass'); - $this->assertEquals($def->getClass(), 'stdClass', '__construct() takes the class name as its first argument'); + $this->assertEquals('stdClass', $def->getClass(), '__construct() takes the class name as its first argument'); $def = new Definition('stdClass', array('foo')); - $this->assertEquals($def->getArguments(), array('foo'), '__construct() takes an optional array of arguments as its second argument'); + $this->assertEquals(array('foo'), $def->getArguments(), '__construct() takes an optional array of arguments as its second argument'); } public function testSetGetConstructor() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->setConstructor('foo')), spl_object_hash($def), '->setConstructor() implements a fluent interface'); - $this->assertEquals($def->getConstructor(), 'foo', '->getConstructor() returns the constructor name'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setConstructor('foo')), '->setConstructor() implements a fluent interface'); + $this->assertEquals('foo', $def->getConstructor(), '->getConstructor() returns the constructor name'); } public function testSetGetClass() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->setClass('foo')), spl_object_hash($def), '->setClass() implements a fluent interface'); - $this->assertEquals($def->getClass(), 'foo', '->getClass() returns the class name'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setClass('foo')), '->setClass() implements a fluent interface'); + $this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name'); } public function testArguments() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->setArguments(array('foo'))), spl_object_hash($def), '->setArguments() implements a fluent interface'); - $this->assertEquals($def->getArguments(), array('foo'), '->getArguments() returns the arguments'); - $this->assertEquals(spl_object_hash($def->addArgument('bar')), spl_object_hash($def), '->addArgument() implements a fluent interface'); - $this->assertEquals($def->getArguments(), array('foo', 'bar'), '->addArgument() adds an argument'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setArguments(array('foo'))), '->setArguments() implements a fluent interface'); + $this->assertEquals(array('foo'), $def->getArguments(), '->getArguments() returns the arguments'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->addArgument('bar')), '->addArgument() implements a fluent interface'); + $this->assertEquals(array('foo', 'bar'), $def->getArguments(), '->addArgument() adds an argument'); } public function testMethodCalls() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->setMethodCalls(array(array('foo', array('foo'))))), spl_object_hash($def), '->setMethodCalls() implements a fluent interface'); - $this->assertEquals($def->getMethodCalls(), array(array('foo', array('foo'))), '->getMethodCalls() returns the methods to call'); - $this->assertEquals(spl_object_hash($def->addMethodCall('bar', array('bar'))), spl_object_hash($def), '->addMethodCall() implements a fluent interface'); - $this->assertEquals($def->getMethodCalls(), array(array('foo', array('foo')), array('bar', array('bar'))), '->addMethodCall() adds a method to call'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setMethodCalls(array(array('foo', array('foo'))))), '->setMethodCalls() implements a fluent interface'); + $this->assertEquals(array(array('foo', array('foo'))), $def->getMethodCalls(), '->getMethodCalls() returns the methods to call'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->addMethodCall('bar', array('bar'))), '->addMethodCall() implements a fluent interface'); + $this->assertEquals(array(array('foo', array('foo')), array('bar', array('bar'))), $def->getMethodCalls(), '->addMethodCall() adds a method to call'); } public function testSetGetFile() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->setFile('foo')), spl_object_hash($def), '->setFile() implements a fluent interface'); - $this->assertEquals($def->getFile(), 'foo', '->getFile() returns the file to include'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setFile('foo')), '->setFile() implements a fluent interface'); + $this->assertEquals('foo', $def->getFile(), '->getFile() returns the file to include'); } public function testSetIsShared() { $def = new Definition('stdClass'); - $this->assertEquals($def->isShared(), true, '->isShared() returns true by default'); - $this->assertEquals(spl_object_hash($def->setShared(false)), spl_object_hash($def), '->setShared() implements a fluent interface'); - $this->assertEquals($def->isShared(), false, '->isShared() returns false if the instance must not be shared'); + $this->assertEquals(true, $def->isShared(), '->isShared() returns true by default'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setShared(false)), '->setShared() implements a fluent interface'); + $this->assertEquals(false, $def->isShared(), '->isShared() returns false if the instance must not be shared'); } public function testSetGetConfigurator() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->setConfigurator('foo')), spl_object_hash($def), '->setConfigurator() implements a fluent interface'); - $this->assertEquals($def->getConfigurator(), 'foo', '->getConfigurator() returns the configurator'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->setConfigurator('foo')), '->setConfigurator() implements a fluent interface'); + $this->assertEquals('foo', $def->getConfigurator(), '->getConfigurator() returns the configurator'); } public function testAnnotations() { $def = new Definition('stdClass'); - $this->assertEquals(spl_object_hash($def->addAnnotation('foo')), spl_object_hash($def), '->addAnnotation() implements a fluent interface'); - $this->assertEquals($def->getAnnotation('foo'), array(array()), '->getAnnotation() returns attributes for an annotation name'); + $this->assertEquals(spl_object_hash($def), spl_object_hash($def->addAnnotation('foo')), '->addAnnotation() implements a fluent interface'); + $this->assertEquals(array(array()), $def->getAnnotation('foo'), '->getAnnotation() returns attributes for an annotation name'); $def->addAnnotation('foo', array('foo' => 'bar')); - $this->assertEquals($def->getAnnotation('foo'), array(array(), array('foo' => 'bar')), '->addAnnotation() can adds the same annotation several times'); + $this->assertEquals(array(array(), array('foo' => 'bar')), $def->getAnnotation('foo'), '->addAnnotation() can adds the same annotation several times'); $def->addAnnotation('bar', array('bar' => 'bar')); $this->assertEquals($def->getAnnotations(), array( 'foo' => array(array(), array('foo' => 'bar')), diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php index 8863f17886b08..b26ec2affdc49 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php @@ -28,18 +28,18 @@ public function testDump() { $dumper = new GraphvizDumper($container = new Builder()); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/graphviz/services1.dot'), '->dump() dumps an empty container as an empty dot file'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/graphviz/services1.dot'), $dumper->dump(), '->dump() dumps an empty container as an empty dot file'); $container = new Builder(); $dumper = new GraphvizDumper($container); $container = include self::$fixturesPath.'/containers/container9.php'; $dumper = new GraphvizDumper($container); - $this->assertEquals($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services9.dot')), '->dump() dumps services'); + $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services9.dot')), $dumper->dump(), '->dump() dumps services'); $container = include self::$fixturesPath.'/containers/container10.php'; $dumper = new GraphvizDumper($container); - $this->assertEquals($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10.dot')), '->dump() dumps services'); + $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10.dot')), $dumper->dump(), '->dump() dumps services'); $container = include self::$fixturesPath.'/containers/container10.php'; $dumper = new GraphvizDumper($container); diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php index 8ffca976f8b67..1925e0d6ce233 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php @@ -28,8 +28,8 @@ public function testDump() { $dumper = new PhpDumper($container = new Builder()); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/php/services1.php'), '->dump() dumps an empty container as an empty PHP class'); - $this->assertEquals($dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer')), file_get_contents(self::$fixturesPath.'/php/services1-1.php'), '->dump() takes a class and a base_class options'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services1.php'), $dumper->dump(), '->dump() dumps an empty container as an empty PHP class'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services1-1.php'), $dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer')), '->dump() takes a class and a base_class options'); $container = new Builder(); $dumper = new PhpDumper($container); @@ -39,14 +39,14 @@ public function testAddParameters() { $container = include self::$fixturesPath.'/containers/container8.php'; $dumper = new PhpDumper($container); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/php/services8.php'), '->dump() dumps parameters'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services8.php'), $dumper->dump(), '->dump() dumps parameters'); } public function testAddService() { $container = include self::$fixturesPath.'/containers/container9.php'; $dumper = new PhpDumper($container); - $this->assertEquals($dumper->dump(), str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/php/services9.php')), '->dump() dumps services'); + $this->assertEquals(str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/php/services9.php')), $dumper->dump(), '->dump() dumps services'); $dumper = new PhpDumper($container = new Builder()); $container->register('foo', 'FooClass')->addArgument(new \stdClass()); diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php index 24f0c7f8d0014..13940297cb3ce 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php @@ -28,7 +28,7 @@ public function testDump() { $dumper = new XmlDumper($container = new Builder()); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/xml/services1.xml'), '->dump() dumps an empty container as an empty XML file'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services1.xml'), $dumper->dump(), '->dump() dumps an empty container as an empty XML file'); $container = new Builder(); $dumper = new XmlDumper($container); @@ -38,14 +38,14 @@ public function testAddParemeters() { $container = include self::$fixturesPath.'//containers/container8.php'; $dumper = new XmlDumper($container); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/xml/services8.xml'), '->dump() dumps parameters'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services8.xml'), $dumper->dump(), '->dump() dumps parameters'); } public function testAddService() { $container = include self::$fixturesPath.'/containers/container9.php'; $dumper = new XmlDumper($container); - $this->assertEquals($dumper->dump(), str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/xml/services9.xml')), '->dump() dumps services'); + $this->assertEquals(str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/xml/services9.xml')), $dumper->dump(), '->dump() dumps services'); $dumper = new XmlDumper($container = new Builder()); $container->register('foo', 'FooClass')->addArgument(new \stdClass()); diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php index fb8778f55de33..9a325b020b5dd 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php @@ -28,7 +28,7 @@ public function testDump() { $dumper = new YamlDumper($container = new Builder()); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/yaml/services1.yml'), '->dump() dumps an empty container as an empty YAML file'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/yaml/services1.yml'), $dumper->dump(), '->dump() dumps an empty container as an empty YAML file'); $container = new Builder(); $dumper = new YamlDumper($container); @@ -38,14 +38,14 @@ public function testAddParameters() { $container = include self::$fixturesPath.'/containers/container8.php'; $dumper = new YamlDumper($container); - $this->assertEquals($dumper->dump(), file_get_contents(self::$fixturesPath.'/yaml/services8.yml'), '->dump() dumps parameters'); + $this->assertEquals(file_get_contents(self::$fixturesPath.'/yaml/services8.yml'), $dumper->dump(), '->dump() dumps parameters'); } public function testAddService() { $container = include self::$fixturesPath.'/containers/container9.php'; $dumper = new YamlDumper($container); - $this->assertEquals($dumper->dump(), str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), '->dump() dumps services'); + $this->assertEquals(str_replace('%path%', self::$fixturesPath.'/includes', file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services'); $dumper = new YamlDumper($container = new Builder()); $container->register('foo', 'FooClass')->addArgument(new \stdClass()); diff --git a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php index f0663126dfd99..41ec10102f0a2 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php @@ -33,7 +33,7 @@ public function tearDown() public function testGetResource() { - $this->assertEquals($this->resource->getResource(), $this->file, '->getResource() returns the path to the resource'); + $this->assertEquals($this->file, $this->resource->getResource(), '->getResource() returns the path to the resource'); } public function testIsUptodate() diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php index 876d3f21b36e1..feb5fb3e78b26 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php @@ -20,25 +20,25 @@ class XmlDumperTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $loader = new ProjectLoader(__DIR__); - $this->assertEquals($loader->paths, array(__DIR__), '__construct() takes a path as its second argument'); + $this->assertEquals(array(__DIR__), $loader->paths, '__construct() takes a path as its second argument'); $loader = new ProjectLoader(array(__DIR__, __DIR__)); - $this->assertEquals($loader->paths, array(__DIR__, __DIR__), '__construct() takes an array of paths as its second argument'); + $this->assertEquals(array(__DIR__, __DIR__), $loader->paths, '__construct() takes an array of paths as its second argument'); } public function testGetAbsolutePath() { $loader = new ProjectLoader(array(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/containers')); - $this->assertEquals($loader->getAbsolutePath('/foo.xml'), '/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); - $this->assertEquals($loader->getAbsolutePath('c:\\\\foo.xml'), 'c:\\\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); - $this->assertEquals($loader->getAbsolutePath('c:/foo.xml'), 'c:/foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); - $this->assertEquals($loader->getAbsolutePath('\\server\\foo.xml'), '\\server\\foo.xml', '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals('/foo.xml', $loader->getAbsolutePath('/foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals('c:\\\\foo.xml', $loader->getAbsolutePath('c:\\\\foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals('c:/foo.xml', $loader->getAbsolutePath('c:/foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path'); + $this->assertEquals('\\server\\foo.xml', $loader->getAbsolutePath('\\server\\foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path'); - $this->assertEquals($loader->getAbsolutePath('FileLoaderTest.php', __DIR__), __DIR__.'/FileLoaderTest.php', '->getAbsolutePath() returns an absolute filename if the file exists in the current path'); + $this->assertEquals(__DIR__.'/FileLoaderTest.php', $loader->getAbsolutePath('FileLoaderTest.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in the current path'); - $this->assertEquals($loader->getAbsolutePath('container10.php', __DIR__), __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/containers/container10.php', '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor'); + $this->assertEquals(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/containers/container10.php', $loader->getAbsolutePath('container10.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor'); - $this->assertEquals($loader->getAbsolutePath('foo.xml', __DIR__), 'foo.xml', '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths'); + $this->assertEquals('foo.xml', $loader->getAbsolutePath('foo.xml', __DIR__), '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths'); } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php index 579af40af93dd..da72c48062984 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php @@ -28,7 +28,7 @@ public function testLoader() { $loader = new IniFileLoader(self::$fixturesPath.'/ini'); $config = $loader->load('parameters.ini'); - $this->assertEquals($config->getParameters(), array('foo' => 'bar', 'bar' => '%foo%'), '->load() takes a single file name as its first argument'); + $this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $config->getParameters(), '->load() takes a single file name as its first argument'); try { diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php index 5ae2a5b15b38f..c0ba13c1d4674 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php @@ -30,6 +30,6 @@ public function testLoad() } $config = $extension->load('bar', array('foo' => 'bar')); - $this->assertEquals($config->getParameters(), array('project.parameter.bar' => 'bar'), '->load() calls the method tied to the given tag'); + $this->assertEquals(array('project.parameter.bar' => 'bar'), $config->getParameters(), '->load() calls the method tied to the given tag'); } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php index 94fb11c84b307..1577229612703 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php @@ -67,7 +67,7 @@ public function testParseFile() } $xml = $loader->parseFile(self::$fixturesPath.'/xml/services1.xml'); - $this->assertEquals(get_class($xml), 'Symfony\\Components\\DependencyInjection\\SimpleXMLElement', '->parseFile() returns an SimpleXMLElement object'); + $this->assertEquals('Symfony\\Components\\DependencyInjection\\SimpleXMLElement', get_class($xml), '->parseFile() returns an SimpleXMLElement object'); } public function testLoadParameters() @@ -78,7 +78,7 @@ public function testLoadParameters() $actual = $config->getParameters(); $expected = 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')); - $this->assertEquals($actual, $expected, '->load() converts XML values to PHP ones'); + $this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones'); } public function testLoadImports() @@ -89,7 +89,7 @@ public function testLoadImports() $actual = $config->getParameters(); $expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true); - $this->assertEquals(array_keys($actual), array_keys($expected), '->load() imports and merges imported files'); + $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); } public function testLoadAnonymousServices() @@ -97,20 +97,20 @@ public function testLoadAnonymousServices() $loader = new ProjectLoader2(self::$fixturesPath.'/xml'); $config = $loader->load('services5.xml'); $services = $config->getDefinitions(); - $this->assertEquals(count($services), 3, '->load() attributes unique ids to anonymous services'); + $this->assertEquals(3, count($services), '->load() attributes unique ids to anonymous services'); $args = $services['foo']->getArguments(); - $this->assertEquals(count($args), 1, '->load() references anonymous services as "normal" ones'); - $this->assertEquals(get_class($args[0]), 'Symfony\\Components\\DependencyInjection\\Reference', '->load() converts anonymous services to references to "normal" services'); + $this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones'); + $this->assertEquals('Symfony\\Components\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services'); $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; - $this->assertEquals($inner->getClass(), 'BarClass', '->load() uses the same configuration as for the anonymous ones'); + $this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $args = $inner->getArguments(); - $this->assertEquals(count($args), 1, '->load() references anonymous services as "normal" ones'); - $this->assertEquals(get_class($args[0]), 'Symfony\\Components\\DependencyInjection\\Reference', '->load() converts anonymous services to references to "normal" services'); + $this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones'); + $this->assertEquals('Symfony\\Components\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services'); $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; - $this->assertEquals($inner->getClass(), 'BazClass', '->load() uses the same configuration as for the anonymous ones'); + $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); } public function testLoadServices() @@ -119,48 +119,48 @@ public function testLoadServices() $config = $loader->load('services6.xml'); $services = $config->getDefinitions(); $this->assertTrue(isset($services['foo']), '->load() parses elements'); - $this->assertEquals(get_class($services['foo']), 'Symfony\\Components\\DependencyInjection\\Definition', '->load() converts element to Definition instances'); - $this->assertEquals($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute'); + $this->assertEquals('Symfony\\Components\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts element to Definition instances'); + $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertTrue($services['shared']->isShared(), '->load() parses the shared attribute'); $this->assertTrue(!$services['non_shared']->isShared(), '->load() parses the shared attribute'); - $this->assertEquals($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute'); - $this->assertEquals($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag'); - $this->assertEquals($services['arguments']->getArguments(), array('foo', new Reference('foo'), array(true, false)), '->load() parses the argument tags'); - $this->assertEquals($services['configurator1']->getConfigurator(), 'sc_configure', '->load() parses the configurator tag'); - $this->assertEquals($services['configurator2']->getConfigurator(), array(new Reference('baz'), 'configure'), '->load() parses the configurator tag'); - $this->assertEquals($services['configurator3']->getConfigurator(), array('BazClass', 'configureStatic'), '->load() parses the configurator tag'); - $this->assertEquals($services['method_call1']->getMethodCalls(), array(array('setBar', array())), '->load() parses the method_call tag'); - $this->assertEquals($services['method_call2']->getMethodCalls(), array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), '->load() parses the method_call tag'); + $this->assertEquals('getInstance', $services['constructor']->getConstructor(), '->load() parses the constructor attribute'); + $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); + $this->assertEquals(array('foo', new Reference('foo'), array(true, false)), $services['arguments']->getArguments(), '->load() parses the argument tags'); + $this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag'); + $this->assertEquals(array(new Reference('baz'), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag'); + $this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag'); + $this->assertEquals(array(array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); + $this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag'); $aliases = $config->getAliases(); $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses elements'); - $this->assertEquals($aliases['alias_for_foo'], 'foo', '->load() parses aliases'); + $this->assertEquals('foo', $aliases['alias_for_foo'], '->load() parses aliases'); } public function testConvertDomElementToArray() { $doc = new \DOMDocument("1.0"); $doc->loadXML('bar'); - $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), 'bar', '::convertDomElementToArray() converts a \DomElement to an array'); + $this->assertEquals('bar', ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); $doc = new \DOMDocument("1.0"); $doc->loadXML(''); - $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => 'bar'), '::convertDomElementToArray() converts a \DomElement to an array'); + $this->assertEquals(array('foo' => 'bar'), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); $doc = new \DOMDocument("1.0"); $doc->loadXML('bar'); - $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => 'bar'), '::convertDomElementToArray() converts a \DomElement to an array'); + $this->assertEquals(array('foo' => 'bar'), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); $doc = new \DOMDocument("1.0"); $doc->loadXML('barbar'); - $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => array('value' => 'bar', 'foo' => 'bar')), '::convertDomElementToArray() converts a \DomElement to an array'); + $this->assertEquals(array('foo' => array('value' => 'bar', 'foo' => 'bar')), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); $doc = new \DOMDocument("1.0"); $doc->loadXML(''); - $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => null), '::convertDomElementToArray() converts a \DomElement to an array'); + $this->assertEquals(array('foo' => null), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); $doc = new \DOMDocument("1.0"); $doc->loadXML(''); - $this->assertEquals(ProjectLoader2::convertDomElementToArray($doc->documentElement), array('foo' => null), '::convertDomElementToArray() converts a \DomElement to an array'); + $this->assertEquals(array('foo' => null), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); } public function testExtensions() diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php index 6de3e76d0149a..ffda523b401b5 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php @@ -69,7 +69,7 @@ public function testLoadParameters() { $loader = new ProjectLoader3(self::$fixturesPath.'/yaml'); $config = $loader->load('services2.yml'); - $this->assertEquals($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'); + $this->assertEquals(array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), $config->getParameters(), '->load() converts YAML keys to lowercase'); } public function testLoadImports() @@ -79,7 +79,7 @@ public function testLoadImports() $actual = $config->getParameters(); $expected = array('foo' => 'bar', 'values' => array(true, false), 'bar' => '%foo%', 'foo_bar' => new Reference('foo_bar'), 'imported_from_ini' => true, 'imported_from_xml' => true); - $this->assertEquals(array_keys($actual), array_keys($expected), '->load() imports and merges imported files'); + $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); } public function testLoadServices() @@ -88,21 +88,21 @@ public function testLoadServices() $config = $loader->load('services6.yml'); $services = $config->getDefinitions(); $this->assertTrue(isset($services['foo']), '->load() parses service elements'); - $this->assertEquals(get_class($services['foo']), 'Symfony\\Components\\DependencyInjection\\Definition', '->load() converts service element to Definition instances'); - $this->assertEquals($services['foo']->getClass(), 'FooClass', '->load() parses the class attribute'); + $this->assertEquals('Symfony\\Components\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts service element to Definition instances'); + $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertTrue($services['shared']->isShared(), '->load() parses the shared attribute'); $this->assertTrue(!$services['non_shared']->isShared(), '->load() parses the shared attribute'); - $this->assertEquals($services['constructor']->getConstructor(), 'getInstance', '->load() parses the constructor attribute'); - $this->assertEquals($services['file']->getFile(), '%path%/foo.php', '->load() parses the file tag'); - $this->assertEquals($services['arguments']->getArguments(), array('foo', new Reference('foo'), array(true, false)), '->load() parses the argument tags'); - $this->assertEquals($services['configurator1']->getConfigurator(), 'sc_configure', '->load() parses the configurator tag'); - $this->assertEquals($services['configurator2']->getConfigurator(), array(new Reference('baz'), 'configure'), '->load() parses the configurator tag'); - $this->assertEquals($services['configurator3']->getConfigurator(), array('BazClass', 'configureStatic'), '->load() parses the configurator tag'); - $this->assertEquals($services['method_call1']->getMethodCalls(), array(array('setBar', array())), '->load() parses the method_call tag'); - $this->assertEquals($services['method_call2']->getMethodCalls(), array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), '->load() parses the method_call tag'); + $this->assertEquals('getInstance', $services['constructor']->getConstructor(), '->load() parses the constructor attribute'); + $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); + $this->assertEquals(array('foo', new Reference('foo'), array(true, false)), $services['arguments']->getArguments(), '->load() parses the argument tags'); + $this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag'); + $this->assertEquals(array(new Reference('baz'), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag'); + $this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag'); + $this->assertEquals(array(array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); + $this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag'); $aliases = $config->getAliases(); $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses aliases'); - $this->assertEquals($aliases['alias_for_foo'], 'foo', '->load() parses aliases'); + $this->assertEquals('foo', $aliases['alias_for_foo'], '->load() parses aliases'); } public function testExtensions() diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php index 39d79f479f5e0..b35c415d626e1 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php @@ -19,6 +19,6 @@ class ParameterTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $ref = new Parameter('foo'); - $this->assertEquals((string) $ref, 'foo', '__construct() sets the id of the parameter, which is used for the __toString() method'); + $this->assertEquals('foo', (string) $ref, '__construct() sets the id of the parameter, which is used for the __toString() method'); } } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php index 2528ae5a3d1e6..53959824cb775 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php @@ -19,6 +19,6 @@ class ReferenceTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $ref = new Reference('foo'); - $this->assertEquals((string) $ref, 'foo', '__construct() sets the id of the reference, which is used for the __toString() method'); + $this->assertEquals('foo', (string) $ref, '__construct() sets the id of the reference, which is used for the __toString() method'); } } diff --git a/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php b/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php index 62892ecb4aaa6..502812cb101ff 100644 --- a/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php +++ b/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php @@ -22,14 +22,14 @@ public function testConnectAndDisconnect() $dispatcher = new EventDispatcher(); $dispatcher->connect('bar', 'listenToBar'); - $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar'), '->connect() connects a listener to an event name'); + $this->assertEquals(array('listenToBar'), $dispatcher->getListeners('bar'), '->connect() connects a listener to an event name'); $dispatcher->connect('bar', 'listenToBarBar'); - $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar', 'listenToBarBar'), '->connect() can connect several listeners for the same event name'); + $this->assertEquals(array('listenToBar', 'listenToBarBar'), $dispatcher->getListeners('bar'), '->connect() can connect several listeners for the same event name'); $dispatcher->connect('barbar', 'listenToBarBar'); $dispatcher->disconnect('bar', 'listenToBarBar'); - $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar'), '->disconnect() disconnects a listener for an event name'); - $this->assertEquals($dispatcher->getListeners('barbar'), array('listenToBarBar'), '->disconnect() disconnects a listener for an event name'); + $this->assertEquals(array('listenToBar'), $dispatcher->getListeners('bar'), '->disconnect() disconnects a listener for an event name'); + $this->assertEquals(array('listenToBarBar'), $dispatcher->getListeners('barbar'), '->disconnect() disconnects a listener for an event name'); $this->assertTrue($dispatcher->disconnect('foobar', 'listen') === false, '->disconnect() returns false if the listener does not exist'); } @@ -38,15 +38,15 @@ public function testGetHasListeners() { $dispatcher = new EventDispatcher(); - $this->assertEquals($dispatcher->hasListeners('foo'), false, '->hasListeners() returns false if the event has no listener'); + $this->assertEquals(false, $dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener'); $dispatcher->connect('foo', 'listenToFoo'); - $this->assertEquals($dispatcher->hasListeners('foo'), true, '->hasListeners() returns true if the event has some listeners'); + $this->assertEquals(true, $dispatcher->hasListeners('foo'), '->hasListeners() returns true if the event has some listeners'); $dispatcher->disconnect('foo', 'listenToFoo'); - $this->assertEquals($dispatcher->hasListeners('foo'), false, '->hasListeners() returns false if the event has no listener'); + $this->assertEquals(false, $dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener'); $dispatcher->connect('bar', 'listenToBar'); - $this->assertEquals($dispatcher->getListeners('bar'), array('listenToBar'), '->getListeners() returns an array of listeners connected to the given event name'); - $this->assertEquals($dispatcher->getListeners('foobar'), array(), '->getListeners() returns an empty array if no listener are connected to the given event name'); + $this->assertEquals(array('listenToBar'), $dispatcher->getListeners('bar'), '->getListeners() returns an array of listeners connected to the given event name'); + $this->assertEquals(array(), $dispatcher->getListeners('foobar'), '->getListeners() returns an empty array if no listener are connected to the given event name'); } public function testNotify() @@ -56,15 +56,15 @@ public function testNotify() $dispatcher->connect('foo', array($listener, 'listenToFoo')); $dispatcher->connect('foo', array($listener, 'listenToFooBis')); $e = $dispatcher->notify($event = new Event(new \stdClass(), 'foo')); - $this->assertEquals($listener->getValue(), 'listenToFoolistenToFooBis', '->notify() notifies all registered listeners in order'); - $this->assertEquals($e, $event, '->notify() returns the event object'); + $this->assertEquals('listenToFoolistenToFooBis', $listener->getValue(), '->notify() notifies all registered listeners in order'); + $this->assertEquals($event, $e, '->notify() returns the event object'); $listener->reset(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'listenToFooBis')); $dispatcher->connect('foo', array($listener, 'listenToFoo')); $dispatcher->notify(new Event(new \stdClass(), 'foo')); - $this->assertEquals($listener->getValue(), 'listenToFooBislistenToFoo', '->notify() notifies all registered listeners in order'); + $this->assertEquals('listenToFooBislistenToFoo', $listener->getValue(), '->notify() notifies all registered listeners in order'); } public function testNotifyUntil() @@ -74,15 +74,15 @@ public function testNotifyUntil() $dispatcher->connect('foo', array($listener, 'listenToFoo')); $dispatcher->connect('foo', array($listener, 'listenToFooBis')); $e = $dispatcher->notifyUntil($event = new Event(new \stdClass(), 'foo')); - $this->assertEquals($listener->getValue(), 'listenToFoolistenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); - $this->assertEquals($e, $event, '->notifyUntil() returns the event object'); + $this->assertEquals('listenToFoolistenToFooBis', $listener->getValue(), '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); + $this->assertEquals($event, $e, '->notifyUntil() returns the event object'); $listener->reset(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'listenToFooBis')); $dispatcher->connect('foo', array($listener, 'listenToFoo')); $e = $dispatcher->notifyUntil($event = new Event(new \stdClass(), 'foo')); - $this->assertEquals($listener->getValue(), 'listenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); + $this->assertEquals('listenToFooBis', $listener->getValue(), '->notifyUntil() notifies all registered listeners in order and stops if it returns true'); } public function testFilter() @@ -92,15 +92,15 @@ public function testFilter() $dispatcher->connect('foo', array($listener, 'filterFoo')); $dispatcher->connect('foo', array($listener, 'filterFooBis')); $e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); - $this->assertEquals($e->getReturnValue(), '-*foo*-', '->filter() filters a value'); - $this->assertEquals($e, $event, '->filter() returns the event object'); + $this->assertEquals('-*foo*-', $e->getReturnValue(), '->filter() filters a value'); + $this->assertEquals($event, $e, '->filter() returns the event object'); $listener->reset(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'filterFooBis')); $dispatcher->connect('foo', array($listener, 'filterFoo')); $e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); - $this->assertEquals($e->getReturnValue(), '*-foo-*', '->filter() filters a value'); + $this->assertEquals('*-foo-*', $e->getReturnValue(), '->filter() filters a value'); } } diff --git a/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php b/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php index a1ff17764a4db..659cb955868dc 100644 --- a/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php +++ b/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php @@ -21,22 +21,23 @@ class EventTest extends \PHPUnit_Framework_TestCase public function testGetSubject() { - $this->assertEquals($this->createEvent()->getSubject(), $this->subject, '->getSubject() returns the event subject'); + $event = $this->createEvent(); + $this->assertEquals($this->subject, $event->getSubject(), '->getSubject() returns the event subject'); } public function testGetName() { - $this->assertEquals($this->createEvent()->getName(), 'name', '->getName() returns the event name'); + $this->assertEquals('name', $this->createEvent()->getName(), '->getName() returns the event name'); } public function testParameters() { $event = $this->createEvent(); - $this->assertEquals($event->getParameters(), $this->parameters, '->getParameters() returns the event parameters'); - $this->assertEquals($event->getParameter('foo'), 'bar', '->getParameter() returns the value of a parameter'); + $this->assertEquals($this->parameters, $event->getParameters(), '->getParameters() returns the event parameters'); + $this->assertEquals('bar', $event->getParameter('foo'), '->getParameter() returns the value of a parameter'); $event->setParameter('foo', 'foo'); - $this->assertEquals($event->getParameter('foo'), 'foo', '->setParameter() changes the value of a parameter'); + $this->assertEquals('foo', $event->getParameter('foo'), '->setParameter() changes the value of a parameter'); $this->assertTrue($event->hasParameter('foo'), '->hasParameter() returns true if the parameter is defined'); unset($event['foo']); $this->assertTrue(!$event->hasParameter('foo'), '->hasParameter() returns false if the parameter is not defined'); @@ -56,25 +57,25 @@ public function testSetGetReturnValue() { $event = $this->createEvent(); $event->setReturnValue('foo'); - $this->assertEquals($event->getReturnValue(), 'foo', '->getReturnValue() returns the return value of the event'); + $this->assertEquals('foo', $event->getReturnValue(), '->getReturnValue() returns the return value of the event'); } public function testSetIsProcessed() { $event = $this->createEvent(); $event->setProcessed(true); - $this->assertEquals($event->isProcessed(), true, '->isProcessed() returns true if the event has been processed'); + $this->assertEquals(true, $event->isProcessed(), '->isProcessed() returns true if the event has been processed'); $event->setProcessed(false); - $this->assertEquals($event->isProcessed(), false, '->setProcessed() changes the processed status'); + $this->assertEquals(false, $event->isProcessed(), '->setProcessed() changes the processed status'); } public function testArrayAccessInterface() { $event = $this->createEvent(); - $this->assertEquals($event['foo'], 'bar', 'Event implements the ArrayAccess interface'); + $this->assertEquals('bar', $event['foo'], 'Event implements the ArrayAccess interface'); $event['foo'] = 'foo'; - $this->assertEquals($event['foo'], 'foo', 'Event implements the ArrayAccess interface'); + $this->assertEquals('foo', $event['foo'], 'Event implements the ArrayAccess interface'); try { diff --git a/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php index e86e6e9d1c051..d9cbba90ae455 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php @@ -28,14 +28,14 @@ static public function setUpBeforeClass() public function testGetRaw() { - $this->assertEquals(self::$escaped->getRaw(0), 'escaped!', '->getRaw() returns the raw value'); + $this->assertEquals('escaped!', self::$escaped->getRaw(0), '->getRaw() returns the raw value'); } public function testArrayAccessInterface() { - $this->assertEquals(self::$escaped[0], '<strong>escaped!</strong>', 'The escaped object behaves like an array'); - $this->assertEquals(self::$escaped[2], null, 'The escaped object behaves like an array'); - $this->assertEquals(self::$escaped[3][1], '<strong>escaped!</strong>', 'The escaped object behaves like an array'); + $this->assertEquals('<strong>escaped!</strong>', self::$escaped[0], 'The escaped object behaves like an array'); + $this->assertEquals(null, self::$escaped[2], 'The escaped object behaves like an array'); + $this->assertEquals('<strong>escaped!</strong>', self::$escaped[3][1], 'The escaped object behaves like an array'); $this->assertTrue(isset(self::$escaped[1]), 'The escaped object behaves like an array (isset)'); @@ -67,13 +67,13 @@ public function testIteratorInterface() switch ($key) { case 0: - $this->assertEquals($value, '<strong>escaped!</strong>', 'The escaped object behaves like an array'); + $this->assertEquals('<strong>escaped!</strong>', $value, 'The escaped object behaves like an array'); break; case 1: - $this->assertEquals($value, 1, 'The escaped object behaves like an array'); + $this->assertEquals(1, $value, 'The escaped object behaves like an array'); break; case 2: - $this->assertEquals($value, null, 'The escaped object behaves like an array'); + $this->assertEquals(null, $value, 'The escaped object behaves like an array'); break; case 3: break; @@ -85,6 +85,6 @@ public function testIteratorInterface() public function testCountableInterface() { - $this->assertEquals(count(self::$escaped), 4, 'The escaped object implements the Countable interface'); + $this->assertEquals(4, count(self::$escaped), 'The escaped object implements the Countable interface'); } } diff --git a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php index c63cba990fd42..fea856c80bdc0 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php @@ -30,13 +30,13 @@ public function testEscapeDoesNotEscapeSpecialValues() public function testEscapeDoesNotEscapeAValueWhenEscapingMethodIsRAW() { - $this->assertEquals(Escaper::escape('raw', 'escaped!'), 'escaped!', '::escape() takes an escaping strategy function name as its first argument'); + $this->assertEquals('escaped!', Escaper::escape('raw', 'escaped!'), '::escape() takes an escaping strategy function name as its first argument'); } public function testEscapeEscapesStrings() { - $this->assertEquals(Escaper::escape('entities', 'escaped!'), '<strong>escaped!</strong>', '::escape() returns an escaped string if the value to escape is a string'); - $this->assertEquals(Escaper::escape('entities', 'échappé'), '<strong>échappé</strong>', '::escape() returns an escaped string if the value to escape is a string'); + $this->assertEquals('<strong>escaped!</strong>', Escaper::escape('entities', 'escaped!'), '::escape() returns an escaped string if the value to escape is a string'); + $this->assertEquals('<strong>échappé</strong>', Escaper::escape('entities', 'échappé'), '::escape() returns an escaped string if the value to escape is a string'); } public function testEscapeEscapesArrays() @@ -47,9 +47,9 @@ public function testEscapeEscapesArrays() ); $output = Escaper::escape('entities', $input); $this->assertTrue($output instanceof ArrayDecorator, '::escape() returns a ArrayDecorator object if the value to escape is an array'); - $this->assertEquals($output['foo'], '<strong>escaped!</strong>', '::escape() escapes all elements of the original array'); - $this->assertEquals($output['bar']['foo'], '<strong>escaped!</strong>', '::escape() is recursive'); - $this->assertEquals($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); + $this->assertEquals('<strong>escaped!</strong>', $output['foo'], '::escape() escapes all elements of the original array'); + $this->assertEquals('<strong>escaped!</strong>', $output['bar']['foo'], '::escape() is recursive'); + $this->assertEquals($input, $output->getRawValue(), '->getRawValue() returns the unescaped value'); } public function testEscapeEscapesObjects() @@ -57,12 +57,12 @@ public function testEscapeEscapesObjects() $input = new OutputEscaperTestClass(); $output = Escaper::escape('entities', $input); $this->assertTrue($output instanceof ObjectDecorator, '::escape() returns a ObjectDecorator object if the value to escape is an object'); - $this->assertEquals($output->getTitle(), '<strong>escaped!</strong>', '::escape() escapes all methods of the original object'); - $this->assertEquals($output->title, '<strong>escaped!</strong>', '::escape() escapes all properties of the original object'); - $this->assertEquals($output->getTitleTitle(), '<strong>escaped!</strong>', '::escape() is recursive'); - $this->assertEquals($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); + $this->assertEquals('<strong>escaped!</strong>', $output->getTitle(), '::escape() escapes all methods of the original object'); + $this->assertEquals('<strong>escaped!</strong>', $output->title, '::escape() escapes all properties of the original object'); + $this->assertEquals('<strong>escaped!</strong>', $output->getTitleTitle(), '::escape() is recursive'); + $this->assertEquals($input, $output->getRawValue(), '->getRawValue() returns the unescaped value'); - $this->assertEquals(Escaper::escape('entities', $output)->getTitle(), '<strong>escaped!</strong>', '::escape() does not double escape an object'); + $this->assertEquals('<strong>escaped!</strong>', Escaper::escape('entities', $output)->getTitle(), '::escape() does not double escape an object'); $this->assertTrue(Escaper::escape('entities', new \DirectoryIterator('.')) instanceof IteratorDecorator, '::escape() returns a IteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface'); } @@ -99,8 +99,8 @@ public function testUnescapeDoesNotUnescapeSpecialValues() public function testUnescapeUnescapesStrings() { - $this->assertEquals(Escaper::unescape('<strong>escaped!</strong>'), 'escaped!', '::unescape() returns an unescaped string if the value to unescape is a string'); - $this->assertEquals(Escaper::unescape('<strong>échappé</strong>'), 'échappé', '::unescape() returns an unescaped string if the value to unescape is a string'); + $this->assertEquals('escaped!', Escaper::unescape('<strong>escaped!</strong>'), '::unescape() returns an unescaped string if the value to unescape is a string'); + $this->assertEquals('échappé', Escaper::unescape('<strong>échappé</strong>'), '::unescape() returns an unescaped string if the value to unescape is a string'); } public function testUnescapeUnescapesArrays() @@ -111,8 +111,8 @@ public function testUnescapeUnescapesArrays() )); $output = Escaper::unescape($input); $this->assertTrue(is_array($output), '::unescape() returns an array if the input is a ArrayDecorator object'); - $this->assertEquals($output['foo'], 'escaped!', '::unescape() unescapes all elements of the original array'); - $this->assertEquals($output['bar']['foo'], 'escaped!', '::unescape() is recursive'); + $this->assertEquals('escaped!', $output['foo'], '::unescape() unescapes all elements of the original array'); + $this->assertEquals('escaped!', $output['bar']['foo'], '::unescape() is recursive'); } public function testUnescapeUnescapesObjects() @@ -121,9 +121,9 @@ public function testUnescapeUnescapesObjects() $input = Escaper::escape('entities', $object); $output = Escaper::unescape($input); $this->assertTrue($output instanceof OutputEscaperTestClass, '::unescape() returns the original object when a ObjectDecorator object is passed'); - $this->assertEquals($output->getTitle(), 'escaped!', '::unescape() unescapes all methods of the original object'); - $this->assertEquals($output->title, 'escaped!', '::unescape() unescapes all properties of the original object'); - $this->assertEquals($output->getTitleTitle(), 'escaped!', '::unescape() is recursive'); + $this->assertEquals('escaped!', $output->getTitle(), '::unescape() unescapes all methods of the original object'); + $this->assertEquals('escaped!', $output->title, '::unescape() unescapes all properties of the original object'); + $this->assertEquals('escaped!', $output->getTitleTitle(), '::unescape() is recursive'); $this->assertTrue(IteratorDecorator::unescape(Escaper::escape('entities', new \DirectoryIterator('.'))) instanceof \DirectoryIterator, '::unescape() unescapes IteratorDecorator objects'); } @@ -140,7 +140,7 @@ public function testUnescapeDoesNotUnescapeObjectMarkedAsBeingSafe() public function testUnescapeDoesNothingToResources() { $fh = fopen(__FILE__, 'r'); - $this->assertEquals(Escaper::unescape($fh), $fh, '::unescape() do nothing to resources'); + $this->assertEquals($fh, Escaper::unescape($fh), '::unescape() do nothing to resources'); } public function testUnescapeUnescapesMixedArrays() @@ -156,7 +156,7 @@ public function testUnescapeUnescapesMixedArrays() 'bar' => 'bar', 'foobar' => $object, ); - $this->assertEquals(Escaper::unescape($input), $output, '::unescape() unescapes values with some escaped and unescaped values'); + $this->assertEquals($output, Escaper::unescape($input), '::unescape() unescapes values with some escaped and unescaped values'); } } diff --git a/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php index c269ea63e5c0d..620b259030914 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php @@ -28,15 +28,15 @@ static public function setUpBeforeClass() public function testGenericBehavior() { - $this->assertEquals(self::$escaped->getTitle(), '<strong>escaped!</strong>', 'The escaped object behaves like the real object'); + $this->assertEquals('<strong>escaped!</strong>', self::$escaped->getTitle(), 'The escaped object behaves like the real object'); $array = self::$escaped->getTitles(); - $this->assertEquals($array[2], '<strong>escaped!</strong>', 'The escaped object behaves like the real object'); + $this->assertEquals('<strong>escaped!</strong>', $array[2], 'The escaped object behaves like the real object'); } public function testMagicToString() { - $this->assertEquals(self::$escaped->__toString(), '<strong>escaped!</strong>', 'The escaped object behaves like the real object'); + $this->assertEquals('<strong>escaped!</strong>', self::$escaped->__toString(), 'The escaped object behaves like the real object'); } } diff --git a/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php index 97c91718d6966..a87a7654bd240 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php @@ -20,35 +20,35 @@ class SafeDecoratorTest extends \PHPUnit_Framework_TestCase public function testGetValue() { $safe = new SafeDecorator('foo'); - $this->assertEquals($safe->getValue(), 'foo', '->getValue() returns the embedded value'); + $this->assertEquals('foo', $safe->getValue(), '->getValue() returns the embedded value'); } public function testMagicGetAndSet() { $safe = new SafeDecorator(new TestClass1()); - $this->assertEquals($safe->foo, 'bar', '->__get() returns the object parameter'); + $this->assertEquals('bar', $safe->foo, '->__get() returns the object parameter'); $safe->foo = 'baz'; - $this->assertEquals($safe->foo, 'baz', '->__set() sets the object parameter'); + $this->assertEquals('baz', $safe->foo, '->__set() sets the object parameter'); } public function testMagicCall() { $safe = new SafeDecorator(new TestClass2()); - $this->assertEquals($safe->doSomething(), 'ok', '->__call() invokes the embedded method'); + $this->assertEquals('ok', $safe->doSomething(), '->__call() invokes the embedded method'); } public function testMagicIssetAndUnset() { $safe = new SafeDecorator(new TestClass3()); - $this->assertEquals(isset($safe->boolValue), true, '->__isset() returns true if the property is not null'); - $this->assertEquals(isset($safe->nullValue), false, '->__isset() returns false if the property is null'); - $this->assertEquals(isset($safe->undefinedValue), false, '->__isset() returns false if the property does not exist'); + $this->assertEquals(true, isset($safe->boolValue), '->__isset() returns true if the property is not null'); + $this->assertEquals(false, isset($safe->nullValue), '->__isset() returns false if the property is null'); + $this->assertEquals(false, isset($safe->undefinedValue), '->__isset() returns false if the property does not exist'); unset($safe->boolValue); - $this->assertEquals(isset($safe->boolValue), false, '->__unset() unsets the embedded property'); + $this->assertEquals(false, isset($safe->boolValue), '->__unset() unsets the embedded property'); } public function testIteratorInterface() @@ -68,12 +68,12 @@ public function testArrayAccessIterator() { $safe = new SafeDecorator(array('foo' => 'bar')); - $this->assertEquals($safe['foo'], 'bar', '"ArrayAccess" implementation returns a value from the embedded array'); + $this->assertEquals('bar', $safe['foo'], '"ArrayAccess" implementation returns a value from the embedded array'); $safe['foo'] = 'baz'; - $this->assertEquals($safe['foo'], 'baz', '"ArrayAccess" implementation sets a value on the embedded array'); - $this->assertEquals(isset($safe['foo']), true, '"ArrayAccess" checks if a value is set on the embedded array'); + $this->assertEquals('baz', $safe['foo'], '"ArrayAccess" implementation sets a value on the embedded array'); + $this->assertEquals(true, isset($safe['foo']), '"ArrayAccess" checks if a value is set on the embedded array'); unset($safe['foo']); - $this->assertEquals(isset($safe['foo']), false, '"ArrayAccess" unsets a value on the embedded array'); + $this->assertEquals(false, isset($safe['foo']), '"ArrayAccess" unsets a value on the embedded array'); } } diff --git a/tests/Symfony/Tests/Components/Templating/EngineTest.php b/tests/Symfony/Tests/Components/Templating/EngineTest.php index 7f2629229f455..0857728173ea9 100644 --- a/tests/Symfony/Tests/Components/Templating/EngineTest.php +++ b/tests/Symfony/Tests/Components/Templating/EngineTest.php @@ -37,11 +37,11 @@ static public function setUpBeforeClass() public function testConstructor() { $engine = new ProjectTemplateEngine(self::$loader); - $this->assertEquals($engine->getLoader(), self::$loader, '__construct() takes a loader instance as its second first argument'); - $this->assertEquals(array_keys($engine->getRenderers()), array('php'), '__construct() automatically registers a PHP renderer if none is given'); + $this->assertEquals(self::$loader, $engine->getLoader(), '__construct() takes a loader instance as its second first argument'); + $this->assertEquals(array('php'), array_keys($engine->getRenderers()), '__construct() automatically registers a PHP renderer if none is given'); $engine = new ProjectTemplateEngine(self::$loader, array('foo' => self::$renderer)); - $this->assertEquals(array_keys($engine->getRenderers()), array('foo', 'php'), '__construct() takes an array of renderers as its third argument'); + $this->assertEquals(array('foo', 'php'), array_keys($engine->getRenderers()), '__construct() takes an array of renderers as its third argument'); $this->assertTrue(self::$renderer->getEngine() === $engine, '__construct() registers itself on all renderers'); $engine = new ProjectTemplateEngine(self::$loader, array('php' => self::$renderer)); @@ -52,7 +52,7 @@ public function testMagicGet() { $engine = new ProjectTemplateEngine(self::$loader); $engine->set($helper = new \SimpleHelper('bar'), 'foo'); - $this->assertEquals($engine->foo, $helper, '->__get() returns the value of a helper'); + $this->assertEquals($helper, $engine->foo, '->__get() returns the value of a helper'); try { @@ -69,10 +69,10 @@ public function testGetSetHas() $engine = new ProjectTemplateEngine(self::$loader); $foo = new \SimpleHelper('foo'); $engine->set($foo); - $this->assertEquals($engine->get('foo'), $foo, '->set() sets a helper'); + $this->assertEquals($foo, $engine->get('foo'), '->set() sets a helper'); $engine->set($foo, 'bar'); - $this->assertEquals($engine->get('bar'), $foo, '->set() takes an alias as a second argument'); + $this->assertEquals($foo, $engine->get('bar'), '->set() takes an alias as a second argument'); try { @@ -113,33 +113,34 @@ public function testExtendRender() $engine->set(new \SimpleHelper('bar')); self::$loader->setTemplate('foo.php', 'extend("layout"); echo $view->foo.$foo ?>'); self::$loader->setTemplate('layout.php', '-slots->get("_content") ?>-'); - $this->assertEquals($engine->render('foo', array('foo' => 'foo')), '-barfoo-', '->render() uses the decorator to decorate the template'); + $this->assertEquals('-barfoo-', $engine->render('foo', array('foo' => 'foo')), '->render() uses the decorator to decorate the template'); $engine = new ProjectTemplateEngine(self::$loader, array(), array(new SlotsHelper())); $engine->set(new \SimpleHelper('bar')); self::$loader->setTemplate('bar.php', 'bar'); self::$loader->setTemplate('foo.php', 'extend("layout"); echo $foo ?>'); self::$loader->setTemplate('layout.php', 'render("bar") ?>-slots->get("_content") ?>-'); - $this->assertEquals($engine->render('foo', array('foo' => 'foo', 'bar' => 'bar')), 'bar-foo-', '->render() supports render() calls in templates'); + $this->assertEquals('bar-foo-', $engine->render('foo', array('foo' => 'foo', 'bar' => 'bar')), '->render() supports render() calls in templates'); // compilable templates $engine = new ProjectTemplateEngine(new CompilableTemplateLoader(), array('foo' => new FooTemplateRenderer())); - $this->assertEquals($engine->render('index'), 'foo', '->load() takes into account the renderer embedded in the Storage instance if not null'); + $this->assertEquals('foo', $engine->render('index'), '->load() takes into account the renderer embedded in the Storage instance if not null'); } public function testEscape() { $engine = new ProjectTemplateEngine(self::$loader); - $this->assertEquals($engine->escape('
'), '<br />', '->escape() escapes strings'); - $this->assertEquals($engine->escape($foo = new \stdClass()), $foo, '->escape() does nothing on non strings'); + $this->assertEquals('<br />', $engine->escape('
'), '->escape() escapes strings'); + $foo = new \stdClass(); + $this->assertEquals($foo, $engine->escape($foo), '->escape() does nothing on non strings'); } public function testGetSetCharset() { $engine = new ProjectTemplateEngine(self::$loader); - $this->assertEquals($engine->getCharset(), 'UTF-8', '->getCharset() returns UTF-8 by default'); + $this->assertEquals('UTF-8', $engine->getCharset(), '->getCharset() returns UTF-8 by default'); $engine->setCharset('ISO-8859-1'); - $this->assertEquals($engine->getCharset(), 'ISO-8859-1', '->setCharset() changes the default charset to use'); + $this->assertEquals('ISO-8859-1', $engine->getCharset(), '->setCharset() changes the default charset to use'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php index 16f135ddfad83..167fea6e9d349 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php @@ -20,36 +20,36 @@ class AssetsHelperTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $helper = new AssetsHelper('foo', 'http://www.example.com', 'abcd'); - $this->assertEquals($helper->getBasePath(), '/foo/', '__construct() takes a base path as its first argument'); - $this->assertEquals($helper->getBaseURLs(), array('http://www.example.com'), '__construct() takes a base URL as its second argument'); - $this->assertEquals($helper->getVersion(), 'abcd', '__construct() takes a version as its thrid argument'); + $this->assertEquals('/foo/', $helper->getBasePath(), '__construct() takes a base path as its first argument'); + $this->assertEquals(array('http://www.example.com'), $helper->getBaseURLs(), '__construct() takes a base URL as its second argument'); + $this->assertEquals('abcd', $helper->getVersion(), '__construct() takes a version as its thrid argument'); } public function testGetSetBasePath() { $helper = new AssetsHelper(); $helper->setBasePath('foo/'); - $this->assertEquals($helper->getBasePath(), '/foo/', '->setBasePath() prepends a / if needed'); + $this->assertEquals('/foo/', $helper->getBasePath(), '->setBasePath() prepends a / if needed'); $helper->setBasePath('/foo'); - $this->assertEquals($helper->getBasePath(), '/foo/', '->setBasePath() appends a / is needed'); + $this->assertEquals('/foo/', $helper->getBasePath(), '->setBasePath() appends a / is needed'); $helper->setBasePath(''); - $this->assertEquals($helper->getBasePath(), '/', '->setBasePath() returns / if no base path is defined'); + $this->assertEquals('/', $helper->getBasePath(), '->setBasePath() returns / if no base path is defined'); $helper->setBasePath('0'); - $this->assertEquals($helper->getBasePath(), '/0/', '->setBasePath() returns /0/ if 0 is given'); + $this->assertEquals('/0/', $helper->getBasePath(), '->setBasePath() returns /0/ if 0 is given'); } public function testGetSetVersion() { $helper = new AssetsHelper(); $helper->setVersion('foo'); - $this->assertEquals($helper->getVersion(), 'foo', '->setVersion() sets the version'); + $this->assertEquals('foo', $helper->getVersion(), '->setVersion() sets the version'); } public function testSetGetBaseURLs() { $helper = new AssetsHelper(); $helper->setBaseURLs('http://www.example.com/'); - $this->assertEquals($helper->getBaseURLs(), array('http://www.example.com'), '->setBaseURLs() removes the / at the of an absolute base path'); + $this->assertEquals(array('http://www.example.com'), $helper->getBaseURLs(), '->setBaseURLs() removes the / at the of an absolute base path'); $helper->setBaseURLs(array('http://www1.example.com/', 'http://www2.example.com/')); $URLs = array(); for ($i = 0; $i < 20; $i++) @@ -58,41 +58,41 @@ public function testSetGetBaseURLs() } $URLs = array_values(array_unique($URLs)); sort($URLs); - $this->assertEquals($URLs, array('http://www1.example.com', 'http://www2.example.com'), '->getBaseURL() returns a random base URL if several are given'); + $this->assertEquals(array('http://www1.example.com', 'http://www2.example.com'), $URLs, '->getBaseURL() returns a random base URL if several are given'); $helper->setBaseURLs(''); - $this->assertEquals($helper->getBaseURL(1), '', '->getBaseURL() returns an empty string if no base URL exist'); + $this->assertEquals('', $helper->getBaseURL(1), '->getBaseURL() returns an empty string if no base URL exist'); } public function testGetUrl() { $helper = new AssetsHelper(); - $this->assertEquals($helper->getUrl('http://example.com/foo.js'), 'http://example.com/foo.js', '->getUrl() does nothing if an absolute URL is given'); + $this->assertEquals('http://example.com/foo.js', $helper->getUrl('http://example.com/foo.js'), '->getUrl() does nothing if an absolute URL is given'); $helper = new AssetsHelper(); - $this->assertEquals($helper->getUrl('foo.js'), '/foo.js', '->getUrl() appends a / on relative paths'); - $this->assertEquals($helper->getUrl('/foo.js'), '/foo.js', '->getUrl() does nothing on absolute paths'); + $this->assertEquals('/foo.js', $helper->getUrl('foo.js'), '->getUrl() appends a / on relative paths'); + $this->assertEquals('/foo.js', $helper->getUrl('/foo.js'), '->getUrl() does nothing on absolute paths'); $helper = new AssetsHelper('/foo'); - $this->assertEquals($helper->getUrl('foo.js'), '/foo/foo.js', '->getUrl() appends the basePath on relative paths'); - $this->assertEquals($helper->getUrl('/foo.js'), '/foo.js', '->getUrl() does not append the basePath on absolute paths'); + $this->assertEquals('/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() appends the basePath on relative paths'); + $this->assertEquals('/foo.js', $helper->getUrl('/foo.js'), '->getUrl() does not append the basePath on absolute paths'); $helper = new AssetsHelper(null, 'http://assets.example.com/'); - $this->assertEquals($helper->getUrl('foo.js'), 'http://assets.example.com/foo.js', '->getUrl() prepends the base URL'); - $this->assertEquals($helper->getUrl('/foo.js'), 'http://assets.example.com/foo.js', '->getUrl() prepends the base URL'); + $this->assertEquals('http://assets.example.com/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL'); + $this->assertEquals('http://assets.example.com/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL'); $helper = new AssetsHelper(null, 'http://www.example.com/foo'); - $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL with a path'); - $this->assertEquals($helper->getUrl('/foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL with a path'); + $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL with a path'); + $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL with a path'); $helper = new AssetsHelper('/foo', 'http://www.example.com/'); - $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL and the base path if defined'); - $this->assertEquals($helper->getUrl('/foo.js'), 'http://www.example.com/foo.js', '->getUrl() prepends the base URL but not the base path on absolute paths'); + $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL and the base path if defined'); + $this->assertEquals('http://www.example.com/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL but not the base path on absolute paths'); $helper = new AssetsHelper('/bar', 'http://www.example.com/foo'); - $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/bar/foo.js', '->getUrl() prepends the base URL and the base path if defined'); - $this->assertEquals($helper->getUrl('/foo.js'), 'http://www.example.com/foo/foo.js', '->getUrl() prepends the base URL but not the base path on absolute paths'); + $this->assertEquals('http://www.example.com/foo/bar/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL and the base path if defined'); + $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL but not the base path on absolute paths'); $helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd'); - $this->assertEquals($helper->getUrl('foo.js'), 'http://www.example.com/foo/bar/foo.js?abcd', '->getUrl() appends the version if defined'); + $this->assertEquals('http://www.example.com/foo/bar/foo.js?abcd', $helper->getUrl('foo.js'), '->getUrl() appends the version if defined'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php index 667bb88c473a3..35e57d3a4d041 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php @@ -24,13 +24,13 @@ public function testAdd() $assetHelper = new AssetsHelper(); $helper = new JavascriptsHelper($assetHelper); $helper->add('foo'); - $this->assertEquals($helper->get(), array('/foo' => array()), '->add() adds a JavaScript'); + $this->assertEquals(array('/foo' => array()), $helper->get(), '->add() adds a JavaScript'); $helper->add('/foo'); - $this->assertEquals($helper->get(), array('/foo' => array()), '->add() does not add the same JavaScript twice'); + $this->assertEquals(array('/foo' => array()), $helper->get(), '->add() does not add the same JavaScript twice'); $helper = new JavascriptsHelper($assetHelper); $assetHelper->setBaseURLs('http://assets.example.com/'); $helper->add('foo'); - $this->assertEquals($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the JavaScript to a public path'); + $this->assertEquals(array('http://assets.example.com/foo' => array()), $helper->get(), '->add() converts the JavaScript to a public path'); } public function testMagicToString() @@ -39,6 +39,6 @@ public function testMagicToString() $assetHelper->setBaseURLs(''); $helper = new JavascriptsHelper($assetHelper); $helper->add('foo', array('class' => 'ba>')); - $this->assertEquals($helper->__toString(), ''."\n", '->__toString() converts the JavaScript configuration to HTML'); + $this->assertEquals(''."\n", $helper->__toString(), '->__toString() converts the JavaScript configuration to HTML'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php index 4d1f8ef2aad41..405d7b6649de3 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php @@ -21,8 +21,8 @@ public function testHasGetSet() { $helper = new SlotsHelper(); $helper->set('foo', 'bar'); - $this->assertEquals($helper->get('foo'), 'bar', '->set() sets a slot value'); - $this->assertEquals($helper->get('bar', 'bar'), 'bar', '->get() takes a default value to return if the slot does not exist'); + $this->assertEquals('bar', $helper->get('foo'), '->set() sets a slot value'); + $this->assertEquals('bar', $helper->get('bar', 'bar'), '->get() takes a default value to return if the slot does not exist'); $this->assertTrue($helper->has('foo'), '->has() returns true if the slot exists'); $this->assertTrue(!$helper->has('bar'), '->has() returns false if the slot does not exist'); @@ -35,20 +35,20 @@ public function testOutput() ob_start(); $ret = $helper->output('foo'); $output = ob_get_clean(); - $this->assertEquals($output, 'bar', '->output() outputs the content of a slot'); - $this->assertEquals($ret, true, '->output() returns true if the slot exists'); + $this->assertEquals('bar', $output, '->output() outputs the content of a slot'); + $this->assertEquals(true, $ret, '->output() returns true if the slot exists'); ob_start(); $ret = $helper->output('bar', 'bar'); $output = ob_get_clean(); - $this->assertEquals($output, 'bar', '->output() takes a default value to return if the slot does not exist'); - $this->assertEquals($ret, true, '->output() returns true if the slot does not exist but a default value is provided'); + $this->assertEquals('bar', $output, '->output() takes a default value to return if the slot does not exist'); + $this->assertEquals(true, $ret, '->output() returns true if the slot does not exist but a default value is provided'); ob_start(); $ret = $helper->output('bar'); $output = ob_get_clean(); - $this->assertEquals($output, '', '->output() outputs nothing if the slot does not exist'); - $this->assertEquals($ret, false, '->output() returns false if the slot does not exist'); + $this->assertEquals('', $output, '->output() outputs nothing if the slot does not exist'); + $this->assertEquals(false, $ret, '->output() returns false if the slot does not exist'); } public function testStartStop() @@ -57,7 +57,7 @@ public function testStartStop() $helper->start('bar'); echo 'foo'; $helper->stop(); - $this->assertEquals($helper->get('bar'), 'foo', '->start() starts a slot'); + $this->assertEquals('foo', $helper->get('bar'), '->start() starts a slot'); $this->assertTrue($helper->has('bar'), '->starts() starts a slot'); $helper->start('bar'); diff --git a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php index 16fd096da0fb7..d23ba2794ff04 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php @@ -24,13 +24,13 @@ public function testAdd() $assetHelper = new AssetsHelper(); $helper = new StylesheetsHelper($assetHelper); $helper->add('foo'); - $this->assertEquals($helper->get(), array('/foo' => array()), '->add() adds a stylesheet'); + $this->assertEquals(array('/foo' => array()), $helper->get(), '->add() adds a stylesheet'); $helper->add('/foo'); - $this->assertEquals($helper->get(), array('/foo' => array()), '->add() does not add the same stylesheet twice'); + $this->assertEquals(array('/foo' => array()), $helper->get(), '->add() does not add the same stylesheet twice'); $helper = new StylesheetsHelper($assetHelper); $assetHelper->setBaseURLs('http://assets.example.com/'); $helper->add('foo'); - $this->assertEquals($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the stylesheet to a public path'); + $this->assertEquals(array('http://assets.example.com/foo' => array()), $helper->get(), '->add() converts the stylesheet to a public path'); } public function testMagicToString() @@ -39,6 +39,6 @@ public function testMagicToString() $assetHelper->setBaseURLs(''); $helper = new StylesheetsHelper($assetHelper); $helper->add('foo', array('media' => 'ba>')); - $this->assertEquals($helper->__toString(), ''."\n", '->__toString() converts the stylesheet configuration to HTML'); + $this->assertEquals(''."\n", $helper->__toString(), '->__toString() converts the stylesheet configuration to HTML'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php index 358a02563d99c..6cc6bfe6e381b 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php @@ -26,7 +26,7 @@ public function testConstructor() { $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), sys_get_temp_dir()); $this->assertTrue($loader->getLoader() === $varLoader, '__construct() takes a template loader as its first argument'); - $this->assertEquals($loader->getDir(), sys_get_temp_dir(), '__construct() takes a directory where to store the cache as its second argument'); + $this->assertEquals(sys_get_temp_dir(), $loader->getDir(), '__construct() takes a directory where to store the cache as its second argument'); } public function testLoad() @@ -50,11 +50,11 @@ public function testLoad() $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); $template = $loader->load('special', array('renderer' => 'comp')); $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); - $this->assertEquals($template->getRenderer(), 'php', '->load() changes the renderer to php if the template is compilable'); + $this->assertEquals('php', $template->getRenderer(), '->load() changes the renderer to php if the template is compilable'); $template = $loader->load('special', array('renderer' => 'comp')); $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); - $this->assertEquals($template->getRenderer(), 'php', '->load() changes the renderer to php if the template is compilable'); + $this->assertEquals('php', $template->getRenderer(), '->load() changes the renderer to php if the template is compilable'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php index 75e66b46b017a..1babe43cbd98c 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php @@ -33,14 +33,14 @@ static public function setUpBeforeClass() public function testConstructor() { $loader = new ProjectTemplateLoader1(array(self::$loader1, self::$loader2)); - $this->assertEquals($loader->getLoaders(), array(self::$loader1, self::$loader2), '__construct() takes an array of template loaders as its second argument'); + $this->assertEquals(array(self::$loader1, self::$loader2), $loader->getLoaders(), '__construct() takes an array of template loaders as its second argument'); } public function testAddLoader() { $loader = new ProjectTemplateLoader1(array(self::$loader1)); $loader->addLoader(self::$loader2); - $this->assertEquals($loader->getLoaders(), array(self::$loader1, self::$loader2), '->addLoader() adds a template loader at the end of the loaders'); + $this->assertEquals(array(self::$loader1, self::$loader2), $loader->getLoaders(), '->addLoader() adds a template loader at the end of the loaders'); } public function testLoad() diff --git a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php index 0619838990b55..1f69894e7ac21 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php @@ -32,9 +32,9 @@ public function testConstructor() $pathPattern = self::$fixturesPath.'/templates/%name%.%renderer%'; $path = self::$fixturesPath.'/templates'; $loader = new ProjectTemplateLoader2($pathPattern); - $this->assertEquals($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes a path as its second argument'); + $this->assertEquals(array($pathPattern), $loader->getTemplatePathPatterns(), '__construct() takes a path as its second argument'); $loader = new ProjectTemplateLoader2(array($pathPattern)); - $this->assertEquals($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes an array of paths as its second argument'); + $this->assertEquals(array($pathPattern), $loader->getTemplatePathPatterns(), '__construct() takes an array of paths as its second argument'); } public function testIsAbsolutePath() @@ -52,13 +52,13 @@ public function testLoad() $loader = new ProjectTemplateLoader2($pathPattern); $storage = $loader->load($path.'/foo.php'); $this->assertTrue($storage instanceof FileStorage, '->load() returns a FileStorage if you pass an absolute path'); - $this->assertEquals((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the passed absolute path'); + $this->assertEquals($path.'/foo.php', (string) $storage, '->load() returns a FileStorage pointing to the passed absolute path'); $this->assertTrue($loader->load('bar') === false, '->load() returns false if the template is not found'); $storage = $loader->load('foo'); $this->assertTrue($storage instanceof FileStorage, '->load() returns a FileStorage if you pass a relative template that exists'); - $this->assertEquals((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the absolute path of the template'); + $this->assertEquals($path.'/foo.php', (string) $storage, '->load() returns a FileStorage pointing to the absolute path of the template'); $loader = new ProjectTemplateLoader2($pathPattern); $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); diff --git a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php index 73a35c48deaed..285fe7d8fd2dd 100644 --- a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php +++ b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php @@ -25,9 +25,9 @@ public function testEvaluate() $renderer = new PhpRenderer(); $template = new StringStorage(''); - $this->assertEquals($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of StringStorage'); + $this->assertEquals('bar', $renderer->evaluate($template, array('foo' => 'bar')), '->evaluate() renders templates that are instances of StringStorage'); $template = new FileStorage(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/templates/foo.php'); - $this->assertEquals($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of FileStorage'); + $this->assertEquals('bar', $renderer->evaluate($template, array('foo' => 'bar')), '->evaluate() renders templates that are instances of FileStorage'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php index 16b1e8877612c..d462262313152 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php @@ -23,6 +23,6 @@ public function testGetContent() $storage = new FileStorage('foo'); $this->assertTrue($storage instanceof Storage, 'FileStorage is an instance of Storage'); $storage = new FileStorage(__DIR__.'/../../../../../fixtures/Symfony/Components/Templating/templates/foo.php'); - $this->assertEquals($storage->getContent(), '', '->getContent() returns the content of the template'); + $this->assertEquals('', $storage->getContent(), '->getContent() returns the content of the template'); } } diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php index 544c468ce0199..8c7c67ae1264b 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php @@ -21,7 +21,7 @@ class StorageTest extends \PHPUnit_Framework_TestCase public function testMagicToString() { $storage = new TestStorage('foo'); - $this->assertEquals((string) $storage, 'foo', '__toString() returns the template name'); + $this->assertEquals('foo', (string) $storage, '__toString() returns the template name'); } public function testGetRenderer() diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php index ed1cf095ca44a..ce63cbbb617e9 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php @@ -23,6 +23,6 @@ public function testGetContent() $storage = new StringStorage('foo'); $this->assertTrue($storage instanceof Storage, 'StringStorage is an instance of Storage'); $storage = new StringStorage('foo'); - $this->assertEquals($storage->getContent(), 'foo', '->getContent() returns the content of the template'); + $this->assertEquals('foo', $storage->getContent(), '->getContent() returns the content of the template'); } } diff --git a/tests/Symfony/Tests/Components/Yaml/DumperTest.php b/tests/Symfony/Tests/Components/Yaml/DumperTest.php index 7220e182dafb1..5e8a84bf57f41 100644 --- a/tests/Symfony/Tests/Components/Yaml/DumperTest.php +++ b/tests/Symfony/Tests/Components/Yaml/DumperTest.php @@ -62,7 +62,7 @@ public function testSpecifications() { $expected = eval('return '.trim($test['php']).';'); - $this->assertEquals($this->parser->parse($this->dumper->dump($expected, 10)), $expected, $test['test']); + $this->assertEquals($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']); } } } @@ -89,8 +89,8 @@ public function testInlineLevel() $expected = <<assertEquals($this->dumper->dump($array, -10), $expected, '->dump() takes an inline level argument'); -$this->assertEquals($this->dumper->dump($array, 0), $expected, '->dump() takes an inline level argument'); +$this->assertEquals($expected, $this->dumper->dump($array, -10), '->dump() takes an inline level argument'); +$this->assertEquals($expected, $this->dumper->dump($array, 0), '->dump() takes an inline level argument'); $expected = <<assertEquals($this->dumper->dump($array, 1), $expected, '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($array, 1), '->dump() takes an inline level argument'); $expected = <<assertEquals($this->dumper->dump($array, 2), $expected, '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($array, 2), '->dump() takes an inline level argument'); $expected = <<assertEquals($this->dumper->dump($array, 3), $expected, '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($array, 3), '->dump() takes an inline level argument'); $expected = <<assertEquals($this->dumper->dump($array, 4), $expected, '->dump() takes an inline level argument'); - $this->assertEquals($this->dumper->dump($array, 10), $expected, '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($array, 4), '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument'); } public function testObjectsSupport() { $a = array('foo' => new A(), 'bar' => 1); - $this->assertEquals($this->dumper->dump($a), '{ foo: !!php/object:O:40:"Symfony\Tests\Components\OutputEscaper\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', '->dump() is able to dump objects'); + $this->assertEquals('{ foo: !!php/object:O:40:"Symfony\Tests\Components\OutputEscaper\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $this->dumper->dump($a), '->dump() is able to dump objects'); } } diff --git a/tests/Symfony/Tests/Components/Yaml/InlineTest.php b/tests/Symfony/Tests/Components/Yaml/InlineTest.php index 47501a1f62977..967602b30a8d8 100644 --- a/tests/Symfony/Tests/Components/Yaml/InlineTest.php +++ b/tests/Symfony/Tests/Components/Yaml/InlineTest.php @@ -26,7 +26,7 @@ public function testLoad() { foreach ($this->getTestsForLoad() as $yaml => $value) { - $this->assertEquals(Inline::load($yaml), $value, sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml)); + $this->assertEquals($value, Inline::load($yaml), sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml)); } } @@ -36,7 +36,7 @@ public function testDump() foreach ($testsForDump as $yaml => $value) { - $this->assertEquals(Inline::dump($value), $yaml, sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); + $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); } foreach ($this->getTestsForLoad() as $yaml => $value) @@ -46,7 +46,7 @@ public function testDump() continue; } - $this->assertEquals(Inline::load(Inline::dump($value)), $value, 'check consistency'); + $this->assertEquals($value, Inline::load(Inline::dump($value)), 'check consistency'); } foreach ($testsForDump as $yaml => $value) @@ -56,7 +56,7 @@ public function testDump() continue; } - $this->assertEquals(Inline::load(Inline::dump($value)), $value, 'check consistency'); + $this->assertEquals($value, Inline::load(Inline::dump($value)), 'check consistency'); } } diff --git a/tests/Symfony/Tests/Components/Yaml/ParserTest.php b/tests/Symfony/Tests/Components/Yaml/ParserTest.php index 5e1d4ed100853..fa7ceea690740 100644 --- a/tests/Symfony/Tests/Components/Yaml/ParserTest.php +++ b/tests/Symfony/Tests/Components/Yaml/ParserTest.php @@ -56,7 +56,7 @@ public function testSpecifications() { $expected = var_export(eval('return '.trim($test['php']).';'), true); - $this->assertEquals(var_export($this->parser->parse($test['yaml']), true), $expected, $test['test']); + $this->assertEquals($expected, var_export($this->parser->parse($test['yaml']), true), $test['test']); } } } From 9fe1808cf2e7aaa09af8b6b36e551bce900563cc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Mar 2010 19:10:26 +0800 Subject: [PATCH 18/54] [Yaml] reverted previous commit --- src/Symfony/Components/Yaml/Parser.php | 7 +++-- .../Symfony/Components/Yaml/sfTests.yml | 28 ------------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index 4ae02e31a27c4..3873c6b4d3967 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -300,9 +300,12 @@ protected function getNextEmbedBlock() while ($this->moveToNextLine()) { - if ($this->isCurrentLineBlank()) + if ($this->isCurrentLineEmpty()) { - $data[] = substr($this->currentLine, $newIndent); + if ($this->isCurrentLineBlank()) + { + $data[] = substr($this->currentLine, $newIndent); + } continue; } diff --git a/tests/fixtures/Symfony/Components/Yaml/sfTests.yml b/tests/fixtures/Symfony/Components/Yaml/sfTests.yml index 29c6100a9f420..8eff31c60a282 100644 --- a/tests/fixtures/Symfony/Components/Yaml/sfTests.yml +++ b/tests/fixtures/Symfony/Components/Yaml/sfTests.yml @@ -143,31 +143,3 @@ yaml: | 0123 php: | array('foo' => "0123\n") ---- -test: Comments in folded scalars -brief: Comments in folded scalars should be kept as is -yaml: | - # comment - foo: | - # comment - bar - bar: - # comment - foo: bar # comment - bar: | - # comment - foo - foobar: - foo: | - # comment - bar - # comment -php: | - array( - 'foo' => "# comment\nbar\n", - 'bar' => array( - 'foo' => 'bar', - 'bar' => "# comment\nfoo\n", - 'foobar' => array('foo' => "# comment\nbar\n") - ) - ) From b28c781447852b81cb7a583b2af11f368964b7f3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Mar 2010 22:02:49 +0800 Subject: [PATCH 19/54] [Yaml] added support for compact inline notation with immediate sub mapping --- src/Symfony/Components/Yaml/Parser.php | 25 +-- .../Symfony/Components/Yaml/index.yml | 1 + .../Symfony/Components/Yaml/sfCompact.yml | 159 ++++++++++++++++++ 3 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 tests/fixtures/Symfony/Components/Yaml/sfCompact.yml diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index 3873c6b4d3967..330f9a1ef61e1 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -83,11 +83,7 @@ public function parse($value) } else { - if (preg_match('/^([^ ]+)\: +({.*?)$/', $values['value'], $matches)) - { - $data[] = array($matches[1] => Inline::load($matches[2])); - } - elseif (isset($values['leadspaces']) + if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] && preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P.+?))?\s*$#', $values['value'], $matches)) { @@ -99,7 +95,7 @@ public function parse($value) $block = $values['value']; if (!$this->isNextLineIndented()) { - $block .= "\n".$this->getNextEmbedBlock(); + $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); } $data[] = $parser->parse($block); @@ -283,17 +279,26 @@ protected function getCurrentLineIndentation() /** * Returns the next embed block of YAML. * + * @param integer $indentation The indent level at which the block is to be read, or null for default + * * @return string A YAML string */ - protected function getNextEmbedBlock() + protected function getNextEmbedBlock($indentation = null) { $this->moveToNextLine(); - $newIndent = $this->getCurrentLineIndentation(); + if (null === $indentation) + { + $newIndent = $this->getCurrentLineIndentation(); - if (!$this->isCurrentLineEmpty() && 0 == $newIndent) + if (!$this->isCurrentLineEmpty() && 0 == $newIndent) + { + throw new ParserException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } + } + else { - throw new ParserException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine)); + $newIndent = $indentation; } $data = array(substr($this->currentLine, $newIndent)); diff --git a/tests/fixtures/Symfony/Components/Yaml/index.yml b/tests/fixtures/Symfony/Components/Yaml/index.yml index e9735d6f4c222..dea165fe1c7d6 100644 --- a/tests/fixtures/Symfony/Components/Yaml/index.yml +++ b/tests/fixtures/Symfony/Components/Yaml/index.yml @@ -1,4 +1,5 @@ - sfComments +- sfCompact - sfTests - sfObjects - sfMergeKey diff --git a/tests/fixtures/Symfony/Components/Yaml/sfCompact.yml b/tests/fixtures/Symfony/Components/Yaml/sfCompact.yml new file mode 100644 index 0000000000000..c49f31aaf3aa6 --- /dev/null +++ b/tests/fixtures/Symfony/Components/Yaml/sfCompact.yml @@ -0,0 +1,159 @@ +--- %YAML:1.0 +test: Compact notation +brief: | + Compact notation for sets of mappings with single element +yaml: | + --- + # products purchased + - item : Super Hoop + - item : Basketball + quantity: 1 + - item: + name: Big Shoes + nick: Biggies + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + ), + array ( + 'item' => 'Basketball', + 'quantity' => 1, + ), + array ( + 'item' => array( + 'name' => 'Big Shoes', + 'nick' => 'Biggies' + ), + 'quantity' => 1 + ) + ) +--- +test: Compact notation combined with inline notation +brief: | + Combinations of compact and inline notation are allowed +yaml: | + --- + items: + - { item: Super Hoop, quantity: 1 } + - [ Basketball, Big Shoes ] +php: | + array ( + 'items' => array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'Basketball', + 'Big Shoes' + ) + ) + ) +--- %YAML:1.0 +test: Compact notation +brief: | + Compact notation for sets of mappings with single element +yaml: | + --- + # products purchased + - item : Super Hoop + - item : Basketball + quantity: 1 + - item: + name: Big Shoes + nick: Biggies + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + ), + array ( + 'item' => 'Basketball', + 'quantity' => 1, + ), + array ( + 'item' => array( + 'name' => 'Big Shoes', + 'nick' => 'Biggies' + ), + 'quantity' => 1 + ) + ) +--- +test: Compact notation combined with inline notation +brief: | + Combinations of compact and inline notation are allowed +yaml: | + --- + items: + - { item: Super Hoop, quantity: 1 } + - [ Basketball, Big Shoes ] +php: | + array ( + 'items' => array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'Basketball', + 'Big Shoes' + ) + ) + ) +--- %YAML:1.0 +test: Compact notation +brief: | + Compact notation for sets of mappings with single element +yaml: | + --- + # products purchased + - item : Super Hoop + - item : Basketball + quantity: 1 + - item: + name: Big Shoes + nick: Biggies + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + ), + array ( + 'item' => 'Basketball', + 'quantity' => 1, + ), + array ( + 'item' => array( + 'name' => 'Big Shoes', + 'nick' => 'Biggies' + ), + 'quantity' => 1 + ) + ) +--- +test: Compact notation combined with inline notation +brief: | + Combinations of compact and inline notation are allowed +yaml: | + --- + items: + - { item: Super Hoop, quantity: 1 } + - [ Basketball, Big Shoes ] +php: | + array ( + 'items' => array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'Basketball', + 'Big Shoes' + ) + ) + ) From af392234bca9247c933e83951e9dc301f4751c49 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Mar 2010 22:03:58 +0800 Subject: [PATCH 20/54] [Foundation] removed the old class loader --- src/Symfony/Foundation/ClassLoader.php | 84 -------------------------- 1 file changed, 84 deletions(-) delete mode 100644 src/Symfony/Foundation/ClassLoader.php diff --git a/src/Symfony/Foundation/ClassLoader.php b/src/Symfony/Foundation/ClassLoader.php deleted file mode 100644 index 27eaad343c526..0000000000000 --- a/src/Symfony/Foundation/ClassLoader.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * ClassLoader implementation that implements the technical interoperability - * standards for PHP 5.3 namespaces and class names. - * - * Based on http://groups.google.com/group/php-standards/web/psr-0-final-proposal - * - * Example usage: - * - * [php] - * $loader = new ClassLoader(); - * $loader->registerNamespace('Symfony', __DIR__.'/..'); - * $loader->register(); - * - * @author Jonathan H. Wage - * @author Roman S. Borschel - * @author Matthew Weier O'Phinney - * @author Kris Wallsmith - * @author Fabien Potencier - */ -class ClassLoader -{ - protected $namespaces = array(); - - /** - * Creates a new loader for classes of the specified namespace. - * - * @param string $namespace The namespace to use - * @param string $includePath The path to the namespace - */ - public function registerNamespace($namespace, $includePath = null) - { - $this->namespaces[$namespace] = $includePath; - } - - /** - * Installs this class loader on the SPL autoload stack. - */ - public function register() - { - spl_autoload_register(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $className The name of the class to load - */ - public function loadClass($className) - { - $vendor = substr($className, 0, stripos($className, '\\')); - if (!isset($this->namespaces[$vendor])) - { - return; - } - - if (false !== ($lastNsPos = strripos($className, '\\'))) - { - $namespace = substr($className, 0, $lastNsPos); - $className = substr($className, $lastNsPos + 1); - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; - } - else - { - $namespace = ''; - $fileName = ''; - } - $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; - - require $this->namespaces[$vendor].DIRECTORY_SEPARATOR.$fileName; - } -} From 401ccdd2eccdc0d194a794b501646880ea3df426 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 25 Mar 2010 15:20:30 +0800 Subject: [PATCH 21/54] fixed unit tests boostrap script --- tests/Symfony/Tests/bootstrap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Symfony/Tests/bootstrap.php b/tests/Symfony/Tests/bootstrap.php index 5eefbe7ebb22c..51d41b6a364f6 100644 --- a/tests/Symfony/Tests/bootstrap.php +++ b/tests/Symfony/Tests/bootstrap.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/../../../src/Symfony/Foundation/ClassLoader.php'; +require_once __DIR__.'/../../../src/Symfony/Foundation/UniversalClassLoader.php'; require_once 'PHPUnit/Framework.php'; -$loader = new Symfony\Foundation\ClassLoader(); +$loader = new Symfony\Foundation\UniversalClassLoader(); $loader->registerNamespace('Symfony', __DIR__.'/../../../src'); $loader->register(); From 05466f6bba747331e8763a33b238d8b7c6ac9b2a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 25 Mar 2010 15:55:50 +0800 Subject: [PATCH 22/54] [RequestHandler] changed the Request constructor signature to be more explicit --- .../Components/RequestHandler/Request.php | 72 +++++++++---------- .../WebBundle/Listener/ControllerLoader.php | 2 +- .../WebBundle/Listener/ExceptionHandler.php | 2 +- .../Components/RequestHandler/RequestTest.php | 68 ++++++++++++++++++ 4 files changed, 103 insertions(+), 41 deletions(-) create mode 100644 tests/Symfony/Tests/Components/RequestHandler/RequestTest.php diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index 5c5ba3da8ae7f..e2307c4a30431 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -45,11 +45,14 @@ class Request implements RequestInterface /** * Constructor. * - * @param array $parameters An array of parameters (see setParameters()) + * @param array $query The GET parameters + * @param array $request The POST parameters + * @param array $path The parameters parsed from the PATH_INFO (see Router) + * @param array $server The SERVER parameters */ - public function __construct(array $parameters = array()) + public function __construct(array $query = null, array $request = null, array $path = null, array $server = null) { - $this->setParameters($parameters); + $this->setParameters($request, $query, $path, $server); } /** @@ -57,21 +60,17 @@ public function __construct(array $parameters = array()) * * This method also re-initializes all properties. * - * The parameters can define four elements: - * - * * request: The POST parameters - * * query: The GET parameters - * * path: The parameters parsed from the PATH_INFO (see Router) - * * server: The SERVER parameters - * - * @param array $parameters An array of parameters + * @param array $query The GET parameters + * @param array $request The POST parameters + * @param array $path The parameters parsed from the PATH_INFO + * @param array $server The SERVER parameters */ - public function setParameters(array $parameters = array()) + public function setParameters(array $query = null, array $request = null, array $path = null, array $server = null) { - $this->requestParameters = isset($parameters['request']) ? $parameters['request'] : $_POST; - $this->queryParameters = isset($parameters['query']) ? $parameters['query'] : $_GET; - $this->pathParameters = isset($parameters['path']) ? $parameters['path'] : array(); - $this->serverParameters = isset($parameters['server']) ? $parameters['server'] : $_SERVER; + $this->requestParameters = null !== $request ? $request : $_POST; + $this->queryParameters = null !== $query ? $query : $_GET; + $this->pathParameters = null !== $path ? $path : array(); + $this->serverParameters = null !== $server ? $server : $_SERVER; $this->languages = null; $this->charsets = null; @@ -85,30 +84,25 @@ public function setParameters(array $parameters = array()) $this->format = null; } - public function duplicate(array $parameters = array()) - { - $request = clone $this; - - foreach (array('request', 'query', 'path', 'server') as $key) - { - if (isset($parameters[$key])) - { - $request->{$key.'Parameters'} = $parameters[$key]; - } - } - - $this->languages = null; - $this->charsets = null; - $this->acceptableContentTypes = null; - $this->scriptName = null; - $this->pathInfo = null; - $this->requestUri = null; - $this->baseUrl = null; - $this->basePath = null; - $this->method = null; - $this->format = null; + /** + * Clones a request and overrides some of its parameters. + * + * @param array $query The GET parameters + * @param array $request The POST parameters + * @param array $path The parameters parsed from the PATH_INFO + * @param array $server The SERVER parameters + */ + public function duplicate(array $query = null, array $request = null, array $path = null, array $server = null) + { + $dup = clone $this; + $dup->setParameters( + null !== $query ? $query : $this->queryParameters, + null !== $request ? $request : $this->requestParameters, + null !== $path ? $path : $this->pathParameters, + null !== $server ? $server : $this->serverParameters + ); - return $request; + return $dup; } /** diff --git a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php index 7b170d7e2a04f..edaf3224f6ea0 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php +++ b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php @@ -45,7 +45,7 @@ public function run($controller, array $parameters) list($parameters['_bundle'], $parameters['_controller'], $parameters['_action']) = explode(':', $controller); $parameters['_format'] = $request->getRequestFormat(); - $request = $request->duplicate(array('path' => $parameters)); + $request = $request->duplicate(null, null, $parameters); return $this->container->getRequestHandlerService()->handleRaw($request, false); } diff --git a/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php b/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php index 828ae0dec4f59..0abee28d4cf7b 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php +++ b/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php @@ -67,7 +67,7 @@ public function handle(Event $event) 'logs' => $this->container->hasService('zend.logger.writer.debug') ? $this->container->getService('zend.logger.writer.debug')->getLogs() : array(), ); - $request = $event->getParameter('request')->duplicate(array('path' => $parameters)); + $request = $event->getParameter('request')->duplicate(null, null, $parameters); try { diff --git a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php new file mode 100644 index 0000000000000..166d77a9eb1ff --- /dev/null +++ b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\RequestHandler; + +require_once __DIR__.'/../../bootstrap.php'; + +use Symfony\Components\RequestHandler\Request; + +class RequestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Request::__construct() + */ + public function testConstructor() + { + $this->testSetParameters(); + } + + /** + * @covers Request::setParameters() + */ + public function testSetParameters() + { + $request = new Request(); + + $request->setParameters(array('foo' => 'bar')); + $this->assertEquals('bar', $request->getQueryParameter('foo'), '->setParameter() takes an array of query parameters as its first argument'); + + $request->setParameters(null, array('foo' => 'bar')); + $this->assertEquals('bar', $request->getRequestParameter('foo'), '->setParameter() takes an array of request parameters as its second argument'); + + $request->setParameters(null, null, array('foo' => 'bar')); + $this->assertEquals('bar', $request->getPathParameter('foo'), '->setParameter() takes an array of path parameters as its thrid argument'); + + $request->setParameters(null, null, null, array('HTTP_FOO' => 'bar')); + $this->assertEquals('bar', $request->getHttpHeader('foo'), '->setParameter() takes an array of HTTP headers as its fourth argument'); + } + + /** + * @covers Request::duplicate() + */ + public function testDuplicate() + { + $request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array('HTTP_FOO' => 'bar')); + $dup = $request->duplicate(); + + $this->assertEquals($request->getQueryParameters(), $dup->getQueryParameters(), '->duplicate() duplicates a request an copy the current query parameters'); + $this->assertEquals($request->getRequestParameters(), $dup->getRequestParameters(), '->duplicate() duplicates a request an copy the current request parameters'); + $this->assertEquals($request->getPathParameters(), $dup->getPathParameters(), '->duplicate() duplicates a request an copy the current path parameters'); + $this->assertEquals($request->getHttpHeader('foo'), $dup->getHttpHeader('foo'), '->duplicate() duplicates a request an copy the current HTTP headers'); + + $dup = $request->duplicate(array('foo' => 'foobar'), array('foo' => 'foobar'), array('foo' => 'foobar'), array('HTTP_FOO' => 'foobar')); + + $this->assertEquals(array('foo' => 'foobar'), $dup->getQueryParameters(), '->duplicate() overrides the query parameters if provided'); + $this->assertEquals(array('foo' => 'foobar'), $dup->getRequestParameters(), '->duplicate() overrides the request parameters if provided'); + $this->assertEquals(array('foo' => 'foobar'), $dup->getPathParameters(), '->duplicate() overrides the path parameters if provided'); + $this->assertEquals('foobar', $dup->getHttpHeader('foo'), '->duplicate() overrides the HTTP header if provided'); + } +} From bb035f10b2c5d97f715aef3b233e46e302083562 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 25 Mar 2010 20:26:16 +0800 Subject: [PATCH 23/54] [RequestHandler] fixed coverage annotations in tests --- .../Symfony/Tests/Components/RequestHandler/RequestTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php index 166d77a9eb1ff..741c6b5e32153 100644 --- a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php +++ b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php @@ -18,7 +18,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase { /** - * @covers Request::__construct() + * @covers Symfony\Components\RequestHandler\Request::__construct */ public function testConstructor() { @@ -26,7 +26,7 @@ public function testConstructor() } /** - * @covers Request::setParameters() + * @covers Symfony\Components\RequestHandler\Request::setParameters */ public function testSetParameters() { @@ -46,7 +46,7 @@ public function testSetParameters() } /** - * @covers Request::duplicate() + * @covers Symfony\Components\RequestHandler\Request::duplicate */ public function testDuplicate() { From b5b1d6d2f1f03db59ea88cab04e22c3d942d85d4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 25 Mar 2010 21:04:48 +0800 Subject: [PATCH 24/54] [DependencyInjection] fixed Container::getService() when the service is empty (closes #8456) --- .../Components/DependencyInjection/Container.php | 2 +- .../DependencyInjection/ContainerTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Components/DependencyInjection/Container.php b/src/Symfony/Components/DependencyInjection/Container.php index 95ec4118214d6..c6a011a218607 100644 --- a/src/Symfony/Components/DependencyInjection/Container.php +++ b/src/Symfony/Components/DependencyInjection/Container.php @@ -193,7 +193,7 @@ public function getService($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_RE throw new \InvalidArgumentException(sprintf('A service id should be a string (%s given).', str_replace("\n", '', var_export($id, true)))); } - if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) + if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service') && 'getService' !== $method) { return $this->$method(); } diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php index 4fb0838e89461..ff3baf28f6dde 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php @@ -176,6 +176,20 @@ public function testMagicCall() { } } + + public function testGetService() + { + $sc = new Container(); + + try + { + $sc->getService(''); + $this->fail('->getService() throws a \InvalidArgumentException exception if the service is empty'); + } + catch (\InvalidArgumentException $e) + { + } + } } class ProjectServiceContainer extends Container From fb22353fc68d5d3f735b896bc768217be4393bde Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 25 Mar 2010 21:56:29 +0800 Subject: [PATCH 25/54] simplified unit tests --- phpunit.xml | 1 + tests/Symfony/Tests/Components/Console/ApplicationTest.php | 2 -- tests/Symfony/Tests/Components/Console/Command/CommandTest.php | 2 -- .../Tests/Components/Console/Command/HelpCommandTest.php | 2 -- .../Tests/Components/Console/Command/ListCommandTest.php | 2 -- .../Tests/Components/Console/Helper/FormatterHelperTest.php | 2 -- tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php | 2 -- tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php | 2 -- .../Tests/Components/Console/Input/InputArgumentTest.php | 2 -- .../Tests/Components/Console/Input/InputDefinitionTest.php | 2 -- .../Symfony/Tests/Components/Console/Input/InputOptionTest.php | 2 -- tests/Symfony/Tests/Components/Console/Input/InputTest.php | 2 -- .../Symfony/Tests/Components/Console/Input/StringInputTest.php | 2 -- .../Tests/Components/Console/Output/ConsoleOutputTest.php | 2 -- .../Symfony/Tests/Components/Console/Output/NullOutputTest.php | 2 -- tests/Symfony/Tests/Components/Console/Output/OutputTest.php | 2 -- .../Tests/Components/Console/Output/StreamOutputTest.php | 2 -- .../Tests/Components/Console/Tester/ApplicationTesterTest.php | 2 -- .../Tests/Components/Console/Tester/CommandTesterTest.php | 2 -- .../Components/DependencyInjection/BuilderConfigurationTest.php | 2 -- .../Tests/Components/DependencyInjection/BuilderTest.php | 2 -- .../Tests/Components/DependencyInjection/ContainerTest.php | 2 -- .../Tests/Components/DependencyInjection/CrossCheckTest.php | 2 -- .../Tests/Components/DependencyInjection/DefinitionTest.php | 2 -- .../Tests/Components/DependencyInjection/Dumper/DumperTest.php | 2 -- .../DependencyInjection/Dumper/GraphvizDumperTest.php | 2 -- .../Components/DependencyInjection/Dumper/PhpDumperTest.php | 2 -- .../Components/DependencyInjection/Dumper/XmlDumperTest.php | 2 -- .../Components/DependencyInjection/Dumper/YamlDumperTest.php | 2 -- .../Tests/Components/DependencyInjection/FileResourceTest.php | 2 -- .../Components/DependencyInjection/Loader/FileLoaderTest.php | 2 -- .../Components/DependencyInjection/Loader/IniFileLoaderTest.php | 2 -- .../DependencyInjection/Loader/LoaderExtensionTest.php | 2 -- .../Tests/Components/DependencyInjection/Loader/LoaderTest.php | 2 -- .../Components/DependencyInjection/Loader/XmlFileLoaderTest.php | 2 -- .../DependencyInjection/Loader/YamlFileLoaderTest.php | 2 -- .../Tests/Components/DependencyInjection/ParameterTest.php | 2 -- .../Tests/Components/DependencyInjection/ReferenceTest.php | 2 -- .../Tests/Components/EventDispatcher/EventDispatcherTest.php | 2 -- tests/Symfony/Tests/Components/EventDispatcher/EventTest.php | 2 -- .../Tests/Components/OutputEscaper/ArrayDecoratorTest.php | 2 -- tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php | 2 -- .../Tests/Components/OutputEscaper/ObjectDecoratorTest.php | 2 -- .../Tests/Components/OutputEscaper/SafeDecoratorTest.php | 2 -- tests/Symfony/Tests/Components/RequestHandler/RequestTest.php | 2 -- tests/Symfony/Tests/Components/Templating/EngineTest.php | 2 -- tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php | 2 -- tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php | 2 -- .../Components/Templating/Helper/JavascriptsHelperTest.php | 2 -- .../Tests/Components/Templating/Helper/SlotsHelperTest.php | 2 -- .../Components/Templating/Helper/StylesheetsHelperTest.php | 2 -- .../Tests/Components/Templating/Loader/CacheLoaderTest.php | 2 -- .../Tests/Components/Templating/Loader/ChainLoaderTest.php | 2 -- .../Tests/Components/Templating/Loader/FilesystemLoaderTest.php | 2 -- tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php | 2 -- .../Tests/Components/Templating/Renderer/PhpRendererTest.php | 2 -- .../Tests/Components/Templating/Renderer/RendererTest.php | 2 -- .../Tests/Components/Templating/Storage/FileStorageTest.php | 2 -- .../Symfony/Tests/Components/Templating/Storage/StorageTest.php | 2 -- .../Tests/Components/Templating/Storage/StringStorageTest.php | 2 -- tests/Symfony/Tests/Components/Yaml/DumperTest.php | 2 -- tests/Symfony/Tests/Components/Yaml/InlineTest.php | 2 -- tests/Symfony/Tests/Components/Yaml/ParserTest.php | 2 -- tests/Symfony/Tests/bootstrap.php | 1 - 64 files changed, 1 insertion(+), 125 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 446c84e0c575e..14e1056998ea3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,6 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" + bootstrap="tests/Symfony/Tests/bootstrap.php" > diff --git a/tests/Symfony/Tests/Components/Console/ApplicationTest.php b/tests/Symfony/Tests/Components/Console/ApplicationTest.php index 05e554b697e4b..62b87738eee32 100644 --- a/tests/Symfony/Tests/Components/Console/ApplicationTest.php +++ b/tests/Symfony/Tests/Components/Console/ApplicationTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\Console\Application; use Symfony\Components\Console\Input\ArrayInput; use Symfony\Components\Console\Output\Output; diff --git a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php index d39278f5983bb..c0aba57905659 100644 --- a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php +++ b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Command; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Command\Command; use Symfony\Components\Console\Application; use Symfony\Components\Console\Input\InputDefinition; diff --git a/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php b/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php index 2c61f4472769f..55b9cef745487 100644 --- a/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php +++ b/tests/Symfony/Tests/Components/Console/Command/HelpCommandTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Command; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Tester\CommandTester; use Symfony\Components\Console\Command\HelpCommand; use Symfony\Components\Console\Command\ListCommand; diff --git a/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php b/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php index e7c81b41f3e81..238b8164c2724 100644 --- a/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php +++ b/tests/Symfony/Tests/Components/Console/Command/ListCommandTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Command; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Tester\CommandTester; use Symfony\Components\Console\Application; diff --git a/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php b/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php index eecec2243a774..c7f3f76bb96b3 100644 --- a/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php +++ b/tests/Symfony/Tests/Components/Console/Helper/FormatterHelperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Formatter; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Helper\FormatterHelper; class FormatterHelperTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php b/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php index 66e5c6bf5e2d5..8f58eb2a74563 100644 --- a/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\ArgvInput; use Symfony\Components\Console\Input\InputDefinition; use Symfony\Components\Console\Input\InputArgument; diff --git a/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php b/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php index 4168c0fa426ce..e4f0b7930890b 100644 --- a/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\ArrayInput; use Symfony\Components\Console\Input\InputDefinition; use Symfony\Components\Console\Input\InputArgument; diff --git a/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php b/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php index 77ef5cf42b0b6..370e047ca1512 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\InputArgument; use Symfony\Components\Console\Exception; diff --git a/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php b/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php index 655d5eb1bba2f..908c1f5fe60b2 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\InputDefinition; use Symfony\Components\Console\Input\InputArgument; use Symfony\Components\Console\Input\InputOption; diff --git a/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php b/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php index d05c5c618d101..eff2085963582 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\InputOption; use Symfony\Components\Console\Exception; diff --git a/tests/Symfony/Tests/Components/Console/Input/InputTest.php b/tests/Symfony/Tests/Components/Console/Input/InputTest.php index 8d482487482a1..726f826ca9e8d 100644 --- a/tests/Symfony/Tests/Components/Console/Input/InputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/InputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\ArrayInput; use Symfony\Components\Console\Input\InputDefinition; use Symfony\Components\Console\Input\InputArgument; diff --git a/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php b/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php index 6f3381489aa20..4fa4d108de1ec 100644 --- a/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php +++ b/tests/Symfony/Tests/Components/Console/Input/StringInputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Input; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Input\StringInput; class StringInputTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php index b8f0e884d52e5..2fe9be8d1dfbf 100644 --- a/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/ConsoleOutputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Output; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Output\ConsoleOutput; use Symfony\Components\Console\Output\Output; diff --git a/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php index 62ce474f821b8..c3446faf606d3 100644 --- a/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/NullOutputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Output; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Output\NullOutput; class NullOutputTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Console/Output/OutputTest.php b/tests/Symfony/Tests/Components/Console/Output/OutputTest.php index da84bcff54c79..8b9c363b84712 100644 --- a/tests/Symfony/Tests/Components/Console/Output/OutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/OutputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Output; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Output\Output; class OutputTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php b/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php index ffb29308a3313..3c0a18a105f58 100644 --- a/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php +++ b/tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Output; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Output\Output; use Symfony\Components\Console\Output\StreamOutput; diff --git a/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php b/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php index 210eb0256a516..d053c19d8325f 100644 --- a/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php +++ b/tests/Symfony/Tests/Components/Console/Tester/ApplicationTesterTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Tester; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Application; use Symfony\Components\Console\Output\Output; use Symfony\Components\Console\Tester\ApplicationTester; diff --git a/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php b/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php index a58dadaab09d1..f77c2032840df 100644 --- a/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php +++ b/tests/Symfony/Tests/Components/Console/Tester/CommandTesterTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\Console\Tester; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Console\Command\Command; use Symfony\Components\Console\Output\Output; use Symfony\Components\Console\Tester\CommandTester; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php index 5ac6c9cc9c923..77480ed4ec5ac 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\BuilderConfiguration; use Symfony\Components\DependencyInjection\Definition; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php index f3d8029292379..dd92d55d9fa6d 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\BuilderConfiguration; use Symfony\Components\DependencyInjection\Definition; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php index ff3baf28f6dde..9615c56ac0a2e 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Container; class ContainerTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php index 22612bfef2ad7..7e769233461f5 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; class CrossCheckTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php index 02075a809a707..d569a807745e9 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Definition; class DefinitionTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php index 7894a31ae5119..ae4bd018fea3a 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Dumper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Dumper\Dumper; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php index b26ec2affdc49..f8ae12a929d10 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Dumper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Dumper\GraphvizDumper; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php index 1925e0d6ce233..a13ad04786196 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Dumper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Dumper\PhpDumper; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php index 13940297cb3ce..2f9fd4d72cb8b 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Dumper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Dumper\XmlDumper; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php index 9a325b020b5dd..0b650ceb24e62 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Dumper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Dumper\YamlDumper; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php index 41ec10102f0a2..11f2f36413dcc 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\FileResource; class FileResourceTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php index feb5fb3e78b26..e126c14ef2797 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Loader\FileLoader; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php index da72c48062984..46c09a91de000 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Loader\IniFileLoader; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php index c0ba13c1d4674..b152812002008 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php'; class LoaderExtensionTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php index 986af5991799c..975c63f12f771 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php'; use Symfony\Components\DependencyInjection\Loader\Loader; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php index 1577229612703..725ff0acfc3a3 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Reference; use Symfony\Components\DependencyInjection\Definition; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php index ffda523b401b5..7c7a26f0164f0 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\Reference; use Symfony\Components\DependencyInjection\Definition; diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php index b35c415d626e1..02b6224d4f140 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Parameter; class ParameterTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php index 53959824cb775..bee62af42c87c 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\DependencyInjection; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\DependencyInjection\Reference; class ReferenceTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php b/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php index 502812cb101ff..d671f4aac3a2c 100644 --- a/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php +++ b/tests/Symfony/Tests/Components/EventDispatcher/EventDispatcherTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\EventDispatcher; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\EventDispatcher\Event; use Symfony\Components\EventDispatcher\EventDispatcher; diff --git a/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php b/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php index 659cb955868dc..bfe2d1ebdf6de 100644 --- a/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php +++ b/tests/Symfony/Tests/Components/EventDispatcher/EventTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\EventDispatcher; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\EventDispatcher\Event; class EventTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php index d9cbba90ae455..3dac6aed5bd66 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\OutputEscaper\Escaper; class ArrayDecoratorTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php index fea856c80bdc0..49221573bc186 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\OutputEscaper\Escaper; use Symfony\Components\OutputEscaper\SafeDecorator; use Symfony\Components\OutputEscaper\IteratorDecorator; diff --git a/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php index 620b259030914..1e9e8e436372a 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/ObjectDecoratorTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\OutputEscaper\Escaper; class ObjectDecoratorTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php b/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php index a87a7654bd240..32a5391bab074 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\OutputEscaper\SafeDecorator; class SafeDecoratorTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php index 741c6b5e32153..a2f1e4dc4cc52 100644 --- a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php +++ b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\RequestHandler; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\RequestHandler\Request; class RequestTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Templating/EngineTest.php b/tests/Symfony/Tests/Components/Templating/EngineTest.php index 0857728173ea9..0c7c9feb86886 100644 --- a/tests/Symfony/Tests/Components/Templating/EngineTest.php +++ b/tests/Symfony/Tests/Components/Templating/EngineTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating; -require_once __DIR__.'/../../bootstrap.php'; - require_once __DIR__.'/../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php'; use Symfony\Components\Templating\Engine; diff --git a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php index 167fea6e9d349..b86b2c34750ac 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Helper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Helper\AssetsHelper; class AssetsHelperTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php index 679aff7cdf4e5..96226cc716105 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Helper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Helper\Helper; class HelperTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php index 35e57d3a4d041..cfd63115a94cd 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Helper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Helper\AssetsHelper; use Symfony\Components\Templating\Helper\JavascriptsHelper; use Symfony\Components\Templating\Loader\FilesystemLoader; diff --git a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php index 405d7b6649de3..90d0e0a13650d 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Helper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Helper\SlotsHelper; class SlotsHelperTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php index d23ba2794ff04..8316636464368 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Helper; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Helper\AssetsHelper; use Symfony\Components\Templating\Helper\StylesheetsHelper; use Symfony\Components\Templating\Loader\FilesystemLoader; diff --git a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php index 6cc6bfe6e381b..d9992b6c4d499 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; use Symfony\Components\Templating\Loader\Loader; diff --git a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php index 1babe43cbd98c..5e5c9a76c29bf 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; use Symfony\Components\Templating\Loader\ChainLoader; diff --git a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php index 1f69894e7ac21..db93d11273846 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; use Symfony\Components\Templating\Loader\FilesystemLoader; diff --git a/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php index 295ecbd71e66f..bfaeb21d81213 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Loader; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php'; use Symfony\Components\Templating\Loader\Loader; diff --git a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php index 285fe7d8fd2dd..d7f2ead7d496f 100644 --- a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php +++ b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Renderer; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Renderer\PhpRenderer; use Symfony\Components\Templating\Storage\Storage; use Symfony\Components\Templating\Storage\StringStorage; diff --git a/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php index fd5c718ad5943..69d93bbe16b54 100644 --- a/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php +++ b/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Renderer; -require_once __DIR__.'/../../../bootstrap.php'; - require_once __DIR__.'/../../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php'; use Symfony\Components\Templating\Engine; diff --git a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php index d462262313152..bd5a9d84c4445 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Storage; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Storage\Storage; use Symfony\Components\Templating\Storage\FileStorage; diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php index 8c7c67ae1264b..eb2cfeb1ee61e 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Storage; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Storage\Storage; use Symfony\Components\Templating\Renderer\PhpRenderer; diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php index ce63cbbb617e9..4db7f15715165 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php @@ -11,8 +11,6 @@ namespace Symfony\Tests\Components\Templating\Storage; -require_once __DIR__.'/../../../bootstrap.php'; - use Symfony\Components\Templating\Storage\Storage; use Symfony\Components\Templating\Storage\StringStorage; diff --git a/tests/Symfony/Tests/Components/Yaml/DumperTest.php b/tests/Symfony/Tests/Components/Yaml/DumperTest.php index 5e8a84bf57f41..4ca0873602e24 100644 --- a/tests/Symfony/Tests/Components/Yaml/DumperTest.php +++ b/tests/Symfony/Tests/Components/Yaml/DumperTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\Yaml\Yaml; use Symfony\Components\Yaml\Parser; use Symfony\Components\Yaml\Dumper; diff --git a/tests/Symfony/Tests/Components/Yaml/InlineTest.php b/tests/Symfony/Tests/Components/Yaml/InlineTest.php index 967602b30a8d8..47bc898383f7c 100644 --- a/tests/Symfony/Tests/Components/Yaml/InlineTest.php +++ b/tests/Symfony/Tests/Components/Yaml/InlineTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\Yaml\Yaml; use Symfony\Components\Yaml\Inline; diff --git a/tests/Symfony/Tests/Components/Yaml/ParserTest.php b/tests/Symfony/Tests/Components/Yaml/ParserTest.php index fa7ceea690740..916a1f641b73d 100644 --- a/tests/Symfony/Tests/Components/Yaml/ParserTest.php +++ b/tests/Symfony/Tests/Components/Yaml/ParserTest.php @@ -10,8 +10,6 @@ namespace Symfony\Tests\Components\OutputEscaper; -require_once __DIR__.'/../../bootstrap.php'; - use Symfony\Components\Yaml\Yaml; use Symfony\Components\Yaml\Parser; use Symfony\Components\Yaml\ParserException; diff --git a/tests/Symfony/Tests/bootstrap.php b/tests/Symfony/Tests/bootstrap.php index 51d41b6a364f6..a773566674eb9 100644 --- a/tests/Symfony/Tests/bootstrap.php +++ b/tests/Symfony/Tests/bootstrap.php @@ -10,7 +10,6 @@ */ require_once __DIR__.'/../../../src/Symfony/Foundation/UniversalClassLoader.php'; -require_once 'PHPUnit/Framework.php'; $loader = new Symfony\Foundation\UniversalClassLoader(); $loader->registerNamespace('Symfony', __DIR__.'/../../../src'); From 616f88c0e2959a0a3ae162d87b6401162ba27123 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 26 Mar 2010 23:18:26 +0800 Subject: [PATCH 26/54] [Routing] fixed a warning when using a sub-class of UrlGenerator --- src/Symfony/Components/Routing/Generator/UrlGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Components/Routing/Generator/UrlGenerator.php b/src/Symfony/Components/Routing/Generator/UrlGenerator.php index e28f82e3a77e4..aeb691b37f7c5 100644 --- a/src/Symfony/Components/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Components/Routing/Generator/UrlGenerator.php @@ -38,7 +38,7 @@ class UrlGenerator implements UrlGeneratorInterface public function __construct(RouteCollection $routes, array $context = array(), array $defaults = array()) { $this->routes = $routes; - $this->context = array_merge(array('base_url' => ''), $context); + $this->context = $context; $this->defaults = $defaults; $this->cache = array(); } @@ -123,7 +123,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $url .= '?'.http_build_query($extra); } - $url = $this->context['base_url'].$url; + $url = (isset($this->context['base_url']) ? $this->context['base_url'] : '').$url; if ($absolute && isset($this->context['host'])) { From c882f4caea48479c2c5a5bf6c681feaa79259848 Mon Sep 17 00:00:00 2001 From: Bongiraud Dominique Date: Mon, 29 Mar 2010 01:02:36 +0800 Subject: [PATCH 27/54] [DependencyInjection]fix bug --- .../Components/DependencyInjection/BuilderConfiguration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php b/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php index 512f76849aef3..7da14fb9bf247 100644 --- a/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php +++ b/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php @@ -277,7 +277,7 @@ public function setDefinition($id, Definition $definition) { unset($this->aliases[$id]); - return $this->definitions[$id] = $definition; + $this->definitions[$id] = $definition; return $this; } From be96afdf9a4b2b11cf3e0d3c8d5b4f65f20495ec Mon Sep 17 00:00:00 2001 From: Bongiraud Dominique Date: Mon, 29 Mar 2010 01:03:00 +0800 Subject: [PATCH 28/54] [Routing]fix bug --- src/Symfony/Components/Routing/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Components/Routing/Router.php b/src/Symfony/Components/Routing/Router.php index 188e914e95a3f..48795b14df61b 100644 --- a/src/Symfony/Components/Routing/Router.php +++ b/src/Symfony/Components/Routing/Router.php @@ -52,7 +52,7 @@ public function __construct($loader, array $options = array(), array $context = 'debug' => false, 'generator_class' => 'Symfony\\Components\\Routing\\Generator\\UrlGenerator', 'generator_base_class' => 'Symfony\\Components\\Routing\\Generator\\UrlGenerator', - 'generator_dumper_class' => 'Symfony\Components\Routing\Generator\Dumper\PhpGeneratorDumper', + 'generator_dumper_class' => 'Symfony\\Components\\Routing\\Generator\\Dumper\\PhpGeneratorDumper', 'generator_cache_class' => 'ProjectUrlGenerator', 'matcher_class' => 'Symfony\\Components\\Routing\\Matcher\\UrlMatcher', 'matcher_base_class' => 'Symfony\\Components\\Routing\\Matcher\\UrlMatcher', From 54be54d52697d44e954aec7b939431dd27a32fe2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Mar 2010 18:40:22 +0800 Subject: [PATCH 29/54] [Yaml] fixed YAML parser when mbstring.func_overload is used with an mbstring.internal_encoding different from ASCII --- src/Symfony/Components/Yaml/Inline.php | 21 ++++++++++++++++++--- src/Symfony/Components/Yaml/Parser.php | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Components/Yaml/Inline.php b/src/Symfony/Components/Yaml/Inline.php index 854f4bba59763..b94f7a15ea1c4 100644 --- a/src/Symfony/Components/Yaml/Inline.php +++ b/src/Symfony/Components/Yaml/Inline.php @@ -37,15 +37,30 @@ static public function load($value) return ''; } + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) + { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + switch ($value[0]) { case '[': - return self::parseSequence($value); + $result = self::parseSequence($value); + break; case '{': - return self::parseMapping($value); + $result = self::parseMapping($value); + break; default: - return self::parseScalar($value); + $result = self::parseScalar($value); } + + if (isset($mbEncoding)) + { + mb_internal_encoding($mbEncoding); + } + + return $result; } /** diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index 330f9a1ef61e1..b47a0dd0b89e6 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -50,6 +50,12 @@ public function parse($value) $this->currentLine = ''; $this->lines = explode("\n", $this->cleanup($value)); + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) + { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + $data = array(); while ($this->moveToNextLine()) { @@ -220,6 +226,11 @@ public function parse($value) } } + if (isset($mbEncoding)) + { + mb_internal_encoding($mbEncoding); + } + return $value; } @@ -253,6 +264,11 @@ public function parse($value) } } + if (isset($mbEncoding)) + { + mb_internal_encoding($mbEncoding); + } + return empty($data) ? null : $data; } From e1c118abce1400218aaaae57a3db3784fc7960ca Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Mar 2010 19:14:45 +0800 Subject: [PATCH 30/54] simplified phpunit.xml and made it more generic (PHPUnit 3.5 is now required) --- phpunit.xml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 14e1056998ea3..b739519fc0d9c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,16 +20,12 @@ - ./src/Symfony/ + ./src/Symfony/ - ./src/Symfony/Framework/DoctrineBundle - ./src/Symfony/Framework/ZendBundle + ./src/Symfony/Framework/DoctrineBundle + ./src/Symfony/Framework/ZendBundle - ./src/Symfony/Framework/DoctrineBundle/Resources - ./src/Symfony/Framework/ProfilerBundle/Resources - ./src/Symfony/Framework/SwiftmailerBundle/Resources - ./src/Symfony/Framework/WebBundle/Resources - ./src/Symfony/Framework/ZendBundle/Resources + ./src/Symfony/Framework/*/Resources ./src/Symfony/Foundation/bootstrap.php ./src/Symfony/Foundation/packager.php From 9379d4356c424dd20dbf1dcc939b827e99d7988b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Mar 2010 20:32:58 +0800 Subject: [PATCH 31/54] [DependencyInjection] fixed a test --- .../Components/DependencyInjection/BuilderConfigurationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php index 77480ed4ec5ac..9545ab73a3258 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php @@ -170,7 +170,7 @@ public function testDefinitions() $configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')); $this->assertEquals($foo, $configuration->getDefinition('foobar'), '->getDefinition() returns a service definition if defined'); - $this->assertTrue($configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference'); + $this->assertTrue($configuration->setDefinition('foobar', new Definition('FooBarClass')) === $configuration, '->setDefinition() implements a fuild interface'); $configuration->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); $this->assertEquals(array_merge($definitions, $defs), $configuration->getDefinitions(), '->addDefinitions() adds the service definitions'); From af27f9388a49a0137534eeacf5cd698477a6d4fc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 31 Mar 2010 14:42:18 +0800 Subject: [PATCH 32/54] [CssSelector] added the component --- .../CssSelector/Node/AttribNode.php | 137 ++++++++ .../Components/CssSelector/Node/ClassNode.php | 49 +++ .../CssSelector/Node/CombinedSelectorNode.php | 99 ++++++ .../CssSelector/Node/ElementNode.php | 68 ++++ .../CssSelector/Node/FunctionNode.php | 256 +++++++++++++++ .../Components/CssSelector/Node/HashNode.php | 49 +++ .../CssSelector/Node/NodeInterface.php | 29 ++ .../Components/CssSelector/Node/OrNode.php | 50 +++ .../CssSelector/Node/PseudoNode.php | 155 +++++++++ src/Symfony/Components/CssSelector/Parser.php | 307 ++++++++++++++++++ src/Symfony/Components/CssSelector/README | 4 + .../Components/CssSelector/SyntaxError.php | 26 ++ src/Symfony/Components/CssSelector/Token.php | 51 +++ .../Components/CssSelector/TokenStream.php | 85 +++++ .../Components/CssSelector/Tokenizer.php | 183 +++++++++++ .../Components/CssSelector/XPathExpr.php | 185 +++++++++++ .../Components/CssSelector/XPathExprOr.php | 46 +++ .../CssSelector/Node/AttribNodeTest.php | 44 +++ .../CssSelector/Node/ClassNodeTest.php | 27 ++ .../Node/CombinedSelectorNodeTest.php | 37 +++ .../CssSelector/Node/ElementNodeTest.php | 30 ++ .../CssSelector/Node/FunctionNodeTest.php | 91 ++++++ .../CssSelector/Node/HashNodeTest.php | 27 ++ .../CssSelector/Node/OrNodeTest.php | 29 ++ .../CssSelector/Node/PseudoNodeTest.php | 55 ++++ .../Components/CssSelector/ParserTest.php | 62 ++++ .../Components/CssSelector/TokenizerTest.php | 53 +++ 27 files changed, 2234 insertions(+) create mode 100644 src/Symfony/Components/CssSelector/Node/AttribNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/ClassNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/ElementNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/FunctionNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/HashNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/NodeInterface.php create mode 100644 src/Symfony/Components/CssSelector/Node/OrNode.php create mode 100644 src/Symfony/Components/CssSelector/Node/PseudoNode.php create mode 100644 src/Symfony/Components/CssSelector/Parser.php create mode 100644 src/Symfony/Components/CssSelector/README create mode 100644 src/Symfony/Components/CssSelector/SyntaxError.php create mode 100644 src/Symfony/Components/CssSelector/Token.php create mode 100644 src/Symfony/Components/CssSelector/TokenStream.php create mode 100644 src/Symfony/Components/CssSelector/Tokenizer.php create mode 100644 src/Symfony/Components/CssSelector/XPathExpr.php create mode 100644 src/Symfony/Components/CssSelector/XPathExprOr.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/AttribNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/ClassNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/CombinedSelectorNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/ElementNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/FunctionNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/HashNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/OrNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/Node/PseudoNodeTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/ParserTest.php create mode 100644 tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php diff --git a/src/Symfony/Components/CssSelector/Node/AttribNode.php b/src/Symfony/Components/CssSelector/Node/AttribNode.php new file mode 100644 index 0000000000000..b123b2f880a70 --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/AttribNode.php @@ -0,0 +1,137 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * AttribNode represents a "selector[namespace|attrib operator value]" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class AttribNode implements NodeInterface +{ + protected $selector; + protected $namespace; + protected $attrib; + protected $operator; + protected $value; + + public function __construct($selector, $namespace, $attrib, $operator, $value) + { + $this->selector = $selector; + $this->namespace = $namespace; + $this->attrib = $attrib; + $this->operator = $operator; + $this->value = $value; + } + + public function __toString() + { + if ($this->operator == 'exists') + { + return sprintf('%s[%s[%s]]', __CLASS__, $this->selector, $this->formatAttrib()); + } + else + { + return sprintf('%s[%s[%s %s %s]]', __CLASS__, $this->selector, $this->formatAttrib(), $this->operator, $this->value); + } + } + + public function toXpath() + { + $path = $this->selector->toXpath(); + $attrib = $this->xpathAttrib(); + $value = $this->value; + if ($this->operator == 'exists') + { + $path->addCondition($attrib); + } + elseif ($this->operator == '=') + { + $path->addCondition(sprintf('%s = %s', $attrib, XPathExpr::xpathLiteral($value))); + } + elseif ($this->operator == '!=') + { + # FIXME: this seems like a weird hack... + if ($value) + { + $path->addCondition(sprintf('not(%s) or %s != %s', $attrib, $attrib, XPathExpr::xpathLiteral($value))); + } + else + { + $path->addCondition(sprintf('%s != %s', $attrib, XPathExpr::xpathLiteral($value))); + } + #path.addCondition('%s != %s' % (attrib, xpathLiteral(value))) + } + elseif ($this->operator == '~=') + { + $path->addCondition(sprintf("contains(concat(' ', normalize-space(%s), ' '), %s)", $attrib, XPathExpr::xpathLiteral(' '.$value.' '))); + } + elseif ($this->operator == '|=') + { + # Weird, but true... + $path->addCondition(sprintf('%s = %s or starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value), $attrib, XPathExpr::xpathLiteral($value.'-'))); + } + elseif ($this->operator == '^=') + { + $path->addCondition(sprintf('starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value))); + } + elseif ($this->operator == '$=') + { + # Oddly there is a starts-with in XPath 1.0, but not ends-with + $path->addCondition(sprintf('substring(%s, string-length(%s)-%s) = %s', $attrib, $attrib, strlen($value) - 1, XPathExpr::xpathLiteral($value))); + } + elseif ($this->operator == '*=') + { + # FIXME: case sensitive? + $path->addCondition(sprintf('contains(%s, %s)', $attrib, XPathExpr::xpathLiteral($value))); + } + else + { + throw new SyntaxError(sprintf("Unknown operator: %s", $this->operator)); + } + + return $path; + } + + protected function xpathAttrib() + { + # FIXME: if attrib is *? + if ($this->namespace == '*') + { + return '@'.$this->attrib; + } + else + { + return sprintf('@%s:%s', $this->namespace, $this->attrib); + } + } + + protected function formatAttrib() + { + if ($this->namespace == '*') + { + return $this->attrib; + } + else + { + return sprintf('%s|%s', $this->namespace, $this->attrib); + } + } +} diff --git a/src/Symfony/Components/CssSelector/Node/ClassNode.php b/src/Symfony/Components/CssSelector/Node/ClassNode.php new file mode 100644 index 0000000000000..6b001739470af --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/ClassNode.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * ClassNode represents a "selector.className" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class ClassNode implements NodeInterface +{ + protected $selector; + protected $className; + + public function __construct($selector, $className) + { + $this->selector = $selector; + $this->className = $className; + } + + public function __toString() + { + return sprintf('%s[%s.%s]', __CLASS__, $this->selector, $this->className); + } + + public function toXpath() + { + $selXpath = $this->selector->toXpath(); + $selXpath->addCondition(sprintf("contains(concat(' ', normalize-space(@class), ' '), %s)", XPathExpr::xpathLiteral(' '.$this->className.' '))); + + return $selXpath; + } +} diff --git a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php new file mode 100644 index 0000000000000..4ce5ab23748ad --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php @@ -0,0 +1,99 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * CombinedSelectorNode represents a combinator node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class CombinedSelectorNode implements NodeInterface +{ + static protected $_method_mapping = array( + ' ' => 'descendant', + '>' => 'child', + '+' => 'direct_adjacent', + '~' => 'indirect_adjacent', + ); + + protected $selector; + protected $combinator; + protected $subselector; + + public function __construct($selector, $combinator, $subselector) + { + $this->selector = $selector; + $this->combinator = $combinator; + $this->subselector = $subselector; + } + + public function __toString() + { + $comb = $this->combinator == ' ' ? '' : $this->combinator; + + return sprintf('%s[%s %s %s]', __CLASS__, $this->selector, $comb, $this->subselector); + } + + public function toXpath() + { + if (!isset(self::$_method_mapping[$this->combinator])) + { + throw new SyntaxError(sprintf("Unknown combinator: %s", $this->combinator)); + } + + $method = '_xpath_'.self::$_method_mapping[$this->combinator]; + $path = $this->selector->toXpath(); + + return $this->$method($path, $this->subselector); + } + + protected function _xpath_descendant($xpath, $sub) + { + # when sub is a descendant in any way of xpath + $xpath->join('/descendant::', $sub->toXpath()); + + return $xpath; + } + + protected function _xpath_child($xpath, $sub) + { + # when sub is an immediate child of xpath + $xpath->join('/', $sub->toXpath()); + + return $xpath; + } + + protected function _xpath_direct_adjacent($xpath, $sub) + { + # when sub immediately follows xpath + $xpath->join('/following-sibling::', $sub->toXpath()); + $xpath->addNameTest(); + $xpath->addCondition('position() = 1'); + + return $xpath; + } + + protected function _xpath_indirect_adjacent($xpath, $sub) + { + # when sub comes somewhere after xpath as a sibling + $xpath->join('/following-sibling::', $sub->toXpath()); + + return $xpath; + } +} diff --git a/src/Symfony/Components/CssSelector/Node/ElementNode.php b/src/Symfony/Components/CssSelector/Node/ElementNode.php new file mode 100644 index 0000000000000..e45a0ec7d76b1 --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/ElementNode.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * ElementNode represents a "namespace|element" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class ElementNode implements NodeInterface +{ + protected $namespace; + protected $element; + + public function __construct($namespace, $element) + { + $this->namespace = $namespace; + $this->element = $element; + } + + public function __toString() + { + return sprintf('%s[%s]', __CLASS__, $this->formatElement()); + } + + public function formatElement() + { + if ($this->namespace == '*') + { + return $this->element; + } + else + { + return sprintf('%s|%s', $this->namespace, $this->element); + } + } + + public function toXpath() + { + if ($this->namespace == '*') + { + $el = strtolower($this->element); + } + else + { + # FIXME: Should we lowercase here? + $el = sprintf('%s:%s', $this->namespace, $this->element); + } + + return new XPathExpr(null, null, $el); + } +} diff --git a/src/Symfony/Components/CssSelector/Node/FunctionNode.php b/src/Symfony/Components/CssSelector/Node/FunctionNode.php new file mode 100644 index 0000000000000..e7dd9956056e3 --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/FunctionNode.php @@ -0,0 +1,256 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * FunctionNode represents a "selector:name(expr)" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class FunctionNode implements NodeInterface +{ + static protected $unsupported = array('target', 'lang', 'enabled', 'disabled'); + + protected $selector; + protected $type; + protected $name; + protected $expr; + + public function __construct($selector, $type, $name, $expr) + { + $this->selector = $selector; + $this->type = $type; + $this->name = $name; + $this->expr = $expr; + } + + public function __toString() + { + return sprintf('%s[%s%s%s(%s)]', __CLASS__, $this->selector, $this->type, $this->name, $this->expr); + } + + public function toXpath() + { + $sel_path = $this->selector->toXpath(); + if (in_array($this->name, self::$unsupported)) + { + throw new SyntaxError(sprintf("The pseudo-class %s is not supported", $this->name)); + } + $method = '_xpath_'.str_replace('-', '_', $this->name); + if (!method_exists($this, $method)) + { + throw new SyntaxError(sprintf("The pseudo-class %s is unknown", $this->name)); + } + + return $this->$method($sel_path, $this->expr); + } + + protected function _xpath_nth_child($xpath, $expr, $last = false, $addNameTest = true) + { + list($a, $b) = $this->parseSeries($expr); + if (!$a && !$b && !$last) + { + # a=0 means nothing is returned... + $xpath->addCondition('false() and position() = 0'); + + return $xpath; + } + + if ($addNameTest) + { + $xpath->addNameTest(); + } + + $xpath->addStarPrefix(); + if ($a == 0) + { + if ($last) + { + $b = sprintf('last() - %s', $b); + } + $xpath->addCondition(sprintf('position() = %s', $b)); + + return $xpath; + } + + if ($last) + { + # FIXME: I'm not sure if this is right + $a = -$a; + $b = -$b; + } + + if ($b > 0) + { + $b_neg = -$b; + } + else + { + $b_neg = sprintf('+%s', -$b); + } + + if ($a != 1) + { + $expr = array(sprintf('(position() %s) mod %s = 0', $b_neg, $a)); + } + else + { + $expr = array(); + } + + if ($b >= 0) + { + $expr[] = sprintf('position() >= %s', $b); + } + elseif ($b < 0 && $last) + { + $expr[] = sprintf('position() < (last() %s)', $b); + } + $expr = implode($expr, ' and '); + + if ($expr) + { + $xpath->addCondition($expr); + } + + return $xpath; + # FIXME: handle an+b, odd, even + # an+b means every-a, plus b, e.g., 2n+1 means odd + # 0n+b means b + # n+0 means a=1, i.e., all elements + # an means every a elements, i.e., 2n means even + # -n means -1n + # -1n+6 means elements 6 and previous + } + + protected function _xpath_nth_last_child($xpath, $expr) + { + return $this->_xpath_nth_child($xpath, $expr, true); + } + + protected function _xpath_nth_of_type($xpath, $expr) + { + if ($xpath->getElement() == '*') + { + throw new SyntaxError("*:nth-of-type() is not implemented"); + } + + return $this->_xpath_nth_child($xpath, $expr, false, false); + } + + protected function _xpath_nth_last_of_type($xpath, $expr) + { + return $this->_xpath_nth_child($xpath, $expr, true, false); + } + + protected function _xpath_contains($xpath, $expr) + { + # text content, minus tags, must contain expr + if ($expr instanceof ElementNode) + { + $expr = $expr->formatElement(); + } + $xpath->addCondition(sprintf('contains(css:lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr)))); + # FIXME: Currently case insensitive matching doesn't seem to be happening + + return $xpath; + } + + protected function _xpath_not($xpath, $expr) + { + # everything for which not expr applies + $expr = $expr->toXpath(); + $cond = $expr->getCondition(); + # FIXME: should I do something about element_path? + $xpath->addCondition(sprintf('not(%s)', $cond)); + + return $xpath; + } + + // Parses things like '1n+2', or 'an+b' generally, returning (a, b) + protected function parseSeries($s) + { + if ($s instanceof ElementNode) + { + $s = $s->formatElement(); + } + + if (!$s || $s == '*') + { + # Happens when there's nothing, which the CSS parser thinks of as * + return array(0, 0); + } + + if (is_string($s)) + { + # Happens when you just get a number + return array(0, $s); + } + + if ($s == 'odd') + { + return array(2, 1); + } + elseif ($s == 'even') + { + return array(2, 0); + } + elseif ($s == 'n') + { + return array(1, 0); + } + + if (false === strpos($s, 'n')) + { + # Just a b + + return array(0, intval((string) $s)); + } + + list($a, $b) = explode('n', $s); + if (!$a) + { + $a = 1; + } + elseif ($a == '-' || $a == '+') + { + $a = intval($a.'1'); + } + else + { + $a = intval($a); + } + + if (!$b) + { + $b = 0; + } + elseif ($b == '-' || $b == '+') + { + $b = intval($b.'1'); + } + else + { + $b = intval($b); + } + + return array($a, $b); + } +} diff --git a/src/Symfony/Components/CssSelector/Node/HashNode.php b/src/Symfony/Components/CssSelector/Node/HashNode.php new file mode 100644 index 0000000000000..7a7ae13b9ce6c --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/HashNode.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * HashNode represents a "selector#id" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class HashNode implements NodeInterface +{ + protected $selector; + protected $id; + + public function __construct($selector, $id) + { + $this->selector = $selector; + $this->id = $id; + } + + public function __toString() + { + return sprintf('%s[%s#%s]', __CLASS__, $this->selector, $this->id); + } + + public function toXpath() + { + $path = $this->selector->toXpath(); + $path->addCondition(sprintf('@id = %s', XPathExpr::xpathLiteral($this->id))); + + return $path; + } +} diff --git a/src/Symfony/Components/CssSelector/Node/NodeInterface.php b/src/Symfony/Components/CssSelector/Node/NodeInterface.php new file mode 100644 index 0000000000000..aadcb7b320f33 --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/NodeInterface.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * ClassNode represents a "selector.className" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +interface NodeInterface +{ + public function __toString(); + + public function toXpath(); +} diff --git a/src/Symfony/Components/CssSelector/Node/OrNode.php b/src/Symfony/Components/CssSelector/Node/OrNode.php new file mode 100644 index 0000000000000..b64142a02d685 --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/OrNode.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * OrNode represents a "Or" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class OrNode implements NodeInterface +{ + protected $items; + + public function __construct($items) + { + $this->items = $items; + } + + public function __toString() + { + return sprintf('%s(%s)', __CLASS__, $this->items); + } + + public function toXpath() + { + $paths = array(); + foreach ($this->items as $item) + { + $paths[] = $item->toXpath(); + } + + return new XPathExprOr($paths); + } +} diff --git a/src/Symfony/Components/CssSelector/Node/PseudoNode.php b/src/Symfony/Components/CssSelector/Node/PseudoNode.php new file mode 100644 index 0000000000000..01b0842be97e2 --- /dev/null +++ b/src/Symfony/Components/CssSelector/Node/PseudoNode.php @@ -0,0 +1,155 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * PseudoNode represents a "selector:ident" node. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class PseudoNode implements NodeInterface +{ + static protected $unsupported = array( + 'indeterminate', 'first-line', 'first-letter', + 'selection', 'before', 'after', 'link', 'visited', + 'active', 'focus', 'hover', + ); + + protected $element; + protected $type; + protected $ident; + + public function __construct($element, $type, $ident) + { + $this->element = $element; + + if (!in_array($type, array(':', '::'))) + { + throw new SyntaxError(sprintf('The PseudoNode type can only be : or :: (%s given).', $type)); + } + + $this->type = $type; + $this->ident = $ident; + } + + public function __toString() + { + return sprintf('%s[%s%s%s]', __CLASS__, $this->element, $this->type, $this->ident); + } + + public function toXpath() + { + $el_xpath = $this->element->toXpath(); + + if (in_array($this->ident, self::$unsupported)) + { + throw new SyntaxError(sprintf("The pseudo-class %s is unsupported", $this->ident)); + } + $method = 'xpath_'.str_replace('-', '_', $this->ident); + if (!method_exists($this, $method)) + { + throw new SyntaxError(sprintf("The pseudo-class %s is unknown", $this->ident)); + } + + return $this->$method($el_xpath); + } + + protected function xpath_checked($xpath) + { + # FIXME: is this really all the elements? + $xpath->addCondition("(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')"); + + return $xpath; + } + + protected function xpath_root($xpath) + { + # if this element is the root element + throw new SyntaxError(); + } + + protected function xpath_first_child($xpath) + { + $xpath->addStarPrefix(); + $xpath->addNameTest(); + $xpath->addCondition('position() = 1'); + + return $xpath; + } + + protected function xpath_last_child($xpath) + { + $xpath->addStarPrefix(); + $xpath->addNameTest(); + $xpath->addCondition('position() = last()'); + + return $xpath; + } + + protected function xpath_first_of_type($xpath) + { + if ($xpath->getElement() == '*') + { + throw new SyntaxError("*:first-of-type is not implemented"); + } + $xpath->addStarPrefix(); + $xpath->addCondition('position() = 1'); + + return $xpath; + } + + protected function xpath_last_of_type($xpath) + { + if ($xpath->getElement() == '*') + { + throw new SyntaxError("*:last-of-type is not implemented"); + } + $xpath->addStarPrefix(); + $xpath->addCondition('position() = last()'); + + return $xpath; + } + + protected function xpath_only_child($xpath) + { + $xpath->addNameTest(); + $xpath->addStarPrefix(); + $xpath->addCondition('last() = 1'); + + return $xpath; + } + + protected function xpath_only_of_type($xpath) + { + if ($xpath->getElement() == '*') + { + throw new SyntaxError("*:only-of-type is not implemented"); + } + $xpath->addCondition('last() = 1'); + + return $xpath; + } + + protected function xpath_empty($xpath) + { + $xpath->addCondition("not(*) and not(normalize-space())"); + + return $xpath; + } +} diff --git a/src/Symfony/Components/CssSelector/Parser.php b/src/Symfony/Components/CssSelector/Parser.php new file mode 100644 index 0000000000000..62d37016e731f --- /dev/null +++ b/src/Symfony/Components/CssSelector/Parser.php @@ -0,0 +1,307 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Parser is the main entry point of the component and can convert CSS + * selectors to XPath expressions. + * + * $xpath = Parser::cssToXpath('h1.foo'); + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class Parser +{ + static public function cssToXpath($cssExpr, $prefix = 'descendant-or-self::') + { + if (is_string($cssExpr)) + { + if (preg_match('#^\w+\s*$#u', $cssExpr, $match)) + { + return $prefix.trim($match[0]); + } + + if (preg_match('~^(\w*)#(\w+)\s*$~u', $cssExpr, $match)) + { + return sprintf("%s%s[@id = '%s']", $prefix, $match[1] ? $match[1] : '*', $match[2]); + } + + if (preg_match('#^(\w*)\.(\w+)\s*$#u', $cssExpr, $match)) + { + return sprintf("%s%s[contains(concat(' ', normalize-space(@class), ' '), ' %s ')]", $prefix, $match[1] ? $match[1] : '*', $match[2]); + } + + $parser = new self(); + $cssExpr = $parser->parse($cssExpr); + } + + $expr = $cssExpr->toXpath(); + + // @codeCoverageIgnoreStart + if (!$expr) + { + throw new SyntaxError(sprintf("Got None for xpath expression from %s.", $cssExpr)); + } + // @codeCoverageIgnoreEnd + + if ($prefix) + { + $expr->addPrefix($prefix); + } + + return (string) $expr; + } + + public function parse($string) + { + $tokenizer = new Tokenizer(); + + $stream = new TokenStream($tokenizer->tokenize($string), $string); + + try + { + return $this->parseSelectorGroup($stream); + } + catch (\Exception $e) + { + $class = get_class($e); + + throw new $class(sprintf("%s at %s -> %s", $e->getMessage(), implode($stream->getUsed(), ''), $stream->peek())); + } + } + + protected function parseSelectorGroup($stream) + { + $result = array(); + while (1) + { + $result[] = $this->parseSelector($stream); + if ($stream->peek() == ',') + { + $stream->next(); + } + else + { + break; + } + } + + if (count($result) == 1) + { + return $result[0]; + } + else + { + return new Node\OrNode($result); + } + } + + protected function parseSelector($stream) + { + $result = $this->parseSimpleSelector($stream); + + while (1) + { + $peek = $stream->peek(); + if ($peek == ',' || $peek === null) + { + return $result; + } + elseif (in_array($peek, array('+', '>', '~'))) + { + # A combinator + $combinator = (string) $stream->next(); + } + else + { + $combinator = ' '; + } + $consumed = count($stream->getUsed()); + $next_selector = $this->parseSimpleSelector($stream); + if ($consumed == count($stream->getUsed())) + { + throw new SyntaxError(sprintf("Expected selector, got '%s'", $stream->peek())); + } + + $result = new Node\CombinedSelectorNode($result, $combinator, $next_selector); + } + + return $result; + } + + protected function parseSimpleSelector($stream) + { + $peek = $stream->peek(); + if ($peek != '*' && !$peek->isType('Symbol')) + { + $element = $namespace = '*'; + } + else + { + $next = $stream->next(); + if ($next != '*' && !$next->isType('Symbol')) + { + throw new SyntaxError(sprintf("Expected symbol, got '%s'", $next)); + } + + if ($stream->peek() == '|') + { + $namespace = $next; + $stream->next(); + $element = $stream->next(); + if ($element != '*' && !$next->isType('Symbol')) + { + throw new SyntaxError(sprintf("Expected symbol, got '%s'", $next)); + } + } + else + { + $namespace = '*'; + $element = $next; + } + } + + $result = new Node\ElementNode($namespace, $element); + $has_hash = false; + while (1) + { + $peek = $stream->peek(); + if ($peek == '#') + { + if ($has_hash) + { + # You can't have two hashes + # (FIXME: is there some more general rule I'm missing?) + // @codeCoverageIgnoreStart + break; + // @codeCoverageIgnoreEnd + } + $stream->next(); + $result = new Node\HashNode($result, $stream->next()); + $has_hash = true; + + continue; + } + elseif ($peek == '.') + { + $stream->next(); + $result = new Node\ClassNode($result, $stream->next()); + + continue; + } + elseif ($peek == '[') + { + $stream->next(); + $result = $this->parseAttrib($result, $stream); + $next = $stream->next(); + if ($next != ']') + { + throw new SyntaxError(sprintf("] expected, got '%s'", $next)); + } + + continue; + } + elseif ($peek == ':' || $peek == '::') + { + $type = $stream->next(); + $ident = $stream->next(); + if (!$ident || !$ident->isType('Symbol')) + { + throw new SyntaxError(sprintf("Expected symbol, got '%s'", $ident)); + } + + if ($stream->peek() == '(') + { + $stream->next(); + $peek = $stream->peek(); + if ($peek->isType('String')) + { + $selector = $stream->next(); + } + elseif ($peek->isType('Symbol') && is_int($peek)) + { + $selector = intval($stream->next()); + } + else + { + # FIXME: parseSimpleSelector, or selector, or...? + $selector = $this->parseSimpleSelector($stream); + } + $next = $stream->next(); + if ($next != ')') + { + throw new SyntaxError(sprintf("Expected ')', got '%s' and '%s'", $next, $selector)); + } + + $result = new Node\FunctionNode($result, $type, $ident, $selector); + } + else + { + $result = new Node\PseudoNode($result, $type, $ident); + } + + continue; + } + else + { + if ($peek == ' ') + { + $stream->next(); + } + + break; + } + # FIXME: not sure what "negation" is + } + + return $result; + } + + protected function parseAttrib($selector, $stream) + { + $attrib = $stream->next(); + if ($stream->peek() == '|') + { + $namespace = $attrib; + $stream->next(); + $attrib = $stream->next(); + } + else + { + $namespace = '*'; + } + + if ($stream->peek() == ']') + { + return new Node\AttribNode($selector, $namespace, $attrib, 'exists', null); + } + + $op = $stream->next(); + if (!in_array($op, array('^=', '$=', '*=', '=', '~=', '|=', '!='))) + { + throw new SyntaxError(sprintf("Operator expected, got '%s'", $op)); + } + + $value = $stream->next(); + if (!$value->isType('Symbol') && !$value->isType('String')) + { + throw new SyntaxError(sprintf("Expected string or symbol, got '%s'", $value)); + } + + return new Node\AttribNode($selector, $namespace, $attrib, $op, $value); + } +} diff --git a/src/Symfony/Components/CssSelector/README b/src/Symfony/Components/CssSelector/README new file mode 100644 index 0000000000000..9a52f5637460a --- /dev/null +++ b/src/Symfony/Components/CssSelector/README @@ -0,0 +1,4 @@ +This component is a port of the Python lxml library, +which is copyright Infrae and distributed under the BSD license. + +Current code is a port of http://codespeak.net/svn/lxml/trunk/src/lxml/cssselect.py@71545 diff --git a/src/Symfony/Components/CssSelector/SyntaxError.php b/src/Symfony/Components/CssSelector/SyntaxError.php new file mode 100644 index 0000000000000..47a3d9334ba88 --- /dev/null +++ b/src/Symfony/Components/CssSelector/SyntaxError.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * SyntaxError is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class SyntaxError extends \LogicException +{ +} diff --git a/src/Symfony/Components/CssSelector/Token.php b/src/Symfony/Components/CssSelector/Token.php new file mode 100644 index 0000000000000..8102816970b2b --- /dev/null +++ b/src/Symfony/Components/CssSelector/Token.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Token represents a CSS Selector token. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class Token +{ + protected $type; + protected $value; + protected $position; + + public function __construct($type, $value, $position) + { + $this->type = $type; + $this->value = $value; + $this->position = $position; + } + + public function __toString() + { + return (string) $this->value; + } + + public function isType($type) + { + return $this->type == $type; + } + + public function getPosition() + { + return $this->position; + } +} diff --git a/src/Symfony/Components/CssSelector/TokenStream.php b/src/Symfony/Components/CssSelector/TokenStream.php new file mode 100644 index 0000000000000..6c3c0cc1c54db --- /dev/null +++ b/src/Symfony/Components/CssSelector/TokenStream.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * TokenStream represents a stream of CSS Selector tokens. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class TokenStream +{ + protected $used; + protected $tokens; + protected $source; + protected $peeked; + protected $peeking; + + public function __construct($tokens, $source = null) + { + $this->used = array(); + $this->tokens = $tokens; + $this->source = $source; + $this->peeked = null; + $this->peeking = false; + } + + public function getUsed() + { + return $this->used; + } + + public function next() + { + if ($this->peeking) + { + $this->peeking = false; + $this->used[] = $this->peeked; + + return $this->peeked; + } + else + { + if (!count($this->tokens)) + { + return null; + } + + $next = array_shift($this->tokens); + $this->used[] = $next; + + return $next; + } + } + + public function peek() + { + if (!$this->peeking) + { + if (!count($this->tokens)) + { + return null; + } + + $this->peeked = array_shift($this->tokens); + + $this->peeking = true; + } + + return $this->peeked; + } +} diff --git a/src/Symfony/Components/CssSelector/Tokenizer.php b/src/Symfony/Components/CssSelector/Tokenizer.php new file mode 100644 index 0000000000000..7e0838975833a --- /dev/null +++ b/src/Symfony/Components/CssSelector/Tokenizer.php @@ -0,0 +1,183 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Tokenizer lexes a CSS Selector to tokens. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class Tokenizer +{ + public function tokenize($s) + { + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) + { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + + $tokens = array(); + $pos = 0; + $s = preg_replace('#/\*.*?\*/#s', '', $s); + + while (1) + { + if (preg_match('#\s+#A', $s, $match, 0, $pos)) + { + $preceding_whitespace_pos = $pos; + $pos += strlen($match[0]); + } + else + { + $preceding_whitespace_pos = 0; + } + + if ($pos >= strlen($s)) + { + if (isset($mbEncoding)) + { + mb_internal_encoding($mbEncoding); + } + + return $tokens; + } + + if (preg_match('#[+-]?\d*n(?:[+-]\d+)?#A', $s, $match, 0, $pos) && 'n' !== $match[0]) + { + $sym = substr($s, $pos, strlen($match[0])); + $tokens[] = new Token('Symbol', $sym, $pos); + $pos += strlen($match[0]); + + continue; + } + + $c = $s[$pos]; + $c2 = substr($s, $pos, 2); + if (in_array($c2, array('~=', '|=', '^=', '$=', '*=', '::', '!='))) + { + $tokens[] = new Token('Token', $c2, $pos); + $pos += 2; + + continue; + } + + if (in_array($c, array('>', '+', '~', ',', '.', '*', '=', '[', ']', '(', ')', '|', ':', '#'))) + { + if (in_array($c, array('.', '#', '[')) && $preceding_whitespace_pos > 0) + { + $tokens[] = new Token('Token', ' ', $preceding_whitespace_pos); + } + $tokens[] = new Token('Token', $c, $pos); + ++$pos; + + continue; + } + + if ($c === '"' || $c === "'") + { + # Quoted string + $old_pos = $pos; + list($sym, $pos) = $this->tokenizeEscapedString($s, $pos); + + $tokens[] = new Token('String', $sym, $old_pos); + + continue; + } + + $old_pos = $pos; + list($sym, $pos) = $this->tokenizeSymbol($s, $pos); + + $tokens[] = new Token('Symbol', $sym, $old_pos); + + continue; + } + } + + protected function tokenizeEscapedString($s, $pos) + { + $quote = $s[$pos]; + + $pos = $pos + 1; + $start = $pos; + while (1) + { + $next = strpos($s, $quote, $pos); + if (false === $next) + { + throw new SyntaxError(sprintf("Expected closing %s for string in: %s", $quote, substr($s, $start))); + } + + $result = substr($s, $start, $next - $start); + if ('\\' === $result[strlen($result) - 1]) + { + # next quote character is escaped + $pos = $next + 1; + $continue; + } + + if (false !== strpos($result, '\\')) + { + $result = $this->unescapeStringLiteral($result); + } + + return array($result, $next + 1); + } + } + + protected function unescapeStringLiteral($literal) + { + return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal) + { + if ($matches[0][0] == '\\' && strlen($matches[0]) > 1) + { + $matches[0] = substr($matches[0], 1); + if (in_array($matches[0][0], array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'))) + { + return chr(trim($matches[0])); + } + } + else + { + throw new SyntaxError(sprintf("Invalid escape sequence %s in string %s", $matches[0], $literal)); + } + }, $literal); + } + + protected function tokenizeSymbol($s, $pos) + { + $start = $pos; + + if (!preg_match('#[^\w\-]#', $s, $match, PREG_OFFSET_CAPTURE, $pos)) + { + # Goes to end of s + return array(substr($s, $start), strlen($s)); + } + + $matchStart = $match[0][1]; + + if ($matchStart == $pos) + { + throw new SyntaxError(sprintf("Unexpected symbol: %s at %s", $s[$pos], $pos)); + } + + $result = substr($s, $start, $matchStart - $start); + $pos = $matchStart; + + return array($result, $pos); + } +} diff --git a/src/Symfony/Components/CssSelector/XPathExpr.php b/src/Symfony/Components/CssSelector/XPathExpr.php new file mode 100644 index 0000000000000..b8ba679db49d6 --- /dev/null +++ b/src/Symfony/Components/CssSelector/XPathExpr.php @@ -0,0 +1,185 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * XPathExpr represents an XPath expression. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class XPathExpr +{ + protected $prefix; + protected $path; + protected $element; + protected $condition; + protected $starPrefix; + + public function __construct($prefix = null, $path = null, $element = '*', $condition = null, $starPrefix = false) + { + $this->prefix = $prefix; + $this->path = $path; + $this->element = $element; + $this->condition = $condition; + $this->starPrefix = $starPrefix; + } + + public function getElement() + { + return $this->element; + } + + public function getCondition() + { + return $this->condition; + } + + public function __toString() + { + $path = ''; + if (null !== $this->prefix) + { + $path .= $this->prefix; + } + + if (null !== $this->path) + { + $path .= $this->path; + } + + $path .= $this->element; + + if ($this->condition) + { + $path .= sprintf('[%s]', $this->condition); + } + + return $path; + } + + public function addCondition($condition) + { + if ($this->condition) + { + $this->condition = sprintf('%s and (%s)', $this->condition, $condition); + } + else + { + $this->condition = $condition; + } + } + + public function addPrefix($prefix) + { + if ($this->prefix) + { + $this->prefix = $prefix.$this->prefix; + } + else + { + $this->prefix = $prefix; + } + } + + public function addNameTest() + { + if ($this->element == '*') + { + # We weren't doing a test anyway + return; + } + + $this->addCondition(sprintf("name() = %s", XPathExpr::xpathLiteral($this->element))); + $this->element = '*'; + } + + public function addStarPrefix() + { + /* + Adds a /* prefix if there is no prefix. This is when you need + to keep context's constrained to a single parent. + */ + if ($this->path) + { + $this->path .= '*/'; + } + else + { + $this->path = '*/'; + } + + $this->starPrefix = true; + } + + public function join($combiner, $other) + { + $prefix = (string) $this; + + $prefix .= $combiner; + $path = $other->prefix.$other->path; + + # We don't need a star prefix if we are joining to this other + # prefix; so we'll get rid of it + if ($other->starPrefix && $path == '*/') + { + $path = ''; + } + $this->prefix = $prefix; + $this->path = $path; + $this->element = $other->element; + $this->condition = $other->condition; + } + + static public function xpathLiteral($s) + { + if ($s instanceof Node\ElementNode) + { + # This is probably a symbol that looks like an expression... + $s = $s->formatElement(); + } + else + { + $s = (string) $s; + } + + if (false === strpos($s, "'")) + { + $s = sprintf("'%s'", $s); + } + elseif (false === strpos($s, '"')) + { + $s = sprintf('"%s"', $s); + } + else + { + $tmp = array(); + foreach (preg_split("#('+)#", $s) as $part) + { + if (!$part) + { + continue; + } + + $tmp[] = sprintf(false !== strpos($part, "'") ? '"%s"' : "'%s'", $part); + } + + $s = sprintf("concat(%s)", implode($tmp, ',')); + } + + return $s; + } +} diff --git a/src/Symfony/Components/CssSelector/XPathExprOr.php b/src/Symfony/Components/CssSelector/XPathExprOr.php new file mode 100644 index 0000000000000..28cf88e8ef38a --- /dev/null +++ b/src/Symfony/Components/CssSelector/XPathExprOr.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * XPathExprOr represents XPath |'d expressions. + * + * Note that unfortunately it isn't the union, it's the sum, so duplicate elements will appear. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @package symfony + * @subpackage css_selector + * @author Fabien Potencier + */ +class XPathExprOr extends XPathExpr +{ + public function __construct($items, $prefix = null) + { + $this->items = $items; + $this->prefix = $prefix; + } + + public function __toString() + { + $prefix = $this->prefix; + + $tmp = array(); + foreach ($this->items as $i) + { + $tmp[] = sprintf("%s%s", $prefix, $i); + } + + return implode($tmp, ' | '); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/AttribNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/AttribNodeTest.php new file mode 100644 index 0000000000000..80d73b1886f44 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/AttribNodeTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\AttribNode; +use Symfony\Components\CssSelector\Node\ElementNode; + +class AttribNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + $element = new ElementNode('*', 'h1'); + + $operators = array( + '^=' => "h1[starts-with(@class, 'foo')]", + '$=' => "h1[substring(@class, string-length(@class)-2) = 'foo']", + '*=' => "h1[contains(@class, 'foo')]", + '=' => "h1[@class = 'foo']", + '~=' => "h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", + '|=' => "h1[@class = 'foo' or starts-with(@class, 'foo-')]", + '!=' => "h1[not(@class) or @class != 'foo']", + ); + + // h1[class??foo] + foreach ($operators as $op => $xpath) + { + $attrib = new AttribNode($element, '*', 'class', $op, 'foo'); + $this->assertEquals($xpath, (string) $attrib->toXpath(), '->toXpath() returns the xpath representation of the node'); + } + + // h1[class] + $attrib = new AttribNode($element, '*', 'class', 'exists', 'foo'); + $this->assertEquals('h1[@class]', (string) $attrib->toXpath(), '->toXpath() returns the xpath representation of the node'); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/ClassNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/ClassNodeTest.php new file mode 100644 index 0000000000000..174cc006d61ca --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/ClassNodeTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\ClassNode; +use Symfony\Components\CssSelector\Node\ElementNode; + +class ClassNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + // h1.foo + $element = new ElementNode('*', 'h1'); + $class = new ClassNode($element, 'foo'); + + $this->assertEquals("h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", (string) $class->toXpath(), '->toXpath() returns the xpath representation of the node'); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/CombinedSelectorNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/CombinedSelectorNodeTest.php new file mode 100644 index 0000000000000..ef24c3a940c6b --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/CombinedSelectorNodeTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\CombinedSelectorNode; +use Symfony\Components\CssSelector\Node\ElementNode; + +class CombinedSelectorNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + $combinators = array( + ' ' => "h1/descendant::p", + '>' => "h1/p", + '+' => "h1/following-sibling::*[name() = 'p' and (position() = 1)]", + '~' => "h1/following-sibling::p", + ); + + // h1 ?? p + $element1 = new ElementNode('*', 'h1'); + $element2 = new ElementNode('*', 'p'); + foreach ($combinators as $combinator => $xpath) + { + $combinator = new CombinedSelectorNode($element1, $combinator, $element2); + $this->assertEquals($xpath, (string) $combinator->toXpath(), '->toXpath() returns the xpath representation of the node'); + } + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/ElementNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/ElementNodeTest.php new file mode 100644 index 0000000000000..fed2686eb2a24 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/ElementNodeTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\ElementNode; + +class ElementNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + // h1 + $element = new ElementNode('*', 'h1'); + + $this->assertEquals('h1', (string) $element->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // foo|h1 + $element = new ElementNode('foo', 'h1'); + + $this->assertEquals('foo:h1', (string) $element->toXpath(), '->toXpath() returns the xpath representation of the node'); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/FunctionNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/FunctionNodeTest.php new file mode 100644 index 0000000000000..a34924e2d53a6 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/FunctionNodeTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\FunctionNode; +use Symfony\Components\CssSelector\Node\ElementNode; +use Symfony\Components\CssSelector\Token; + +class FunctionNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + $element = new ElementNode('*', 'h1'); + + // h1:contains("foo") + $function = new FunctionNode($element, ':', 'contains', 'foo'); + $this->assertEquals("h1[contains(css:lower-case(string(.)), 'foo')]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(1) + $function = new FunctionNode($element, ':', 'nth-child', 1); + $this->assertEquals("*/*[name() = 'h1' and (position() = 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child() + $function = new FunctionNode($element, ':', 'nth-child', ''); + $this->assertEquals("h1[false() and position() = 0]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(odd) + $element2 = new ElementNode('*', new Token('Symbol', 'odd', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and ((position() -1) mod 2 = 0 and position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(even) + $element2 = new ElementNode('*', new Token('Symbol', 'even', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and ((position() +0) mod 2 = 0 and position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(n) + $element2 = new ElementNode('*', new Token('Symbol', 'n', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and (position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(3n+1) + $element2 = new ElementNode('*', new Token('Symbol', '3n+1', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and ((position() -1) mod 3 = 0 and position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(n+1) + $element2 = new ElementNode('*', new Token('Symbol', 'n+1', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and (position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(2n) + $element2 = new ElementNode('*', new Token('Symbol', '2n', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and ((position() +0) mod 2 = 0 and position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-child(-n) + $element2 = new ElementNode('*', new Token('Symbol', '-n', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and ((position() +0) mod -1 = 0 and position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-last-child(2) + $function = new FunctionNode($element, ':', 'nth-last-child', 2); + $this->assertEquals("*/*[name() = 'h1' and (position() = last() - 2)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-of-type(2) + $function = new FunctionNode($element, ':', 'nth-of-type', 2); + $this->assertEquals("*/h1[position() = 2]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:nth-last-of-type(2) + $function = new FunctionNode($element, ':', 'nth-last-of-type', 2); + $this->assertEquals("*/h1[position() = last() - 2]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + + /* + // h1:not(p) + $element2 = new ElementNode('*', 'p'); + $function = new FunctionNode($element, ':', 'not', $element2); + + $this->assertEquals("h1[not()]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + */ + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/HashNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/HashNodeTest.php new file mode 100644 index 0000000000000..245a0eb233a49 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/HashNodeTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\HashNode; +use Symfony\Components\CssSelector\Node\ElementNode; + +class HashNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + // h1#foo + $element = new ElementNode('*', 'h1'); + $hash = new HashNode($element, 'foo'); + + $this->assertEquals("h1[@id = 'foo']", (string) $hash->toXpath(), '->toXpath() returns the xpath representation of the node'); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/OrNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/OrNodeTest.php new file mode 100644 index 0000000000000..76d6d97db9d0b --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/OrNodeTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\OrNode; +use Symfony\Components\CssSelector\Node\ElementNode; + +class OrNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + // h1, h2, h3 + $element1 = new ElementNode('*', 'h1'); + $element2 = new ElementNode('*', 'h2'); + $element3 = new ElementNode('*', 'h3'); + $or = new OrNode(array($element1, $element2, $element3)); + + $this->assertEquals("h1 | h2 | h3", (string) $or->toXpath(), '->toXpath() returns the xpath representation of the node'); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/Node/PseudoNodeTest.php b/tests/Symfony/Tests/Components/CssSelector/Node/PseudoNodeTest.php new file mode 100644 index 0000000000000..e96763a71baf0 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/Node/PseudoNodeTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector\Node; + +use Symfony\Components\CssSelector\Node\PseudoNode; +use Symfony\Components\CssSelector\Node\ElementNode; + +class PseudoNodeTest extends \PHPUnit_Framework_TestCase +{ + public function testToXpath() + { + $element = new ElementNode('*', 'h1'); + + // h1:checked + $pseudo = new PseudoNode($element, ':', 'checked'); + $this->assertEquals("h1[(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:first-child + $pseudo = new PseudoNode($element, ':', 'first-child'); + $this->assertEquals("*/*[name() = 'h1' and (position() = 1)]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:last-child + $pseudo = new PseudoNode($element, ':', 'last-child'); + $this->assertEquals("*/*[name() = 'h1' and (position() = last())]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:first-of-type + $pseudo = new PseudoNode($element, ':', 'first-of-type'); + $this->assertEquals("*/h1[position() = 1]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:last-of-type + $pseudo = new PseudoNode($element, ':', 'last-of-type'); + $this->assertEquals("*/h1[position() = last()]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:only-child + $pseudo = new PseudoNode($element, ':', 'only-child'); + $this->assertEquals("*/*[name() = 'h1' and (last() = 1)]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:only-of-type + $pseudo = new PseudoNode($element, ':', 'only-of-type'); + $this->assertEquals("h1[last() = 1]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + + // h1:empty + $pseudo = new PseudoNode($element, ':', 'empty'); + $this->assertEquals("h1[not(*) and not(normalize-space())]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/ParserTest.php b/tests/Symfony/Tests/Components/CssSelector/ParserTest.php new file mode 100644 index 0000000000000..aa11bc4657de1 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/ParserTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector; + +use Symfony\Components\CssSelector\Parser; + +class ParserTest extends \PHPUnit_Framework_TestCase +{ + public function testCssToXpath() + { + $this->assertEquals('descendant-or-self::h1', Parser::cssToXpath('h1')); + $this->assertEquals("descendant-or-self::h1[@id = 'foo']", Parser::cssToXpath('h1#foo')); + $this->assertEquals("descendant-or-self::h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", Parser::cssToXpath('h1.foo')); + + $this->assertEquals('descendant-or-self::foo:h1', Parser::cssToXpath('foo|h1')); + } + + public function testParse() + { + $parser = new Parser(); + + $tests = array( + 'h1' => "h1", + 'foo|h1' => "foo:h1", + 'h1, h2, h3' => "h1 | h2 | h3", + 'h1:nth-child(3n+1)' => "*/*[name() = 'h1' and ((position() -1) mod 3 = 0 and position() >= 1)]", + 'h1 > p' => "h1/p", + 'h1#foo' => "h1[@id = 'foo']", + 'h1.foo' => "h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", + 'h1[class*="foo bar"]' => "h1[contains(@class, 'foo bar')]", + 'h1[foo|class*="foo bar"]' => "h1[contains(@foo:class, 'foo bar')]", + 'h1[class]' => "h1[@class]", + 'h1 .foo' => "h1/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", + 'h1 #foo' => "h1/descendant::*[@id = 'foo']", + 'h1 [class*=foo]' => "h1/descendant::*[contains(@class, 'foo')]", + ); + + foreach ($tests as $selector => $xpath) + { + $this->assertEquals($xpath, (string) $parser->parse($selector)->toXpath(), '->parse() parses an input string and returns a node'); + } + + try + { + $parser->parse('h1:'); + $this->fail('->parse() throws an Exception if the css selector is not valid'); + } + catch (\Exception $e) + { + $this->assertEquals("Expected symbol, got '' at h1: -> ", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid'); + } + } +} diff --git a/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php b/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php new file mode 100644 index 0000000000000..fd3fe0163ed25 --- /dev/null +++ b/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Tests\Components\CssSelector; + +use Symfony\Components\CssSelector\Tokenizer; + +class TokenizerTest extends \PHPUnit_Framework_TestCase +{ + public function testTokenize() + { + $tokenizer = new Tokenizer(); + + $tests = array( + 'h1', + 'h1:nth-child(3n+1)', + 'h1 > p', + 'h1#foo', + 'h1.foo', + 'h1[class*=foo]', + 'h1 .foo', + 'h1 #foo', + 'h1 [class*=foo]', + ); + + foreach ($tests as $test) + { + $this->assertEquals($test, $this->tokensToString($tokenizer->tokenize($test)), '->tokenize() lexes an input string and returns an array of tokens'); + } + + $this->assertEquals('foo[class=foo bar ]', $this->tokensToString($tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); + $this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); + } + + protected function tokensToString($tokens) + { + $str = ''; + foreach ($tokens as $token) + { + $str .= str_repeat(' ', $token->getPosition() - strlen($str)).$token; + } + + return $str; + } +} From a0572e3893a950d4543549c1d66b1d69a2f624d3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Apr 2010 21:19:48 +0800 Subject: [PATCH 33/54] [CssSelector] refactored some tests to use @dataProvider --- .../Components/CssSelector/ParserTest.php | 48 +++++++++-------- .../Components/CssSelector/TokenizerTest.php | 51 +++++++++++-------- 2 files changed, 59 insertions(+), 40 deletions(-) diff --git a/tests/Symfony/Tests/Components/CssSelector/ParserTest.php b/tests/Symfony/Tests/Components/CssSelector/ParserTest.php index aa11bc4657de1..08eb645447624 100644 --- a/tests/Symfony/Tests/Components/CssSelector/ParserTest.php +++ b/tests/Symfony/Tests/Components/CssSelector/ParserTest.php @@ -24,30 +24,19 @@ public function testCssToXpath() $this->assertEquals('descendant-or-self::foo:h1', Parser::cssToXpath('foo|h1')); } - public function testParse() + /** + * @dataProvider getCssSelectors + */ + public function testParse($css, $xpath) { $parser = new Parser(); - $tests = array( - 'h1' => "h1", - 'foo|h1' => "foo:h1", - 'h1, h2, h3' => "h1 | h2 | h3", - 'h1:nth-child(3n+1)' => "*/*[name() = 'h1' and ((position() -1) mod 3 = 0 and position() >= 1)]", - 'h1 > p' => "h1/p", - 'h1#foo' => "h1[@id = 'foo']", - 'h1.foo' => "h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", - 'h1[class*="foo bar"]' => "h1[contains(@class, 'foo bar')]", - 'h1[foo|class*="foo bar"]' => "h1[contains(@foo:class, 'foo bar')]", - 'h1[class]' => "h1[@class]", - 'h1 .foo' => "h1/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", - 'h1 #foo' => "h1/descendant::*[@id = 'foo']", - 'h1 [class*=foo]' => "h1/descendant::*[contains(@class, 'foo')]", - ); + $this->assertEquals($xpath, (string) $parser->parse($css)->toXpath(), '->parse() parses an input string and returns a node'); + } - foreach ($tests as $selector => $xpath) - { - $this->assertEquals($xpath, (string) $parser->parse($selector)->toXpath(), '->parse() parses an input string and returns a node'); - } + public function testParseExceptions() + { + $parser = new Parser(); try { @@ -59,4 +48,23 @@ public function testParse() $this->assertEquals("Expected symbol, got '' at h1: -> ", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid'); } } + + public function getCssSelectors() + { + return array( + array('h1', "h1"), + array('foo|h1', "foo:h1"), + array('h1, h2, h3', "h1 | h2 | h3"), + array('h1:nth-child(3n+1)', "*/*[name() = 'h1' and ((position() -1) mod 3 = 0 and position() >= 1)]"), + array('h1 > p', "h1/p"), + array('h1#foo', "h1[@id = 'foo']"), + array('h1.foo', "h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1[class*="foo bar"]', "h1[contains(@class, 'foo bar')]"), + array('h1[foo|class*="foo bar"]', "h1[contains(@foo:class, 'foo bar')]"), + array('h1[class]', "h1[@class]"), + array('h1 .foo', "h1/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1 #foo', "h1/descendant::*[@id = 'foo']"), + array('h1 [class*=foo]', "h1/descendant::*[contains(@class, 'foo')]"), + ); + } } diff --git a/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php b/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php index fd3fe0163ed25..95cbdb4556c05 100644 --- a/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php +++ b/tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php @@ -15,29 +15,40 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase { - public function testTokenize() + protected $tokenizer; + + public function setUp() { - $tokenizer = new Tokenizer(); - - $tests = array( - 'h1', - 'h1:nth-child(3n+1)', - 'h1 > p', - 'h1#foo', - 'h1.foo', - 'h1[class*=foo]', - 'h1 .foo', - 'h1 #foo', - 'h1 [class*=foo]', - ); + $this->tokenizer = new Tokenizer(); + } - foreach ($tests as $test) - { - $this->assertEquals($test, $this->tokensToString($tokenizer->tokenize($test)), '->tokenize() lexes an input string and returns an array of tokens'); - } + /** + * @dataProvider getCssSelectors + */ + public function testTokenize($css) + { + $this->assertEquals($css, $this->tokensToString($this->tokenizer->tokenize($css)), '->tokenize() lexes an input string and returns an array of tokens'); + } + + public function testTokenizeWithQuotedStrings() + { + $this->assertEquals('foo[class=foo bar ]', $this->tokensToString($this->tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); + $this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); + } - $this->assertEquals('foo[class=foo bar ]', $this->tokensToString($tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); - $this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); + public function getCssSelectors() + { + return array( + array('h1'), + array('h1:nth-child(3n+1)'), + array('h1 > p'), + array('h1#foo'), + array('h1.foo'), + array('h1[class*=foo]'), + array('h1 .foo'), + array('h1 #foo'), + array('h1 [class*=foo]'), + ); } protected function tokensToString($tokens) From 1bba4a33525a4711175a2a3c785743df2510a292 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Apr 2010 22:47:59 +0800 Subject: [PATCH 34/54] [Foundation] made the Kernel serializable (to avoid weird error messages when used with PHPUnit) --- src/Symfony/Foundation/Kernel.php | 14 +++++++++++++- src/Symfony/Foundation/bootstrap.php | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 9ee03a2156743..666fd137dcafc 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -25,7 +25,7 @@ * @package Symfony * @author Fabien Potencier */ -abstract class Kernel +abstract class Kernel implements \Serializable { protected $bundles; protected $bundleDirs; @@ -380,4 +380,16 @@ protected function writeCacheFile($file, $content) @rename($tmpFile, $file); chmod($file, 0644); } + + public function serialize() + { + return serialize(array($this->environment, $this->debug)); + } + + public function unserialize($data) + { + list($environment, $debug) = unserialize($data); + + $this->__construct($environment, $debug); + } } diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index aa0d7ab5026ed..189f61bb4ee87 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -320,7 +320,7 @@ static protected function writeCacheFile($file, $content) use Symfony\Components\RequestHandler\RequestInterface; -abstract class Kernel +abstract class Kernel implements \Serializable { protected $bundles; protected $bundleDirs; @@ -649,6 +649,18 @@ protected function writeCacheFile($file, $content) @rename($tmpFile, $file); chmod($file, 0644); } + + public function serialize() + { + return serialize(array($this->environment, $this->debug)); + } + + public function unserialize($data) + { + list($environment, $debug) = unserialize($data); + + $this->__construct($environment, $debug); + } } From 9262a1834c534e95030504b9ae4708388860db12 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Apr 2010 23:21:45 +0800 Subject: [PATCH 35/54] [WebBundle] fixed Symfony version in the text exception message --- .../WebBundle/Resources/views/Exception/exception.txt.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Framework/WebBundle/Resources/views/Exception/exception.txt.php b/src/Symfony/Framework/WebBundle/Resources/views/Exception/exception.txt.php index c936eb1cedf8c..7148201f49bae 100644 --- a/src/Symfony/Framework/WebBundle/Resources/views/Exception/exception.txt.php +++ b/src/Symfony/Framework/WebBundle/Resources/views/Exception/exception.txt.php @@ -1,5 +1,7 @@ [exception] + [message] + 0): ?> [stack trace] @@ -7,5 +9,5 @@ -[symfony] v. (symfony-project.org) +[symfony] v. (symfony-project.org) [PHP] v. From 448051a21d0214b1555d274a829231af47da3e90 Mon Sep 17 00:00:00 2001 From: Daniel Cestari Date: Mon, 5 Apr 2010 01:07:18 +0800 Subject: [PATCH 36/54] [Foundation] updated link to the PHP 5.3's final proposal for autoloader interoperability --- src/Symfony/Foundation/UniversalClassLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Foundation/UniversalClassLoader.php b/src/Symfony/Foundation/UniversalClassLoader.php index 11bdbcf658ec1..69ed68798ef2d 100644 --- a/src/Symfony/Foundation/UniversalClassLoader.php +++ b/src/Symfony/Foundation/UniversalClassLoader.php @@ -17,7 +17,7 @@ * It is able to load classes that use either: * * * The technical interoperability standards for PHP 5.3 namespaces and - * class names (http://groups.google.com/group/php-standards/web/final-proposal); + * class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal); * * * The PEAR naming convention for classes (http://pear.php.net/). * From 6b04e265aee0c3db7575eb73de9976d90cba070a Mon Sep 17 00:00:00 2001 From: Daniel Cestari Date: Mon, 5 Apr 2010 01:08:44 +0800 Subject: [PATCH 37/54] [WebBundle] updated application's skeleton routing.yml --- .../Resources/skeleton/application/yaml/config/routing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Framework/WebBundle/Resources/skeleton/application/yaml/config/routing.yml b/src/Symfony/Framework/WebBundle/Resources/skeleton/application/yaml/config/routing.yml index 215d42a413e8d..d46c8276604c5 100644 --- a/src/Symfony/Framework/WebBundle/Resources/skeleton/application/yaml/config/routing.yml +++ b/src/Symfony/Framework/WebBundle/Resources/skeleton/application/yaml/config/routing.yml @@ -1,3 +1,3 @@ homepage: pattern: / - default: { _bundle: WebBundle, _controller: Default, _action: index } + defaults: { _bundle: WebBundle, _controller: Default, _action: index } From 1115c4797d1ec6144cd0ecd94f69cde250425237 Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Sat, 3 Apr 2010 07:28:53 +0800 Subject: [PATCH 38/54] [OutputEscaper] fixed coding standards: opening brace should be on a new line --- src/Symfony/Components/OutputEscaper/Escaper.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Components/OutputEscaper/Escaper.php b/src/Symfony/Components/OutputEscaper/Escaper.php index 19d0440a36dfb..44b879df12870 100644 --- a/src/Symfony/Components/OutputEscaper/Escaper.php +++ b/src/Symfony/Components/OutputEscaper/Escaper.php @@ -348,7 +348,10 @@ function ($value) * @param string $value the value to escape * @return string the escaped value */ - function ($value) { return $value; }, + function ($value) + { + return $value; + }, 'js' => /** @@ -363,7 +366,10 @@ function ($value) { return $value; }, * @param string $value the value to escape * @return string the escaped value */ - function ($value) { return str_replace(array("\\" , "\n" , "\r" , "\"" , "'" ), array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), (is_string($value) ? htmlentities($value, ENT_QUOTES, Escaper::getCharset()) : $value)); }, + function ($value) + { + return str_replace(array("\\" , "\n" , "\r" , "\"" , "'" ), array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), (is_string($value) ? htmlentities($value, ENT_QUOTES, Escaper::getCharset()) : $value)); + }, 'js_no_entities' => /** @@ -373,7 +379,10 @@ function ($value) { return str_replace(array("\\" , "\n" , "\r" , "\"" , "'" * @param string $value the value to escape * @return string the escaped value */ - function ($value) { return str_replace(array("\\" , "\n" , "\r" , "\"" , "'" ), array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), $value); }, + function ($value) + { + return str_replace(array("\\" , "\n" , "\r" , "\"" , "'" ), array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), $value); + }, ); } } From 8d3757fe69ae193adf90d20b826c5fd45c6642fb Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Sat, 3 Apr 2010 07:37:58 +0800 Subject: [PATCH 39/54] [OutputEscaper] fixed coding standard: removed useless else statements --- .../Components/OutputEscaper/Escaper.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Components/OutputEscaper/Escaper.php b/src/Symfony/Components/OutputEscaper/Escaper.php index 44b879df12870..2d3011081b044 100644 --- a/src/Symfony/Components/OutputEscaper/Escaper.php +++ b/src/Symfony/Components/OutputEscaper/Escaper.php @@ -127,26 +127,28 @@ static public function escape($escaper, $value) return $copy; } - elseif (self::isClassMarkedAsSafe(get_class($value))) + + if (self::isClassMarkedAsSafe(get_class($value))) { // the class or one of its children is marked as safe // return the unescaped object return $value; } - elseif ($value instanceof SafeDecorator) + + if ($value instanceof SafeDecorator) { // do not escape objects marked as safe // return the original object return $value->getValue(); } - elseif ($value instanceof \Traversable) + + if ($value instanceof \Traversable) { return new IteratorDecorator($escaper, $value); } - else - { - return new ObjectDecorator($escaper, $value); - } + + return new ObjectDecorator($escaper, $value); + } // it must be a resource; cannot escape that. @@ -173,7 +175,8 @@ static public function unescape($value) { return html_entity_decode($value, ENT_QUOTES, self::$charset); } - elseif (is_array($value)) + + if (is_array($value)) { foreach ($value as $name => $v) { @@ -182,7 +185,8 @@ static public function unescape($value) return $value; } - elseif (is_object($value)) + + if (is_object($value)) { return $value instanceof Escaper ? $value->getRawValue() : $value; } From 8ed32b25cfb11bae6e558c2dd96bcdeb0df81d99 Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Sat, 3 Apr 2010 07:48:10 +0800 Subject: [PATCH 40/54] [CssSelector] fixed coding standards: removed perl comment style --- .../CssSelector/Node/AttribNode.php | 12 +++---- .../CssSelector/Node/CombinedSelectorNode.php | 8 ++--- .../CssSelector/Node/ElementNode.php | 2 +- .../CssSelector/Node/FunctionNode.php | 32 +++++++++---------- .../CssSelector/Node/PseudoNode.php | 4 +-- src/Symfony/Components/CssSelector/Parser.php | 10 +++--- .../Components/CssSelector/Tokenizer.php | 6 ++-- .../Components/CssSelector/XPathExpr.php | 8 ++--- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/Symfony/Components/CssSelector/Node/AttribNode.php b/src/Symfony/Components/CssSelector/Node/AttribNode.php index b123b2f880a70..ca698ea8f41e5 100644 --- a/src/Symfony/Components/CssSelector/Node/AttribNode.php +++ b/src/Symfony/Components/CssSelector/Node/AttribNode.php @@ -68,7 +68,7 @@ public function toXpath() } elseif ($this->operator == '!=') { - # FIXME: this seems like a weird hack... + // FIXME: this seems like a weird hack... if ($value) { $path->addCondition(sprintf('not(%s) or %s != %s', $attrib, $attrib, XPathExpr::xpathLiteral($value))); @@ -77,7 +77,7 @@ public function toXpath() { $path->addCondition(sprintf('%s != %s', $attrib, XPathExpr::xpathLiteral($value))); } - #path.addCondition('%s != %s' % (attrib, xpathLiteral(value))) + // path.addCondition('%s != %s' % (attrib, xpathLiteral(value))) } elseif ($this->operator == '~=') { @@ -85,7 +85,7 @@ public function toXpath() } elseif ($this->operator == '|=') { - # Weird, but true... + // Weird, but true... $path->addCondition(sprintf('%s = %s or starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value), $attrib, XPathExpr::xpathLiteral($value.'-'))); } elseif ($this->operator == '^=') @@ -94,12 +94,12 @@ public function toXpath() } elseif ($this->operator == '$=') { - # Oddly there is a starts-with in XPath 1.0, but not ends-with + // Oddly there is a starts-with in XPath 1.0, but not ends-with $path->addCondition(sprintf('substring(%s, string-length(%s)-%s) = %s', $attrib, $attrib, strlen($value) - 1, XPathExpr::xpathLiteral($value))); } elseif ($this->operator == '*=') { - # FIXME: case sensitive? + // FIXME: case sensitive? $path->addCondition(sprintf('contains(%s, %s)', $attrib, XPathExpr::xpathLiteral($value))); } else @@ -112,7 +112,7 @@ public function toXpath() protected function xpathAttrib() { - # FIXME: if attrib is *? + // FIXME: if attrib is *? if ($this->namespace == '*') { return '@'.$this->attrib; diff --git a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php index 4ce5ab23748ad..099a1d9acc021 100644 --- a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php +++ b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php @@ -65,7 +65,7 @@ public function toXpath() protected function _xpath_descendant($xpath, $sub) { - # when sub is a descendant in any way of xpath + // when sub is a descendant in any way of xpath $xpath->join('/descendant::', $sub->toXpath()); return $xpath; @@ -73,7 +73,7 @@ protected function _xpath_descendant($xpath, $sub) protected function _xpath_child($xpath, $sub) { - # when sub is an immediate child of xpath + // when sub is an immediate child of xpath $xpath->join('/', $sub->toXpath()); return $xpath; @@ -81,7 +81,7 @@ protected function _xpath_child($xpath, $sub) protected function _xpath_direct_adjacent($xpath, $sub) { - # when sub immediately follows xpath + // when sub immediately follows xpath $xpath->join('/following-sibling::', $sub->toXpath()); $xpath->addNameTest(); $xpath->addCondition('position() = 1'); @@ -91,7 +91,7 @@ protected function _xpath_direct_adjacent($xpath, $sub) protected function _xpath_indirect_adjacent($xpath, $sub) { - # when sub comes somewhere after xpath as a sibling + // when sub comes somewhere after xpath as a sibling $xpath->join('/following-sibling::', $sub->toXpath()); return $xpath; diff --git a/src/Symfony/Components/CssSelector/Node/ElementNode.php b/src/Symfony/Components/CssSelector/Node/ElementNode.php index e45a0ec7d76b1..aa5986ef2246f 100644 --- a/src/Symfony/Components/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Components/CssSelector/Node/ElementNode.php @@ -59,7 +59,7 @@ public function toXpath() } else { - # FIXME: Should we lowercase here? + // FIXME: Should we lowercase here? $el = sprintf('%s:%s', $this->namespace, $this->element); } diff --git a/src/Symfony/Components/CssSelector/Node/FunctionNode.php b/src/Symfony/Components/CssSelector/Node/FunctionNode.php index e7dd9956056e3..6908c61d1a19f 100644 --- a/src/Symfony/Components/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Components/CssSelector/Node/FunctionNode.php @@ -67,7 +67,7 @@ protected function _xpath_nth_child($xpath, $expr, $last = false, $addNameTest = list($a, $b) = $this->parseSeries($expr); if (!$a && !$b && !$last) { - # a=0 means nothing is returned... + // a=0 means nothing is returned... $xpath->addCondition('false() and position() = 0'); return $xpath; @@ -92,7 +92,7 @@ protected function _xpath_nth_child($xpath, $expr, $last = false, $addNameTest = if ($last) { - # FIXME: I'm not sure if this is right + // FIXME: I'm not sure if this is right $a = -$a; $b = -$b; } @@ -131,13 +131,13 @@ protected function _xpath_nth_child($xpath, $expr, $last = false, $addNameTest = } return $xpath; - # FIXME: handle an+b, odd, even - # an+b means every-a, plus b, e.g., 2n+1 means odd - # 0n+b means b - # n+0 means a=1, i.e., all elements - # an means every a elements, i.e., 2n means even - # -n means -1n - # -1n+6 means elements 6 and previous + /* FIXME: handle an+b, odd, even + an+b means every-a, plus b, e.g., 2n+1 means odd + 0n+b means b + n+0 means a=1, i.e., all elements + an means every a elements, i.e., 2n means even + -n means -1n + -1n+6 means elements 6 and previous */ } protected function _xpath_nth_last_child($xpath, $expr) @@ -162,23 +162,23 @@ protected function _xpath_nth_last_of_type($xpath, $expr) protected function _xpath_contains($xpath, $expr) { - # text content, minus tags, must contain expr + // text content, minus tags, must contain expr if ($expr instanceof ElementNode) { $expr = $expr->formatElement(); } $xpath->addCondition(sprintf('contains(css:lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr)))); - # FIXME: Currently case insensitive matching doesn't seem to be happening + // FIXME: Currently case insensitive matching doesn't seem to be happening return $xpath; } protected function _xpath_not($xpath, $expr) { - # everything for which not expr applies + // everything for which not expr applies $expr = $expr->toXpath(); $cond = $expr->getCondition(); - # FIXME: should I do something about element_path? + // FIXME: should I do something about element_path? $xpath->addCondition(sprintf('not(%s)', $cond)); return $xpath; @@ -194,13 +194,13 @@ protected function parseSeries($s) if (!$s || $s == '*') { - # Happens when there's nothing, which the CSS parser thinks of as * + // Happens when there's nothing, which the CSS parser thinks of as * return array(0, 0); } if (is_string($s)) { - # Happens when you just get a number + // Happens when you just get a number return array(0, $s); } @@ -219,7 +219,7 @@ protected function parseSeries($s) if (false === strpos($s, 'n')) { - # Just a b + // Just a b return array(0, intval((string) $s)); } diff --git a/src/Symfony/Components/CssSelector/Node/PseudoNode.php b/src/Symfony/Components/CssSelector/Node/PseudoNode.php index 01b0842be97e2..8723d373485fa 100644 --- a/src/Symfony/Components/CssSelector/Node/PseudoNode.php +++ b/src/Symfony/Components/CssSelector/Node/PseudoNode.php @@ -72,7 +72,7 @@ public function toXpath() protected function xpath_checked($xpath) { - # FIXME: is this really all the elements? + // FIXME: is this really all the elements? $xpath->addCondition("(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')"); return $xpath; @@ -80,7 +80,7 @@ protected function xpath_checked($xpath) protected function xpath_root($xpath) { - # if this element is the root element + // if this element is the root element throw new SyntaxError(); } diff --git a/src/Symfony/Components/CssSelector/Parser.php b/src/Symfony/Components/CssSelector/Parser.php index 62d37016e731f..f355da85e6402 100644 --- a/src/Symfony/Components/CssSelector/Parser.php +++ b/src/Symfony/Components/CssSelector/Parser.php @@ -123,7 +123,7 @@ protected function parseSelector($stream) } elseif (in_array($peek, array('+', '>', '~'))) { - # A combinator + // A combinator $combinator = (string) $stream->next(); } else @@ -184,8 +184,8 @@ protected function parseSimpleSelector($stream) { if ($has_hash) { - # You can't have two hashes - # (FIXME: is there some more general rule I'm missing?) + /* You can't have two hashes + (FIXME: is there some more general rule I'm missing?) */ // @codeCoverageIgnoreStart break; // @codeCoverageIgnoreEnd @@ -238,7 +238,7 @@ protected function parseSimpleSelector($stream) } else { - # FIXME: parseSimpleSelector, or selector, or...? + // FIXME: parseSimpleSelector, or selector, or...? $selector = $this->parseSimpleSelector($stream); } $next = $stream->next(); @@ -265,7 +265,7 @@ protected function parseSimpleSelector($stream) break; } - # FIXME: not sure what "negation" is + // FIXME: not sure what "negation" is } return $result; diff --git a/src/Symfony/Components/CssSelector/Tokenizer.php b/src/Symfony/Components/CssSelector/Tokenizer.php index 7e0838975833a..5f657b6cc6274 100644 --- a/src/Symfony/Components/CssSelector/Tokenizer.php +++ b/src/Symfony/Components/CssSelector/Tokenizer.php @@ -90,7 +90,7 @@ public function tokenize($s) if ($c === '"' || $c === "'") { - # Quoted string + // Quoted string $old_pos = $pos; list($sym, $pos) = $this->tokenizeEscapedString($s, $pos); @@ -125,7 +125,7 @@ protected function tokenizeEscapedString($s, $pos) $result = substr($s, $start, $next - $start); if ('\\' === $result[strlen($result) - 1]) { - # next quote character is escaped + // next quote character is escaped $pos = $next + 1; $continue; } @@ -164,7 +164,7 @@ protected function tokenizeSymbol($s, $pos) if (!preg_match('#[^\w\-]#', $s, $match, PREG_OFFSET_CAPTURE, $pos)) { - # Goes to end of s + // Goes to end of s return array(substr($s, $start), strlen($s)); } diff --git a/src/Symfony/Components/CssSelector/XPathExpr.php b/src/Symfony/Components/CssSelector/XPathExpr.php index b8ba679db49d6..a8baedee22fcb 100644 --- a/src/Symfony/Components/CssSelector/XPathExpr.php +++ b/src/Symfony/Components/CssSelector/XPathExpr.php @@ -99,7 +99,7 @@ public function addNameTest() { if ($this->element == '*') { - # We weren't doing a test anyway + // We weren't doing a test anyway return; } @@ -132,8 +132,8 @@ public function join($combiner, $other) $prefix .= $combiner; $path = $other->prefix.$other->path; - # We don't need a star prefix if we are joining to this other - # prefix; so we'll get rid of it + /* We don't need a star prefix if we are joining to this other + prefix; so we'll get rid of it */ if ($other->starPrefix && $path == '*/') { $path = ''; @@ -148,7 +148,7 @@ static public function xpathLiteral($s) { if ($s instanceof Node\ElementNode) { - # This is probably a symbol that looks like an expression... + // This is probably a symbol that looks like an expression... $s = $s->formatElement(); } else From 06b772832b178d42949fabdb6466bc0cf95ec719 Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Sat, 3 Apr 2010 07:54:42 +0800 Subject: [PATCH 41/54] [CssSelector] fixed coding standards: removed useless else statements --- .../Components/CssSelector/Node/AttribNode.php | 12 ++++-------- .../Components/CssSelector/Node/ElementNode.php | 6 ++---- .../Components/CssSelector/Node/FunctionNode.php | 6 ++++-- src/Symfony/Components/CssSelector/Parser.php | 6 ++---- .../Components/CssSelector/TokenStream.php | 16 +++++++--------- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/Symfony/Components/CssSelector/Node/AttribNode.php b/src/Symfony/Components/CssSelector/Node/AttribNode.php index ca698ea8f41e5..74a2862b5ddd5 100644 --- a/src/Symfony/Components/CssSelector/Node/AttribNode.php +++ b/src/Symfony/Components/CssSelector/Node/AttribNode.php @@ -117,10 +117,8 @@ protected function xpathAttrib() { return '@'.$this->attrib; } - else - { - return sprintf('@%s:%s', $this->namespace, $this->attrib); - } + + return sprintf('@%s:%s', $this->namespace, $this->attrib); } protected function formatAttrib() @@ -129,9 +127,7 @@ protected function formatAttrib() { return $this->attrib; } - else - { - return sprintf('%s|%s', $this->namespace, $this->attrib); - } + + return sprintf('%s|%s', $this->namespace, $this->attrib); } } diff --git a/src/Symfony/Components/CssSelector/Node/ElementNode.php b/src/Symfony/Components/CssSelector/Node/ElementNode.php index aa5986ef2246f..9425de55a1450 100644 --- a/src/Symfony/Components/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Components/CssSelector/Node/ElementNode.php @@ -45,10 +45,8 @@ public function formatElement() { return $this->element; } - else - { - return sprintf('%s|%s', $this->namespace, $this->element); - } + + return sprintf('%s|%s', $this->namespace, $this->element); } public function toXpath() diff --git a/src/Symfony/Components/CssSelector/Node/FunctionNode.php b/src/Symfony/Components/CssSelector/Node/FunctionNode.php index 6908c61d1a19f..c7c18ae92647c 100644 --- a/src/Symfony/Components/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Components/CssSelector/Node/FunctionNode.php @@ -208,11 +208,13 @@ protected function parseSeries($s) { return array(2, 1); } - elseif ($s == 'even') + + if ($s == 'even') { return array(2, 0); } - elseif ($s == 'n') + + if ($s == 'n') { return array(1, 0); } diff --git a/src/Symfony/Components/CssSelector/Parser.php b/src/Symfony/Components/CssSelector/Parser.php index f355da85e6402..5f00e7f7141bd 100644 --- a/src/Symfony/Components/CssSelector/Parser.php +++ b/src/Symfony/Components/CssSelector/Parser.php @@ -104,10 +104,8 @@ protected function parseSelectorGroup($stream) { return $result[0]; } - else - { - return new Node\OrNode($result); - } + + return new Node\OrNode($result); } protected function parseSelector($stream) diff --git a/src/Symfony/Components/CssSelector/TokenStream.php b/src/Symfony/Components/CssSelector/TokenStream.php index 6c3c0cc1c54db..e1774dd96e88a 100644 --- a/src/Symfony/Components/CssSelector/TokenStream.php +++ b/src/Symfony/Components/CssSelector/TokenStream.php @@ -52,18 +52,16 @@ public function next() return $this->peeked; } - else + + if (!count($this->tokens)) { - if (!count($this->tokens)) - { - return null; - } + return null; + } - $next = array_shift($this->tokens); - $this->used[] = $next; + $next = array_shift($this->tokens); + $this->used[] = $next; - return $next; - } + return $next; } public function peek() From a26dfd644b56709b9583964a1ddd452992bd7ffd Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Sat, 3 Apr 2010 08:24:05 +0800 Subject: [PATCH 42/54] [RequestHandler] fixed coding standards: the use of function is_null() is forbidden --- src/Symfony/Components/RequestHandler/Response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Components/RequestHandler/Response.php b/src/Symfony/Components/RequestHandler/Response.php index d373b91316573..89437d78b57de 100644 --- a/src/Symfony/Components/RequestHandler/Response.php +++ b/src/Symfony/Components/RequestHandler/Response.php @@ -147,7 +147,7 @@ public function getProtocolVersion() */ public function setCookie($name, $value, $expire = null, $path = '/', $domain = '', $secure = false, $httpOnly = false) { - if (!is_null($expire)) + if (null !== $expire) { if (is_numeric($expire)) { @@ -228,7 +228,7 @@ public function setHeader($name, $value, $replace = true) { $name = $this->normalizeHeaderName($name); - if (is_null($value)) + if (null === $value) { unset($this->headers[$name]); From bfc03c06cdb1f680946e4830c5a96eba962f57d3 Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Sun, 4 Apr 2010 07:19:07 +0800 Subject: [PATCH 43/54] [RequestHandler] fixed assertion in getFormat when format is associated with only one mime-type + phpunit tests --- src/Symfony/Components/RequestHandler/Request.php | 2 +- .../Components/RequestHandler/RequestTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index e2307c4a30431..87c4e50fb5b38 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -353,7 +353,7 @@ public function getFormat($mimeType) foreach (static::$formats as $format => $mimeTypes) { - if (in_array($mimeType, $mimeTypes)) + if (in_array($mimeType, (array) $mimeTypes)) { return $format; } diff --git a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php index a2f1e4dc4cc52..740bbec5ef32c 100644 --- a/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php +++ b/tests/Symfony/Tests/Components/RequestHandler/RequestTest.php @@ -63,4 +63,19 @@ public function testDuplicate() $this->assertEquals(array('foo' => 'foobar'), $dup->getPathParameters(), '->duplicate() overrides the path parameters if provided'); $this->assertEquals('foobar', $dup->getHttpHeader('foo'), '->duplicate() overrides the HTTP header if provided'); } + + /** + * @covers Symfony\Components\RequestHandler\Request::getFormat + */ + public function testGetFormat() + { + $request = new Request(); + + $this->assertEquals(null, $request->getFormat(null), '->getFormat() returns null when mime-type is null'); + $this->assertEquals(null, $request->getFormat('unexistant-mime-type'), '->getFormat() returns null when mime-type is unknown'); + $this->assertEquals('txt', $request->getFormat('text/plain'), '->getFormat() returns correct format when mime-type have one format only'); + $this->assertEquals('js', $request->getFormat('application/javascript'), '->getFormat() returns correct format when format have multiple mime-type (first)'); + $this->assertEquals('js', $request->getFormat('application/x-javascript'), '->getFormat() returns correct format when format have multiple mime-type'); + $this->assertEquals('js', $request->getFormat('text/javascript'), '->getFormat() returns correct format when format have multiple mime-type (last)'); + } } From 2e6692a4f1abc3a7554bfb466f26a7b341da7138 Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Mon, 5 Apr 2010 01:11:32 +0800 Subject: [PATCH 44/54] fixed @throws phpdoc tag --- src/Symfony/Components/Console/Application.php | 8 ++++++++ .../Components/Console/Command/Command.php | 6 ++++++ .../Components/Console/Helper/DialogHelper.php | 2 ++ .../Components/Console/Input/ArgvInput.php | 8 ++++++++ .../Components/Console/Input/ArrayInput.php | 6 ++++++ src/Symfony/Components/Console/Input/Input.php | 11 +++++++++++ .../Components/Console/Input/InputArgument.php | 4 ++++ .../Components/Console/Input/InputDefinition.php | 8 ++++++++ .../Components/Console/Input/InputOption.php | 2 ++ .../Components/Console/Input/StringInput.php | 3 +++ src/Symfony/Components/Console/Output/Output.php | 5 +++++ .../Components/Console/Output/StreamOutput.php | 4 ++++ src/Symfony/Components/Console/Shell.php | 2 ++ .../Components/CssSelector/Node/AttribNode.php | 3 +++ .../CssSelector/Node/CombinedSelectorNode.php | 3 +++ .../Components/CssSelector/Node/FunctionNode.php | 3 +++ .../Components/CssSelector/Node/PseudoNode.php | 15 +++++++++++++++ src/Symfony/Components/CssSelector/Parser.php | 15 +++++++++++++++ src/Symfony/Components/CssSelector/Tokenizer.php | 9 +++++++++ .../Components/DependencyInjection/Builder.php | 2 ++ .../Components/DependencyInjection/Container.php | 4 ++++ .../DependencyInjection/Dumper/Dumper.php | 2 ++ .../DependencyInjection/Dumper/XmlDumper.php | 3 +++ .../DependencyInjection/Dumper/YamlDumper.php | 3 +++ .../DependencyInjection/Loader/FileLoader.php | 3 +++ .../DependencyInjection/Loader/IniFileLoader.php | 2 ++ .../Loader/LoaderExtension.php | 2 ++ .../DependencyInjection/Loader/XmlFileLoader.php | 10 ++++++++++ .../DependencyInjection/Loader/YamlFileLoader.php | 3 +++ src/Symfony/Components/EventDispatcher/Event.php | 2 ++ .../Components/OutputEscaper/ArrayDecorator.php | 4 ++-- .../OutputEscaper/IteratorDecorator.php | 4 ++-- .../Components/RequestHandler/RequestHandler.php | 5 ++++- .../Components/RequestHandler/Response.php | 3 +++ .../Routing/Generator/Dumper/GeneratorDumper.php | 2 ++ .../Components/Routing/Generator/UrlGenerator.php | 5 +++++ .../Components/Routing/Loader/FileLoader.php | 3 +++ .../Components/Routing/Loader/XmlFileLoader.php | 8 ++++++++ .../Components/Routing/Loader/YamlFileLoader.php | 8 ++++++++ .../Matcher/Dumper/ApacheMatcherDumper.php | 2 ++ .../Routing/Matcher/Dumper/MatcherDumper.php | 2 ++ .../Components/Routing/RouteCollection.php | 2 ++ src/Symfony/Components/Routing/RouteCompiler.php | 2 ++ src/Symfony/Components/Routing/Router.php | 5 +++++ src/Symfony/Components/Yaml/Inline.php | 10 ++++++++++ src/Symfony/Components/Yaml/Parser.php | 6 +++++- src/Symfony/Components/Yaml/Yaml.php | 2 ++ src/Symfony/Foundation/ClassCollectionLoader.php | 3 +++ src/Symfony/Foundation/Debug/ErrorHandler.php | 3 +++ src/Symfony/Foundation/Kernel.php | 2 ++ .../Command/BuildDoctrineCommand.php | 2 ++ .../Command/DatabaseToolDoctrineCommand.php | 2 ++ .../Command/ImportMappingDoctrineCommand.php | 2 ++ .../Command/InitEntityDoctrineCommand.php | 2 ++ .../Framework/ProfilerBundle/ProfilerStorage.php | 3 +++ .../WebBundle/Command/AssetsInstallCommand.php | 2 ++ .../WebBundle/Command/InitBundleCommand.php | 3 +++ .../WebBundle/Command/RouterDebugCommand.php | 3 +++ .../WebBundle/Controller/ExceptionController.php | 3 +++ .../WebBundle/Listener/ControllerLoader.php | 6 ++++++ .../Framework/WebBundle/Session/PdoSession.php | 15 ++++++++------- .../WebBundle/Session/SessionInterface.php | 8 ++++---- .../Framework/WebBundle/Templating/Engine.php | 3 +++ .../Framework/WebBundle/Util/Filesystem.php | 4 ++++ src/Symfony/Framework/WebBundle/Util/Finder.php | 2 ++ .../Framework/WebBundle/Util/NumberCompare.php | 4 +++- 66 files changed, 280 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Components/Console/Application.php b/src/Symfony/Components/Console/Application.php index e26319be75aec..e9e4a469ea50a 100644 --- a/src/Symfony/Components/Console/Application.php +++ b/src/Symfony/Components/Console/Application.php @@ -99,6 +99,8 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') * @param OutputInterface $output An Output instance * * @return integer 0 if everything went fine, or an error code + * + * @throws \Exception When doRun returns Exception */ public function run(InputInterface $input = null, OutputInterface $output = null) { @@ -396,6 +398,8 @@ public function addCommand(Command $command) * @param string $name The command name or alias * * @return Command A Command object + * + * @throws \InvalidArgumentException When command name given does not exist */ public function getCommand($name) { @@ -456,6 +460,8 @@ public function getNamespaces() * Finds a registered namespace by a name or an abbreviation. * * @return string A registered namespace + * + * @throws \InvalidArgumentException When namespace is incorrect or ambiguous */ public function findNamespace($namespace) { @@ -483,6 +489,8 @@ public function findNamespace($namespace) * @param string $name A command name or a command alias * * @return Command A Command instance + * + * @throws \InvalidArgumentException When command name is incorrect or ambiguous */ public function findCommand($name) { diff --git a/src/Symfony/Components/Console/Command/Command.php b/src/Symfony/Components/Console/Command/Command.php index bbde5f94e0831..6813f31791149 100644 --- a/src/Symfony/Components/Console/Command/Command.php +++ b/src/Symfony/Components/Console/Command/Command.php @@ -43,6 +43,8 @@ class Command * Constructor. * * @param string $name The name of the command + * + * @throws \LogicException When the command name is empty */ public function __construct($name = null) { @@ -88,6 +90,8 @@ protected function configure() * @param OutputInterface $output An OutputInterface instance * * @return integer 0 if everything went fine, or an error code + * + * @throws \LogicException When this abstrass class is not implemented */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -273,6 +277,8 @@ public function addOption($name, $shortcut = null, $mode = null, $description = * @param string $name The command name * * @return Command The current instance + * + * @throws \InvalidArgumentException When command name given is empty */ public function setName($name) { diff --git a/src/Symfony/Components/Console/Helper/DialogHelper.php b/src/Symfony/Components/Console/Helper/DialogHelper.php index a19c3d949a5e0..154143a1a6c74 100644 --- a/src/Symfony/Components/Console/Helper/DialogHelper.php +++ b/src/Symfony/Components/Console/Helper/DialogHelper.php @@ -82,6 +82,8 @@ public function askConfirmation(OutputInterface $output, $question, $default = t * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite) * * @return mixed + * + * @throws \Exception When any of the validator returns an error */ public function askAndValidate(OutputInterface $output, $question, \Closure $validator, $attempts = false) { diff --git a/src/Symfony/Components/Console/Input/ArgvInput.php b/src/Symfony/Components/Console/Input/ArgvInput.php index a140219bfdebf..ec3820c387cb9 100644 --- a/src/Symfony/Components/Console/Input/ArgvInput.php +++ b/src/Symfony/Components/Console/Input/ArgvInput.php @@ -118,6 +118,8 @@ protected function parseShortOption($token) * Parses a short option set. * * @param string $token The current token + * + * @throws \RuntimeException When option given doesn't exist */ protected function parseShortOptionSet($name) { @@ -166,6 +168,8 @@ protected function parseLongOption($token) * Parses an argument. * * @param string $token The current token + * + * @throws \RuntimeException When too many arguments are given */ protected function parseArgument($token) { @@ -182,6 +186,8 @@ protected function parseArgument($token) * * @param string $shortcut The short option key * @param mixed $value The value for the option + * + * @throws \RuntimeException When option given doesn't exist */ protected function addShortOption($shortcut, $value) { @@ -198,6 +204,8 @@ protected function addShortOption($shortcut, $value) * * @param string $name The long option key * @param mixed $value The value for the option + * + * @throws \RuntimeException When option given doesn't exist */ protected function addLongOption($name, $value) { diff --git a/src/Symfony/Components/Console/Input/ArrayInput.php b/src/Symfony/Components/Console/Input/ArrayInput.php index 3ae6154d30900..4f4e624b10bfc 100644 --- a/src/Symfony/Components/Console/Input/ArrayInput.php +++ b/src/Symfony/Components/Console/Input/ArrayInput.php @@ -117,6 +117,8 @@ protected function parse() * * @param string $shortcut The short option key * @param mixed $value The value for the option + * + * @throws \RuntimeException When option given doesn't exist */ protected function addShortOption($shortcut, $value) { @@ -133,6 +135,8 @@ protected function addShortOption($shortcut, $value) * * @param string $name The long option key * @param mixed $value The value for the option + * + * @throws \RuntimeException When option given doesn't exist */ protected function addLongOption($name, $value) { @@ -161,6 +165,8 @@ protected function addLongOption($name, $value) * * @param string $name The argument name * @param mixed $value The value for the argument + * + * @throws \RuntimeException When option given doesn't exist */ protected function addArgument($name, $value) { diff --git a/src/Symfony/Components/Console/Input/Input.php b/src/Symfony/Components/Console/Input/Input.php index 9e9e5f48263cd..9b5423bc705c3 100644 --- a/src/Symfony/Components/Console/Input/Input.php +++ b/src/Symfony/Components/Console/Input/Input.php @@ -68,6 +68,9 @@ public function bind(InputDefinition $definition) */ abstract protected function parse(); + /** + * @throws \RuntimeException When not enough arguments are given + */ public function validate() { if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) @@ -102,6 +105,8 @@ public function getArguments() * @param string $name The argument name * * @return mixed The argument value + * + * @throws \InvalidArgumentException When argument given doesn't exist */ public function getArgument($name) { @@ -118,6 +123,8 @@ public function getArgument($name) * * @param string $name The argument name * @param string $value The argument value + * + * @throws \InvalidArgumentException When argument given doesn't exist */ public function setArgument($name, $value) { @@ -157,6 +164,8 @@ public function getOptions() * @param string $name The option name * * @return mixed The option value + * + * @throws \InvalidArgumentException When option given doesn't exist */ public function getOption($name) { @@ -173,6 +182,8 @@ public function getOption($name) * * @param string $name The option name * @param string $value The option value + * + * @throws \InvalidArgumentException When option given doesn't exist */ public function setOption($name, $value) { diff --git a/src/Symfony/Components/Console/Input/InputArgument.php b/src/Symfony/Components/Console/Input/InputArgument.php index 9b5925b4bfaf8..43bbacf9cd7d9 100644 --- a/src/Symfony/Components/Console/Input/InputArgument.php +++ b/src/Symfony/Components/Console/Input/InputArgument.php @@ -36,6 +36,8 @@ class InputArgument * @param integer $mode The argument mode: self::REQUIRED or self::OPTIONAL * @param string $description A description text * @param mixed $default The default value (for self::OPTIONAL mode only) + * + * @throws \InvalidArgumentException When argument mode is not valid */ public function __construct($name, $mode = null, $description = '', $default = null) { @@ -89,6 +91,8 @@ public function isArray() * Sets the default value. * * @param mixed $default The default value + * + * @throws \LogicException When incorrect default value is given */ public function setDefault($default = null) { diff --git a/src/Symfony/Components/Console/Input/InputDefinition.php b/src/Symfony/Components/Console/Input/InputDefinition.php index 2977e7fd6d427..1903d04fed090 100644 --- a/src/Symfony/Components/Console/Input/InputDefinition.php +++ b/src/Symfony/Components/Console/Input/InputDefinition.php @@ -97,6 +97,8 @@ public function addArguments($arguments = array()) * Add an InputArgument object. * * @param InputArgument $argument An InputArgument object + * + * @throws \LogicException When incorrect argument is given */ public function addArgument(InputArgument $argument) { @@ -138,6 +140,8 @@ public function addArgument(InputArgument $argument) * @param string|integer $name The InputArgument name or position * * @return InputArgument An InputArgument object + * + * @throws \InvalidArgumentException When argument given doesn't exist */ public function getArgument($name) { @@ -240,6 +244,8 @@ public function addOptions($options = array()) * Add an InputOption object. * * @param InputOption $option An InputOption object + * + * @throws \LogicException When option given already exist */ public function addOption(InputOption $option) { @@ -342,6 +348,8 @@ public function getOptionDefaults() * @param string $shortcut The shortcut * * @return string The InputOption name + * + * @throws \InvalidArgumentException When option given does not exist */ protected function shortcutToName($shortcut) { diff --git a/src/Symfony/Components/Console/Input/InputOption.php b/src/Symfony/Components/Console/Input/InputOption.php index 46a47d0d5720e..2937c5810af95 100644 --- a/src/Symfony/Components/Console/Input/InputOption.php +++ b/src/Symfony/Components/Console/Input/InputOption.php @@ -39,6 +39,8 @@ class InputOption * @param integer $mode The option mode: self::PARAMETER_REQUIRED, self::PARAMETER_NONE or self::PARAMETER_OPTIONAL * @param string $description A description text * @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE) + * + * @throws \InvalidArgumentException If option mode is invalid or incompatible */ public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) { diff --git a/src/Symfony/Components/Console/Input/StringInput.php b/src/Symfony/Components/Console/Input/StringInput.php index c66f7b9dc4b39..c250c687a9345 100644 --- a/src/Symfony/Components/Console/Input/StringInput.php +++ b/src/Symfony/Components/Console/Input/StringInput.php @@ -40,6 +40,9 @@ public function __construct($input, InputDefinition $definition = null) $this->tokens = $this->tokenize($input); } + /** + * @throws \InvalidArgumentException When unable to parse input (should never happen) + */ protected function tokenize($input) { $input = preg_replace('/(\r\n|\r|\n|\t)/', ' ', $input); diff --git a/src/Symfony/Components/Console/Output/Output.php b/src/Symfony/Components/Console/Output/Output.php index 7bfa8bf012290..ef251393bb871 100644 --- a/src/Symfony/Components/Console/Output/Output.php +++ b/src/Symfony/Components/Console/Output/Output.php @@ -127,6 +127,8 @@ public function writeln($messages, $type = 0) * @param string|array $messages The message as an array of lines of a single string * @param Boolean $newline Whether to add a newline or not * @param integer $type The type of output + * + * @throws \InvalidArgumentException When unknown output type is given */ public function write($messages, $newline = false, $type = 0) { @@ -182,6 +184,9 @@ protected function format($message) return preg_replace_callback('##i', array($this, 'replaceEndStyle'), $message); } + /** + * @throws \InvalidArgumentException When style is unknown + */ protected function replaceStartStyle($match) { if (!$this->decorated) diff --git a/src/Symfony/Components/Console/Output/StreamOutput.php b/src/Symfony/Components/Console/Output/StreamOutput.php index fdb74debedff6..3023012d7a208 100644 --- a/src/Symfony/Components/Console/Output/StreamOutput.php +++ b/src/Symfony/Components/Console/Output/StreamOutput.php @@ -36,6 +36,8 @@ class StreamOutput extends Output * @param mixed $stream A stream resource * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE) * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) + * + * @throws \InvalidArgumentException When first argument is not a real stream */ public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null) { @@ -69,6 +71,8 @@ public function getStream() * * @param string $message A message to write to the output * @param Boolean $newline Whether to add a newline or not + * + * @throws \RuntimeException When unable to write output (should never happen) */ public function doWrite($message, $newline) { diff --git a/src/Symfony/Components/Console/Shell.php b/src/Symfony/Components/Console/Shell.php index f91965c0bd402..6e4a08ac88416 100644 --- a/src/Symfony/Components/Console/Shell.php +++ b/src/Symfony/Components/Console/Shell.php @@ -38,6 +38,8 @@ class Shell * a \RuntimeException exception is thrown. * * @param Application $application An application instance + * + * @throws \RuntimeException When Readline extension is not enabled */ public function __construct(Application $application) { diff --git a/src/Symfony/Components/CssSelector/Node/AttribNode.php b/src/Symfony/Components/CssSelector/Node/AttribNode.php index 74a2862b5ddd5..fe7300045c276 100644 --- a/src/Symfony/Components/CssSelector/Node/AttribNode.php +++ b/src/Symfony/Components/CssSelector/Node/AttribNode.php @@ -53,6 +53,9 @@ public function __toString() } } + /** + * @throws SyntaxError When unknown operator is found + */ public function toXpath() { $path = $this->selector->toXpath(); diff --git a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php index 099a1d9acc021..eec316e36625b 100644 --- a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php +++ b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php @@ -50,6 +50,9 @@ public function __toString() return sprintf('%s[%s %s %s]', __CLASS__, $this->selector, $comb, $this->subselector); } + /** + * @throws SyntaxError When unknown combinator is found + */ public function toXpath() { if (!isset(self::$_method_mapping[$this->combinator])) diff --git a/src/Symfony/Components/CssSelector/Node/FunctionNode.php b/src/Symfony/Components/CssSelector/Node/FunctionNode.php index c7c18ae92647c..a18b4872de401 100644 --- a/src/Symfony/Components/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Components/CssSelector/Node/FunctionNode.php @@ -46,6 +46,9 @@ public function __toString() return sprintf('%s[%s%s%s(%s)]', __CLASS__, $this->selector, $this->type, $this->name, $this->expr); } + /** + * @throws SyntaxError When unsupported or unknown pseudo-class is found + */ public function toXpath() { $sel_path = $this->selector->toXpath(); diff --git a/src/Symfony/Components/CssSelector/Node/PseudoNode.php b/src/Symfony/Components/CssSelector/Node/PseudoNode.php index 8723d373485fa..99867657b334c 100644 --- a/src/Symfony/Components/CssSelector/Node/PseudoNode.php +++ b/src/Symfony/Components/CssSelector/Node/PseudoNode.php @@ -35,6 +35,9 @@ class PseudoNode implements NodeInterface protected $type; protected $ident; + /** + * @throws SyntaxError When incorrect PseudoNode type is given + */ public function __construct($element, $type, $ident) { $this->element = $element; @@ -53,6 +56,9 @@ public function __toString() return sprintf('%s[%s%s%s]', __CLASS__, $this->element, $this->type, $this->ident); } + /** + * @throws SyntaxError When unsupported or unknown pseudo-class is found + */ public function toXpath() { $el_xpath = $this->element->toXpath(); @@ -78,6 +84,9 @@ protected function xpath_checked($xpath) return $xpath; } + /** + * @throws SyntaxError If this element is the root element + */ protected function xpath_root($xpath) { // if this element is the root element @@ -114,6 +123,9 @@ protected function xpath_first_of_type($xpath) return $xpath; } + /** + * @throws SyntaxError Because *:last-of-type is not implemented + */ protected function xpath_last_of_type($xpath) { if ($xpath->getElement() == '*') @@ -135,6 +147,9 @@ protected function xpath_only_child($xpath) return $xpath; } + /** + * @throws SyntaxError Because *:only-of-type is not implemented + */ protected function xpath_only_of_type($xpath) { if ($xpath->getElement() == '*') diff --git a/src/Symfony/Components/CssSelector/Parser.php b/src/Symfony/Components/CssSelector/Parser.php index 5f00e7f7141bd..6812005c5f444 100644 --- a/src/Symfony/Components/CssSelector/Parser.php +++ b/src/Symfony/Components/CssSelector/Parser.php @@ -26,6 +26,9 @@ */ class Parser { + /** + * @throws SyntaxError When got None for xpath expression + */ static public function cssToXpath($cssExpr, $prefix = 'descendant-or-self::') { if (is_string($cssExpr)) @@ -66,6 +69,9 @@ static public function cssToXpath($cssExpr, $prefix = 'descendant-or-self::') return (string) $expr; } + /** + * @throws \Exception When tokenizer throws it while parsing + */ public function parse($string) { $tokenizer = new Tokenizer(); @@ -108,6 +114,9 @@ protected function parseSelectorGroup($stream) return new Node\OrNode($result); } + /** + * @throws SyntaxError When expected selector but got something else + */ protected function parseSelector($stream) { $result = $this->parseSimpleSelector($stream); @@ -141,6 +150,9 @@ protected function parseSelector($stream) return $result; } + /** + * @throws SyntaxError When expected symbol but got something else + */ protected function parseSimpleSelector($stream) { $peek = $stream->peek(); @@ -269,6 +281,9 @@ protected function parseSimpleSelector($stream) return $result; } + /** + * @throws SyntaxError When encountered unexpected selector + */ protected function parseAttrib($selector, $stream) { $attrib = $stream->next(); diff --git a/src/Symfony/Components/CssSelector/Tokenizer.php b/src/Symfony/Components/CssSelector/Tokenizer.php index 5f657b6cc6274..c83b41cfbd241 100644 --- a/src/Symfony/Components/CssSelector/Tokenizer.php +++ b/src/Symfony/Components/CssSelector/Tokenizer.php @@ -108,6 +108,9 @@ public function tokenize($s) } } + /** + * @throws SyntaxError When expected closing is not found + */ protected function tokenizeEscapedString($s, $pos) { $quote = $s[$pos]; @@ -139,6 +142,9 @@ protected function tokenizeEscapedString($s, $pos) } } + /** + * @throws SyntaxError When invalid escape sequence is found + */ protected function unescapeStringLiteral($literal) { return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal) @@ -158,6 +164,9 @@ protected function unescapeStringLiteral($literal) }, $literal); } + /** + * @throws SyntaxError When Unexpected symbol is found + */ protected function tokenizeSymbol($s, $pos) { $start = $pos; diff --git a/src/Symfony/Components/DependencyInjection/Builder.php b/src/Symfony/Components/DependencyInjection/Builder.php index 65ee52894f000..5eddaeea0ebe2 100644 --- a/src/Symfony/Components/DependencyInjection/Builder.php +++ b/src/Symfony/Components/DependencyInjection/Builder.php @@ -335,6 +335,8 @@ public function getDefinition($id) * @param string $id The service identifier * * @return object The service described by the service definition + * + * @throws \InvalidArgumentException When configure callable is not callable */ protected function createService(Definition $definition, $id) { diff --git a/src/Symfony/Components/DependencyInjection/Container.php b/src/Symfony/Components/DependencyInjection/Container.php index c6a011a218607..d864f2d831ab5 100644 --- a/src/Symfony/Components/DependencyInjection/Container.php +++ b/src/Symfony/Components/DependencyInjection/Container.php @@ -317,6 +317,8 @@ public function __set($id, $service) * Removes a service by identifier. * * @param string The service identifier + * + * @throws LogicException When trying to unset a service */ public function __unset($id) { @@ -330,6 +332,8 @@ public function __unset($id) * @param array $arguments The method arguments * * @return mixed + * + * @throws \RuntimeException When calling to an undefined method */ public function __call($method, $arguments) { diff --git a/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php b/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php index 4e75f00cf424e..d32af853979fb 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php @@ -40,6 +40,8 @@ public function __construct(Builder $container) * @param array $options An array of options * * @return string The representation of the service container + * + * @throws \LogicException When this abstrass class is not implemented */ public function dump(array $options = array()) { diff --git a/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php index a91e0b6908531..74db69c7c96d4 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php @@ -227,6 +227,9 @@ protected function escape($arguments) return $args; } + /** + * @throws \RuntimeException When trying to dump object or ressource + */ static public function phpToXml($value) { switch (true) diff --git a/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php index 78365864968bb..1a5a9191f6a0d 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php @@ -143,6 +143,9 @@ protected function addParameters() return Yaml::dump(array('parameters' => $this->prepareParameters($this->container->getParameters())), 2); } + /** + * @throws \RuntimeException When trying to dump object or ressource + */ protected function dumpValue($value) { if (is_array($value)) diff --git a/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php index bd65728b0a846..25e52f8e4488d 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php @@ -37,6 +37,9 @@ public function __construct($paths = array()) $this->paths = $paths; } + /** + * @throws \InvalidArgumentException When provided file does not exist + */ protected function findFile($file) { $path = $this->getAbsolutePath($file); diff --git a/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php index 6df27729fba73..35878fd0a4215 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php @@ -29,6 +29,8 @@ class IniFileLoader extends FileLoader * @param string $file An INI file path * * @return BuilderConfiguration A BuilderConfiguration instance + * + * @throws \InvalidArgumentException When ini file is not valid */ public function load($file) { diff --git a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php index 23f7e0298552e..2edc2c0994baa 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php +++ b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php @@ -40,6 +40,8 @@ public function setConfiguration($name, $resource) * @param array An array of configuration values * * @return BuilderConfiguration A BuilderConfiguration instance + * + * @throws \InvalidArgumentException When provided tag is not defined in this extension */ public function load($tag, array $config) { diff --git a/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php index 35b5d4a0432ab..5bb3feee9b69f 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php @@ -197,6 +197,9 @@ protected function parseDefinition(BuilderConfiguration $configuration, $id, $se $configuration->setDefinition($id, $definition); } + /** + * @throws \InvalidArgumentException When loading of XML file returns error + */ protected function parseFile($file) { $dom = new \DOMDocument(); @@ -249,6 +252,10 @@ protected function validate($dom, $file) $this->validateExtensions($dom, $file); } + /** + * @throws \RuntimeException When extension references a non-existent XSD file + * @throws \InvalidArgumentException When xml doesn't validate its xsd schema + */ protected function validateSchema($dom, $file) { $schemaLocations = array('http://www.symfony-project.org/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd')); @@ -299,6 +306,9 @@ protected function validateSchema($dom, $file) libxml_use_internal_errors(false); } + /** + * @throws \InvalidArgumentException When non valid tag are found or no extension are found + */ protected function validateExtensions($dom, $file) { foreach ($dom->documentElement->childNodes as $node) diff --git a/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php index 1926ce7e3d89a..c1d893850d0a2 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php @@ -196,6 +196,9 @@ protected function loadFile($file) return $this->validate(Yaml::load($file), $file); } + /** + * @throws \InvalidArgumentException When service file is not valid + */ protected function validate($content, $file) { if (null === $content) diff --git a/src/Symfony/Components/EventDispatcher/Event.php b/src/Symfony/Components/EventDispatcher/Event.php index 21c79d1fd5dee..f9d5070223f38 100644 --- a/src/Symfony/Components/EventDispatcher/Event.php +++ b/src/Symfony/Components/EventDispatcher/Event.php @@ -127,6 +127,8 @@ public function hasParameter($name) * @param string $name The parameter name * * @return mixed The parameter value + * + * @throws \InvalidArgumentException When parameter doesn't exists for this event */ public function getParameter($name) { diff --git a/src/Symfony/Components/OutputEscaper/ArrayDecorator.php b/src/Symfony/Components/OutputEscaper/ArrayDecorator.php index c0752f4ffd645..e024a6bd87b24 100644 --- a/src/Symfony/Components/OutputEscaper/ArrayDecorator.php +++ b/src/Symfony/Components/OutputEscaper/ArrayDecorator.php @@ -120,7 +120,7 @@ public function offsetGet($offset) * @param string $offset (ignored) * @param string $value (ignored) * - * @throws \LogicException + * @throws \LogicException When trying to set values */ public function offsetSet($offset, $value) { @@ -136,7 +136,7 @@ public function offsetSet($offset, $value) * * @param string $offset (ignored) * - * @throws LogicException + * @throws \LogicException When trying to unset values */ public function offsetUnset($offset) { diff --git a/src/Symfony/Components/OutputEscaper/IteratorDecorator.php b/src/Symfony/Components/OutputEscaper/IteratorDecorator.php index cd70dd8bbfda4..ee02214257134 100644 --- a/src/Symfony/Components/OutputEscaper/IteratorDecorator.php +++ b/src/Symfony/Components/OutputEscaper/IteratorDecorator.php @@ -131,7 +131,7 @@ public function offsetGet($offset) * @param string $offset (ignored) * @param string $value (ignored) * - * @throws \LogicException + * @throws \LogicException When trying to set values */ public function offsetSet($offset, $value) { @@ -147,7 +147,7 @@ public function offsetSet($offset, $value) * * @param string $offset (ignored) * - * @throws \LogicException + * @throws \LogicException When trying to unset values */ public function offsetUnset($offset) { diff --git a/src/Symfony/Components/RequestHandler/RequestHandler.php b/src/Symfony/Components/RequestHandler/RequestHandler.php index 1346c3a30d174..434af5bb24528 100644 --- a/src/Symfony/Components/RequestHandler/RequestHandler.php +++ b/src/Symfony/Components/RequestHandler/RequestHandler.php @@ -46,6 +46,8 @@ public function __construct(EventDispatcher $dispatcher) * @param Boolean $main Whether this is the main request or not * * @return ResponseInterface $response A Response instance + * + * @throws \Exception When Exception couldn't be catch by event processing */ public function handle(RequestInterface $request, $main = true) { @@ -78,7 +80,8 @@ public function handle(RequestInterface $request, $main = true) * * @return ResponseInterface $response A Response instance * - * @throws \LogicException if one of the listener does not behave as expected + * @throws \LogicException If one of the listener does not behave as expected + * @throws NotFoundHttpException When controller cannot be found */ public function handleRaw(RequestInterface $request, $main = true) { diff --git a/src/Symfony/Components/RequestHandler/Response.php b/src/Symfony/Components/RequestHandler/Response.php index 89437d78b57de..ff6b9ef594a36 100644 --- a/src/Symfony/Components/RequestHandler/Response.php +++ b/src/Symfony/Components/RequestHandler/Response.php @@ -144,6 +144,8 @@ public function getProtocolVersion() * @param string $domain Domain name * @param bool $secure If secure * @param bool $httpOnly If uses only HTTP + * + * @throws \InvalidArgumentException When cookie expire parameter is not valid */ public function setCookie($name, $value, $expire = null, $path = '/', $domain = '', $secure = false, $httpOnly = false) { @@ -192,6 +194,7 @@ public function getCookies() * @param string $code HTTP status code * @param string $text HTTP status text * + * @throws \InvalidArgumentException When the HTTP status code is not valid */ public function setStatusCode($code, $text = null) { diff --git a/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php b/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php index 89f263365c2b7..e6d5d65f795a9 100644 --- a/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php +++ b/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php @@ -41,6 +41,8 @@ public function __construct(RouteCollection $routes) * @param array $options An array of options * * @return string The representation of the routing + * + * @throws \LogicException When this abstrass class is not implemented */ public function dump(array $options = array()) { diff --git a/src/Symfony/Components/Routing/Generator/UrlGenerator.php b/src/Symfony/Components/Routing/Generator/UrlGenerator.php index aeb691b37f7c5..75e154d7269d5 100644 --- a/src/Symfony/Components/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Components/Routing/Generator/UrlGenerator.php @@ -51,6 +51,8 @@ public function __construct(RouteCollection $routes, array $context = array(), a * @param Boolean $absolute Whether to generate an absolute URL * * @return string The generated URL + * + * @throws \InvalidArgumentException When route doesn't exist */ public function generate($name, array $parameters, $absolute = false) { @@ -67,6 +69,9 @@ public function generate($name, array $parameters, $absolute = false) return $this->doGenerate($this->cache[$name]->getVariables(), $route->getDefaults(), $route->getRequirements(), $this->cache[$name]->getTokens(), $parameters, $name, $absolute); } + /** + * @throws \InvalidArgumentException When route has some missing mandatory parameters + */ protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute) { $defaults = array_merge($this->defaults, $defaults); diff --git a/src/Symfony/Components/Routing/Loader/FileLoader.php b/src/Symfony/Components/Routing/Loader/FileLoader.php index a8bda96e4f3cd..074754e3594a9 100644 --- a/src/Symfony/Components/Routing/Loader/FileLoader.php +++ b/src/Symfony/Components/Routing/Loader/FileLoader.php @@ -37,6 +37,9 @@ public function __construct($paths = array()) $this->paths = $paths; } + /** + * @throws \InvalidArgumentException When file is not found + */ protected function findFile($file) { $path = $this->getAbsolutePath($file); diff --git a/src/Symfony/Components/Routing/Loader/XmlFileLoader.php b/src/Symfony/Components/Routing/Loader/XmlFileLoader.php index dddba62632670..17247f7b078b6 100644 --- a/src/Symfony/Components/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Components/Routing/Loader/XmlFileLoader.php @@ -30,6 +30,8 @@ class XmlFileLoader extends FileLoader * @param string $file A XML file path * * @return RouteCollection A RouteCollection instance + * + * @throws \InvalidArgumentException When a tag can't be parsed */ public function load($file) { @@ -123,6 +125,9 @@ protected function parseImport(RouteCollection $collection, $node, $file) $collection->addCollection($loader->load($importedFile), (string) $node->getAttribute('prefix')); } + /** + * @throws \InvalidArgumentException When loading of XML file returns error + */ protected function loadFile($path) { $dom = new \DOMDocument(); @@ -139,6 +144,9 @@ protected function loadFile($path) return $dom; } + /** + * @throws \InvalidArgumentException When xml doesn't validate its xsd schema + */ protected function validate($dom, $file) { libxml_use_internal_errors(true); diff --git a/src/Symfony/Components/Routing/Loader/YamlFileLoader.php b/src/Symfony/Components/Routing/Loader/YamlFileLoader.php index a1f10de067ad7..4b8ce307deea4 100644 --- a/src/Symfony/Components/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Components/Routing/Loader/YamlFileLoader.php @@ -31,6 +31,8 @@ class YamlFileLoader extends FileLoader * @param string $file A Yaml file path * * @return RouteCollection A RouteCollection instance + * + * @throws \InvalidArgumentException When route can't be parsed */ public function load($file) { @@ -60,6 +62,9 @@ public function load($file) return $collection; } + /** + * @throws \InvalidArgumentException When coonfig pattern is not defined for the given route + */ protected function parseRoute(RouteCollection $collection, $name, $config, $file) { $defaults = isset($config['defaults']) ? $config['defaults'] : array(); @@ -76,6 +81,9 @@ protected function parseRoute(RouteCollection $collection, $name, $config, $file $collection->addRoute($name, $route); } + /** + * @throws \InvalidArgumentException When import resource is not defined + */ protected function parseImport(RouteCollection $collection, $name, $import, $file) { if (!isset($import['resource'])) diff --git a/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php index edbb7b5732b24..ef0cc9bf1cf90 100644 --- a/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ b/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php @@ -32,6 +32,8 @@ class ApacheMatcherDumper extends MatcherDumper * @param array $options An array of options * * @return string A PHP class representing the matcher class + * + * @throws \RuntimeException When a route has more than 9 variables */ public function dump(array $options = array()) { diff --git a/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php b/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php index 41e6eef0b1811..12e72ac0f5df9 100644 --- a/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php +++ b/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php @@ -41,6 +41,8 @@ public function __construct(RouteCollection $routes) * @param array $options An array of options * * @return string The representation of the routing + * + * @throws \LogicException When this abstrass class is not implemented */ public function dump(array $options = array()) { diff --git a/src/Symfony/Components/Routing/RouteCollection.php b/src/Symfony/Components/Routing/RouteCollection.php index ea9c49be46f2a..99a9f8c031cc6 100644 --- a/src/Symfony/Components/Routing/RouteCollection.php +++ b/src/Symfony/Components/Routing/RouteCollection.php @@ -37,6 +37,8 @@ public function __construct() * * @param string $name The route name * @param Route $route A Route instance + * + * @throws \InvalidArgumentException When route name contains non valid characters */ public function addRoute($name, Route $route) { diff --git a/src/Symfony/Components/Routing/RouteCompiler.php b/src/Symfony/Components/Routing/RouteCompiler.php index fc01978f5955b..f89296bf0d047 100644 --- a/src/Symfony/Components/Routing/RouteCompiler.php +++ b/src/Symfony/Components/Routing/RouteCompiler.php @@ -127,6 +127,8 @@ protected function postCompile() /** * Tokenizes the route. + * + * @throws \InvalidArgumentException When route can't be parsed */ protected function tokenize() { diff --git a/src/Symfony/Components/Routing/Router.php b/src/Symfony/Components/Routing/Router.php index 48795b14df61b..8b760d9e57c67 100644 --- a/src/Symfony/Components/Routing/Router.php +++ b/src/Symfony/Components/Routing/Router.php @@ -41,6 +41,8 @@ class Router implements RouterInterface * @param array $options An array of options * @param array $context The context * @param array $defaults The default values + * + * @throws \InvalidArgumentException When unsupported option is provided */ public function __construct($loader, array $options = array(), array $context = array(), array $defaults = array()) { @@ -249,6 +251,9 @@ protected function getCacheFile($class, $extension = 'php') return $this->options['cache_dir'].'/'.$class.'.'.$extension; } + /** + * @throws \RuntimeException When cache file can't be wrote + */ protected function writeCacheFile($file, $content) { $tmpFile = tempnam(dirname($file), basename($file)); diff --git a/src/Symfony/Components/Yaml/Inline.php b/src/Symfony/Components/Yaml/Inline.php index b94f7a15ea1c4..cd07d9c6b6a5b 100644 --- a/src/Symfony/Components/Yaml/Inline.php +++ b/src/Symfony/Components/Yaml/Inline.php @@ -69,6 +69,8 @@ static public function load($value) * @param mixed $value The PHP variable to convert * * @return string The YAML string representing the PHP array + * + * @throws Exception When trying to dump PHP ressource */ static public function dump($value) { @@ -157,6 +159,8 @@ static protected function dumpArray($value) * @param boolean $evaluate * * @return string A YAML string + * + * @throws ParserException When malformed inline YAML string is parsed */ static public function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) { @@ -202,6 +206,8 @@ static public function parseScalar($scalar, $delimiters = null, $stringDelimiter * @param integer $i * * @return string A YAML string + * + * @throws ParserException When malformed inline YAML string is parsed */ static protected function parseQuotedScalar($scalar, &$i) { @@ -235,6 +241,8 @@ static protected function parseQuotedScalar($scalar, &$i) * @param integer $i * * @return string A YAML string + * + * @throws ParserException When malformed inline YAML string is parsed */ static protected function parseSequence($sequence, &$i = 0) { @@ -295,6 +303,8 @@ static protected function parseSequence($sequence, &$i = 0) * @param integer $i * * @return string A YAML string + * + * @throws ParserException When malformed inline YAML string is parsed */ static protected function parseMapping($mapping, &$i = 0) { diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index b47a0dd0b89e6..a20896bcbe653 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -42,7 +42,7 @@ public function __construct($offset = 0) * * @return mixed A PHP value * - * @throws \InvalidArgumentException If the YAML is not valid + * @throws ParserException If the YAML is not valid */ public function parse($value) { @@ -298,6 +298,8 @@ protected function getCurrentLineIndentation() * @param integer $indentation The indent level at which the block is to be read, or null for default * * @return string A YAML string + * + * @throws ParserException When indentation problem are detected */ protected function getNextEmbedBlock($indentation = null) { @@ -386,6 +388,8 @@ protected function moveToPreviousLine() * @param string $value A YAML value * * @return mixed A PHP value + * + * @throws ParserException When reference doesn't not exist */ protected function parseValue($value) { diff --git a/src/Symfony/Components/Yaml/Yaml.php b/src/Symfony/Components/Yaml/Yaml.php index ff8671d5fe6d1..7c744a578edac 100644 --- a/src/Symfony/Components/Yaml/Yaml.php +++ b/src/Symfony/Components/Yaml/Yaml.php @@ -25,6 +25,8 @@ class Yaml * Sets the YAML specification version to use. * * @param string $version The YAML specification version + * + * @throws \InvalidArgumentException When version of YAML specs is not supported */ static public function setSpecVersion($version) { diff --git a/src/Symfony/Foundation/ClassCollectionLoader.php b/src/Symfony/Foundation/ClassCollectionLoader.php index 43ab9189265ac..d97bf6787ea5c 100644 --- a/src/Symfony/Foundation/ClassCollectionLoader.php +++ b/src/Symfony/Foundation/ClassCollectionLoader.php @@ -19,6 +19,9 @@ */ class ClassCollectionLoader { + /** + * @throws \InvalidArgumentException When class can't be loaded + */ static public function load($classes, $cacheDir, $name, $autoReload) { $cache = $cacheDir.'/'.$name.'.php'; diff --git a/src/Symfony/Foundation/Debug/ErrorHandler.php b/src/Symfony/Foundation/Debug/ErrorHandler.php index cc67b0cf8cab5..4dda26cdd26bd 100644 --- a/src/Symfony/Foundation/Debug/ErrorHandler.php +++ b/src/Symfony/Foundation/Debug/ErrorHandler.php @@ -46,6 +46,9 @@ public function register() set_error_handler(array($this, 'handle')); } + /** + * @throws \ErrorException When error_reporting returns error + */ public function handle($level, $message, $file, $line, $context) { if (0 === $this->level) diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 666fd137dcafc..25ae066317a44 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -98,6 +98,8 @@ public function isBooted() * the DI container. * * @return Kernel The current Kernel instance + * + * @throws \LogicException When the Kernel is already booted */ public function boot() { diff --git a/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php index 47ba1b1d59123..530fb406ce634 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php @@ -81,6 +81,8 @@ protected function configure() /** * @see Command + * + * @throws \InvalidArgumentException When neither of any build options is included */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php index df9b5d7fef3fc..ed440f852216a 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php @@ -48,6 +48,8 @@ protected function configure() /** * @see Command + * + * @throws \InvalidArgumentException When neither of --drop or --create is specified */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php index 537758422a311..d551bbd27978e 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php @@ -44,6 +44,8 @@ protected function configure() /** * @see Command + * + * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle\MySampleBundle") */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php index cc8d3583bd3f3..b30d8a8b40fc9 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php @@ -58,6 +58,8 @@ protected function configure() /** * @see Command + * + * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle\MySampleBundle") */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php b/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php index f22563e5a95b1..12ae1247ee226 100644 --- a/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php +++ b/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php @@ -82,6 +82,9 @@ public function write($data) $this->close($db); } + /** + * @throws \RuntimeException When neither of SQLite or PDO_SQLite extension is enabled + */ protected function initDb($readOnly = true) { if (class_exists('\SQLite3')) diff --git a/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php b/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php index 915a463ce5b41..fa3b9ad12af11 100644 --- a/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php @@ -42,6 +42,8 @@ protected function configure() /** * @see Command + * + * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php b/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php index 1a78024fce263..7fe622bbef227 100644 --- a/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php @@ -43,6 +43,9 @@ protected function configure() /** * @see Command + * + * @throws \InvalidArgumentException When namespace doesn't end with Bundle + * @throws \RuntimeException When bundle can't be executed */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php b/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php index 1108fa3ec4726..952f4c61ef14a 100644 --- a/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php @@ -104,6 +104,9 @@ protected function outputRoutes(OutputInterface $output, $routes) } } + /** + * @throws \InvalidArgumentException When route does not exist + */ protected function outputRoute(OutputInterface $output, $routes, $name) { $output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name))); diff --git a/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php b/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php index 9f78bc481d455..a8ecc0bd248ee 100644 --- a/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php +++ b/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php @@ -25,6 +25,9 @@ */ class ExceptionController extends Controller { + /** + * @throws \InvalidArgumentException When the exception template does not exist + */ public function exceptionAction(\Exception $exception, Request $originalRequest, array $logs) { $template = $this->container->getParameter('kernel.debug') ? 'exception' : 'error'; diff --git a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php index edaf3224f6ea0..9984af5a0f37d 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php +++ b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php @@ -74,6 +74,9 @@ public function resolve(Event $event) return true; } + /** + * @throws \InvalidArgumentException|\LogicException If controller can't be found + */ public function findController($bundle, $controller, $action) { $class = null; @@ -130,6 +133,9 @@ public function findController($bundle, $controller, $action) return array($controller, $method); } + /** + * @throws \RuntimeException When value for argument given is not provided + */ public function getMethodArguments(\ReflectionFunctionAbstract $r, array $parameters, $controller) { $arguments = array(); diff --git a/src/Symfony/Framework/WebBundle/Session/PdoSession.php b/src/Symfony/Framework/WebBundle/Session/PdoSession.php index ea776298bc9fd..218c332aba10d 100644 --- a/src/Symfony/Framework/WebBundle/Session/PdoSession.php +++ b/src/Symfony/Framework/WebBundle/Session/PdoSession.php @@ -21,6 +21,9 @@ class PdoSession extends NativeSession { protected $db; + /** + * @throws \InvalidArgumentException When "db_table" option is not provided + */ public function __construct(\PDO $db, $options = null) { $this->db = $db; @@ -60,8 +63,6 @@ public function __construct(\PDO $db, $options = null) * @param string $name (ignored) * * @return boolean true, if the session was opened, otherwise an exception is thrown - * - * @throws DatabaseException If a connection with the database does not exist or cannot be created */ public function sessionOpen($path = null, $name = null) { @@ -84,9 +85,9 @@ public function sessionClose() * * @param string $id A session ID * - * @return bool true, if the session was destroyed, otherwise an exception is thrown + * @return bool true, if the session was destroyed, otherwise an exception is thrown * - * @throws DatabaseException If the session cannot be destroyed + * @throws \RuntimeException If the session cannot be destroyed */ public function sessionDestroy($id) { @@ -118,7 +119,7 @@ public function sessionDestroy($id) * * @return bool true, if old sessions have been cleaned, otherwise an exception is thrown * - * @throws DatabaseException If any old sessions cannot be cleaned + * @throws \RuntimeException If any old sessions cannot be cleaned */ public function sessionGC($lifetime) { @@ -148,7 +149,7 @@ public function sessionGC($lifetime) * * @return string The session data if the session was read or created, otherwise an exception is thrown * - * @throws DatabaseException If the session cannot be read + * @throws \RuntimeException If the session cannot be read */ public function sessionRead($id) { @@ -202,7 +203,7 @@ public function sessionRead($id) * * @return bool true, if the session was written, otherwise an exception is thrown * - * @throws DatabaseException If the session data cannot be written + * @throws \RuntimeException If the session data cannot be written */ public function sessionWrite($id, $data) { diff --git a/src/Symfony/Framework/WebBundle/Session/SessionInterface.php b/src/Symfony/Framework/WebBundle/Session/SessionInterface.php index cbf91228ea92f..fb2661d158480 100644 --- a/src/Symfony/Framework/WebBundle/Session/SessionInterface.php +++ b/src/Symfony/Framework/WebBundle/Session/SessionInterface.php @@ -28,7 +28,7 @@ interface SessionInterface * * @return mixed Data associated with the key * - * @throws RuntimeException If an error occurs while reading data from this storage + * @throws \RuntimeException If an error occurs while reading data from this storage */ public function read($key); @@ -41,7 +41,7 @@ public function read($key); * * @return mixed Data associated with the key * - * @throws RuntimeException If an error occurs while removing data from this storage + * @throws \RuntimeException If an error occurs while removing data from this storage */ public function remove($key); @@ -53,7 +53,7 @@ public function remove($key); * @param string $key A unique key identifying your data * @param mixed $data Data associated with your key * - * @throws RuntimeException If an error occurs while writing to this storage + * @throws \RuntimeException If an error occurs while writing to this storage */ public function write($key, $data); @@ -64,7 +64,7 @@ public function write($key, $data); * * @return boolean True if session regenerated, false if error * - * @throws RuntimeException If an error occurs while regenerating this storage + * @throws \RuntimeException If an error occurs while regenerating this storage */ public function regenerate($destroy = false); } diff --git a/src/Symfony/Framework/WebBundle/Templating/Engine.php b/src/Symfony/Framework/WebBundle/Templating/Engine.php index e4f6126df8b15..2c42ad7158cda 100644 --- a/src/Symfony/Framework/WebBundle/Templating/Engine.php +++ b/src/Symfony/Framework/WebBundle/Templating/Engine.php @@ -77,6 +77,9 @@ public function has($name) return isset($this->helpers[$name]); } + /** + * @throws \InvalidArgumentException When the helper is not defined + */ public function get($name) { if (!isset($this->helpers[$name])) diff --git a/src/Symfony/Framework/WebBundle/Util/Filesystem.php b/src/Symfony/Framework/WebBundle/Util/Filesystem.php index 9962ae0e7ecc7..63b06f4b174d3 100644 --- a/src/Symfony/Framework/WebBundle/Util/Filesystem.php +++ b/src/Symfony/Framework/WebBundle/Util/Filesystem.php @@ -166,6 +166,8 @@ public function chmod($files, $mode, $umask = 0000) * * @param string $origin The origin filename * @param string $target The new filename + * + * @throws \RuntimeException When target file already exists */ public function rename($origin, $target) { @@ -220,6 +222,8 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) * @param string $targetDir The target directory * @param Finder $finder An Finder instance * @param array $options An array of options (see copy()) + * + * @throws \RuntimeException When file type is unknown */ public function mirror($originDir, $targetDir, $finder = null, $options = array()) { diff --git a/src/Symfony/Framework/WebBundle/Util/Finder.php b/src/Symfony/Framework/WebBundle/Util/Finder.php index c8cf0eb4469f5..c163ccc2ead1f 100644 --- a/src/Symfony/Framework/WebBundle/Util/Finder.php +++ b/src/Symfony/Framework/WebBundle/Util/Finder.php @@ -286,6 +286,8 @@ public function sortByType() * * @param mixed function or method to call * @return Finder Current object + * + * @throws \InvalidArgumentException If function or method does not exist */ public function exec() { diff --git a/src/Symfony/Framework/WebBundle/Util/NumberCompare.php b/src/Symfony/Framework/WebBundle/Util/NumberCompare.php index f1d1f01dbebea..5e7a7e6ef9824 100644 --- a/src/Symfony/Framework/WebBundle/Util/NumberCompare.php +++ b/src/Symfony/Framework/WebBundle/Util/NumberCompare.php @@ -43,7 +43,9 @@ public function __construct($test) { $this->test = $test; } - + /** + * @throws \RuntimeException If the test is not understood + */ public function test($number) { if (!preg_match('{^([<>]=?)?(.*?)([kmg]i?)?$}i', $this->test, $matches)) From 916378ef91d20216d44f8e7aa069d0f2e13c8c95 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Apr 2010 16:00:46 +0800 Subject: [PATCH 45/54] [RequestHandler] fixed warning when baseUrl is empty --- src/Symfony/Components/RequestHandler/Request.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index 87c4e50fb5b38..52e4cfdc9d13d 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -642,13 +642,13 @@ protected function prepareBaseUrl() // Does the baseUrl have anything in common with the request_uri? $requestUri = $this->getRequestUri(); - if (0 === strpos($requestUri, $baseUrl)) + if ($baseUrl && 0 === strpos($requestUri, $baseUrl)) { // full $baseUrl matches return $baseUrl; } - if (0 === strpos($requestUri, dirname($baseUrl))) + if ($baseUrl && 0 === strpos($requestUri, dirname($baseUrl))) { // directory portion of $baseUrl matches return rtrim(dirname($baseUrl), '/'); From c7fd3c22766029878c0fc562b7150b6cae406d29 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Apr 2010 16:21:02 +0800 Subject: [PATCH 46/54] [RequestHandler] added files and cookies support to Request --- .../Components/RequestHandler/Request.php | 181 ++++++++++++++++-- 1 file changed, 162 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index 52e4cfdc9d13d..2e0734de0a209 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -29,6 +29,8 @@ class Request implements RequestInterface protected $requestParameters; protected $queryParameters; protected $serverParameters; + protected $filesParameters; + protected $cookiesParameters; protected $languages; protected $charsets; protected $acceptableContentTypes; @@ -48,11 +50,13 @@ class Request implements RequestInterface * @param array $query The GET parameters * @param array $request The POST parameters * @param array $path The parameters parsed from the PATH_INFO (see Router) + * @param array $cookies The COOKIE parameters + * @param array $files The FILES parameters * @param array $server The SERVER parameters */ - public function __construct(array $query = null, array $request = null, array $path = null, array $server = null) + public function __construct(array $query = null, array $request = null, array $path = null, array $cookies = null, array $files = null, array $server = null) { - $this->setParameters($request, $query, $path, $server); + $this->setParameters($request, $query, $path, $cookies, $files, $server); } /** @@ -63,13 +67,17 @@ public function __construct(array $query = null, array $request = null, array $p * @param array $query The GET parameters * @param array $request The POST parameters * @param array $path The parameters parsed from the PATH_INFO + * @param array $cookies The COOKIE parameters + * @param array $files The FILES parameters * @param array $server The SERVER parameters */ - public function setParameters(array $query = null, array $request = null, array $path = null, array $server = null) + public function setParameters(array $query = null, array $request = null, array $path = null, array $cookies = null, array $files = null, array $server = null) { $this->requestParameters = null !== $request ? $request : $_POST; $this->queryParameters = null !== $query ? $query : $_GET; $this->pathParameters = null !== $path ? $path : array(); + $this->cookiesParameters = null !== $cookies ? $cookies : $_COOKIE; + $this->filesParameters = self::convertFileInformation(null !== $files ? $files : $_FILES); $this->serverParameters = null !== $server ? $server : $_SERVER; $this->languages = null; @@ -90,34 +98,25 @@ public function setParameters(array $query = null, array $request = null, array * @param array $query The GET parameters * @param array $request The POST parameters * @param array $path The parameters parsed from the PATH_INFO + * @param array $cookies The COOKIE parameters + * @param array $files The FILES parameters * @param array $server The SERVER parameters */ - public function duplicate(array $query = null, array $request = null, array $path = null, array $server = null) + public function duplicate(array $query = null, array $request = null, array $path = null, array $cookies = null, array $files = null, array $server = null) { $dup = clone $this; $dup->setParameters( null !== $query ? $query : $this->queryParameters, null !== $request ? $request : $this->requestParameters, null !== $path ? $path : $this->pathParameters, + null !== $cookies ? $cookies : $this->cookiesParameters, + null !== $files ? $files : $this->filesParameters, null !== $server ? $server : $this->serverParameters ); return $dup; } - /** - * Gets a cookie value. - * - * @param string $name Cookie name - * @param string $defaultValue Default value returned when no cookie with given name is found - * - * @return mixed The cookie value - */ - public function getCookie($name, $default = null) - { - return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default; - } - // Order of precedence: GET, PATH, POST, COOKIE // Avoid using this method in controllers: // * slow @@ -128,51 +127,145 @@ public function getParameter($key, $default = null) return $this->getQueryParameter($key, $this->getPathParameter($key, $this->getRequestParameter($key, $default))); } + /** + * Returns the server parameters ($_SERVER). + * + * @return array An array of server parameters + */ public function getServerParameters() { return $this->serverParameters; } - public function getServerParameter($name, $default = null) + /** + * Returns a server parameter ($_SERVER). + * + * @param string $key The key + * @param mixed $default The default value + */ + public function getServerParameter($key, $default = null) { - return isset($this->serverParameters[$name]) ? $this->serverParameters[$name] : $default; + return isset($this->serverParameters[$key]) ? $this->serverParameters[$key] : $default; } + /** + * Returns the path parameters. + * + * @return array An array of path parameters + */ public function getPathParameters() { return $this->pathParameters; } + /** + * Sets the path parameters. + * + * @param array An array of path parameters + */ public function setPathParameters(array $parameters) { $this->pathParameters = $parameters; } + /** + * Returns a path parameter. + * + * @param string $key The key + * @param mixed $default The default value + */ public function getPathParameter($key, $default = null) { return isset($this->pathParameters[$key]) ? $this->pathParameters[$key] : $default; } + /** + * Returns the request parameters ($_POST). + * + * @return array An array of request parameters + */ public function getRequestParameters() { return $this->requestParameters; } + /** + * Returns a request parameter ($_POST). + * + * @param string $key The server key + * @param mixed $default The default value + */ public function getRequestParameter($key, $default = null) { return isset($this->requestParameters[$key]) ? $this->requestParameters[$key] : $default; } + /** + * Returns the query parameters ($_GET). + * + * @return array An array of query parameters + */ public function getQueryParameters() { return $this->queryParameters; } + /** + * Returns a query parameter ($_GET). + * + * @param string $key The server key + * @param mixed $default The default value + */ public function getQueryParameter($key, $default = null) { return isset($this->queryParameters[$key]) ? $this->queryParameters[$key] : $default; } + /** + * Returns a cookie value ($_COOKIE). + * + * @param string $key The key + * @param mixed $default The default value + * + * @return mixed The cookie value + */ + public function getCookie($key, $default = null) + { + return isset($this->cookiesParameters[$key]) ? $cookiesParameters[$key] : $default; + } + + /** + * Returns the array of cookies ($_COOKIE). + * + * @param array An array of cookies + */ + public function getCookies() + { + return $this->cookiesParameters; + } + + /** + * Returns a file from the request ($_FILES). + * + * @param string $key A key + * + * @return array The associated file + */ + public function getFile($key) + { + return isset($this->filesParameters[$key]) ? $this->filesParameters[$key] : array(); + } + + /** + * Returns the array of files ($_FILES). + * + * @return array An associative array of files + */ + public function getFiles() + { + return $this->filesParameters; + } + public function getHttpHeader($name, $default = null) { return $this->getServerParameter('HTTP_'.strtoupper(strtr($name, '-', '_')), $default); @@ -735,6 +828,26 @@ protected function preparePathInfo() return (string) $pathInfo; } + /** + * Converts uploaded file array to a format following the $_GET and $POST naming convention. + * + * It's safe to pass an already converted array, in which case this method just returns the original array unmodified. + * + * @param array $taintedFiles An array representing uploaded file information + * + * @return array An array of re-ordered uploaded file information + */ + protected function convertFileInformation(array $taintedFiles) + { + $files = array(); + foreach ($taintedFiles as $key => $data) + { + $files[$key] = $this->fixPhpFilesArray($data); + } + + return $files; + } + static protected function initializeFormats() { static::$formats = array( @@ -747,4 +860,34 @@ static protected function initializeFormats() 'atom' => 'application/atom+xml', ); } + + static protected function fixPhpFilesArray($data) + { + $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type'); + $keys = array_keys($data); + sort($keys); + + if ($fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) + { + return $data; + } + + $files = $data; + foreach ($fileKeys as $k) + { + unset($files[$k]); + } + foreach (array_keys($data['name']) as $key) + { + $files[$key] = self::fixPhpFilesArray(array( + 'error' => $data['error'][$key], + 'name' => $data['name'][$key], + 'type' => $data['type'][$key], + 'tmp_name' => $data['tmp_name'][$key], + 'size' => $data['size'][$key], + )); + } + + return $files; + } } From 692db5d9f58454a637902c3d3008c80f28637a75 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Apr 2010 22:18:25 +0800 Subject: [PATCH 47/54] [DependencyInjection] changed exception class in __call() --- src/Symfony/Components/DependencyInjection/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Components/DependencyInjection/Container.php b/src/Symfony/Components/DependencyInjection/Container.php index d864f2d831ab5..28f8e03a70862 100644 --- a/src/Symfony/Components/DependencyInjection/Container.php +++ b/src/Symfony/Components/DependencyInjection/Container.php @@ -339,7 +339,7 @@ public function __call($method, $arguments) { if (!preg_match('/^get(.+)Service$/', $method, $match)) { - throw new \RuntimeException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); + throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); } return $this->getService(self::underscore($match[1])); From 8398c29edbab5e86f868ebd33e13e7c0053cf286 Mon Sep 17 00:00:00 2001 From: pborreli Date: Tue, 6 Apr 2010 02:28:55 +0800 Subject: [PATCH 48/54] fixed spelling typo --- .../Components/DependencyInjection/Dumper/YamlDumper.php | 2 +- .../DependencyInjection/Loader/LoaderExtensionInterface.php | 2 +- src/Symfony/Components/OutputEscaper/ArrayDecorator.php | 2 +- src/Symfony/Components/OutputEscaper/IteratorDecorator.php | 4 ++-- src/Symfony/Components/Routing/CompiledRoute.php | 2 +- src/Symfony/Components/Routing/Loader/YamlFileLoader.php | 2 +- src/Symfony/Components/Yaml/Inline.php | 2 +- src/Symfony/Foundation/EventDispatcher.php | 2 +- .../Framework/DoctrineBundle/Command/DoctrineCommand.php | 2 +- .../ProfilerBundle/DataCollector/DataCollectorManager.php | 6 +++--- .../DependencyInjection/SwiftmailerExtension.php | 2 +- src/Symfony/Framework/WebBundle/Util/Filesystem.php | 2 +- src/Symfony/Framework/WebBundle/Util/Finder.php | 4 ++-- src/Symfony/Framework/WebBundle/Util/Glob.php | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php index 1a5a9191f6a0d..c614dad630f37 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php @@ -144,7 +144,7 @@ protected function addParameters() } /** - * @throws \RuntimeException When trying to dump object or ressource + * @throws \RuntimeException When trying to dump object or resource */ protected function dumpValue($value) { diff --git a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php index cd94acfb5678e..aee78181a559b 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php +++ b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php @@ -53,7 +53,7 @@ public function getNamespace(); public function getXsdValidationBasePath(); /** - * Returns the recommanded alias to use in XML. + * Returns the recommended alias to use in XML. * * This alias is also the mandatory prefix to use when using YAML. * diff --git a/src/Symfony/Components/OutputEscaper/ArrayDecorator.php b/src/Symfony/Components/OutputEscaper/ArrayDecorator.php index e024a6bd87b24..505aef85191e1 100644 --- a/src/Symfony/Components/OutputEscaper/ArrayDecorator.php +++ b/src/Symfony/Components/OutputEscaper/ArrayDecorator.php @@ -89,7 +89,7 @@ public function valid() /** * Returns true if the supplied offset isset in the array (as required by the ArrayAccess interface). * - * @param string $offset The offset of the value to check existance of + * @param string $offset The offset of the value to check existence of * * @return bool true if the offset isset; false otherwise */ diff --git a/src/Symfony/Components/OutputEscaper/IteratorDecorator.php b/src/Symfony/Components/OutputEscaper/IteratorDecorator.php index ee02214257134..ca00795b4555c 100644 --- a/src/Symfony/Components/OutputEscaper/IteratorDecorator.php +++ b/src/Symfony/Components/OutputEscaper/IteratorDecorator.php @@ -33,7 +33,7 @@ class IteratorDecorator extends ObjectDecorator implements \Iterator, \Countable private $iterator; /** - * Constructs a new escaping iteratoror using the escaping method and value supplied. + * Constructs a new escaping iterator using the escaping method and value supplied. * * @param string $escaper The escaping method to use * @param \Traversable $value The iterator to escape @@ -100,7 +100,7 @@ public function valid() /** * Returns true if the supplied offset isset in the array (as required by the ArrayAccess interface). * - * @param string $offset The offset of the value to check existance of + * @param string $offset The offset of the value to check existence of * * @return bool true if the offset isset; false otherwise */ diff --git a/src/Symfony/Components/Routing/CompiledRoute.php b/src/Symfony/Components/Routing/CompiledRoute.php index 2c6eae43f491f..1e2b287f19184 100644 --- a/src/Symfony/Components/Routing/CompiledRoute.php +++ b/src/Symfony/Components/Routing/CompiledRoute.php @@ -31,7 +31,7 @@ class CompiledRoute * * @param Route $route A original Route instance * @param string $staticPrefix The static prefix of the compiled route - * @param string $regex The regular expresion to use to match this route + * @param string $regex The regular expression to use to match this route * @param array $tokens An array of tokens to use to generate URL for this route * @param array $variables An array of variables */ diff --git a/src/Symfony/Components/Routing/Loader/YamlFileLoader.php b/src/Symfony/Components/Routing/Loader/YamlFileLoader.php index 4b8ce307deea4..c97f7a1b59649 100644 --- a/src/Symfony/Components/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Components/Routing/Loader/YamlFileLoader.php @@ -63,7 +63,7 @@ public function load($file) } /** - * @throws \InvalidArgumentException When coonfig pattern is not defined for the given route + * @throws \InvalidArgumentException When config pattern is not defined for the given route */ protected function parseRoute(RouteCollection $collection, $name, $config, $file) { diff --git a/src/Symfony/Components/Yaml/Inline.php b/src/Symfony/Components/Yaml/Inline.php index cd07d9c6b6a5b..7e3c630c891dd 100644 --- a/src/Symfony/Components/Yaml/Inline.php +++ b/src/Symfony/Components/Yaml/Inline.php @@ -70,7 +70,7 @@ static public function load($value) * * @return string The YAML string representing the PHP array * - * @throws Exception When trying to dump PHP ressource + * @throws Exception When trying to dump PHP resource */ static public function dump($value) { diff --git a/src/Symfony/Foundation/EventDispatcher.php b/src/Symfony/Foundation/EventDispatcher.php index 6cbf84b13ab84..3919358680b80 100644 --- a/src/Symfony/Foundation/EventDispatcher.php +++ b/src/Symfony/Foundation/EventDispatcher.php @@ -16,7 +16,7 @@ */ /** - * This EventDispatcher implementation uses a DependencyInjection contrainer to + * This EventDispatcher implementation uses a DependencyInjection container to * lazy load listeners. * * @package symfony diff --git a/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php index a560aafc57783..1216564d0f20b 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php @@ -24,7 +24,7 @@ */ /** - * Base class for Doctrine consol commands to extend from. + * Base class for Doctrine console commands to extend from. * * @package symfony * @subpackage console diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php index bd23e5f384d69..b4e94d5506bf8 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php @@ -82,7 +82,7 @@ public function initCollectors() { $config = $this->container->findAnnotatedServiceIds('data_collector'); $ids = array(); - $coreColectors = array(); + $coreCollectors = array(); $userCollectors = array(); foreach ($config as $id => $attributes) { @@ -91,7 +91,7 @@ public function initCollectors() if (isset($attributes[0]['core']) && $attributes[0]['core']) { - $coreColectors[$collector->getName()] = $collector; + $coreCollectors[$collector->getName()] = $collector; } else { @@ -99,6 +99,6 @@ public function initCollectors() } } - return $this->collectors = array_merge($coreColectors, $userCollectors); + return $this->collectors = array_merge($coreCollectors, $userCollectors); } } diff --git a/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php b/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php index 56eaaccd57cbd..e8584dac7ffde 100644 --- a/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php +++ b/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php @@ -137,7 +137,7 @@ public function getNamespace() } /** - * Returns the recommanded alias to use in XML. + * Returns the recommended alias to use in XML. * * This alias is also the mandatory prefix to use when using YAML. * diff --git a/src/Symfony/Framework/WebBundle/Util/Filesystem.php b/src/Symfony/Framework/WebBundle/Util/Filesystem.php index 63b06f4b174d3..8288d9b0029d4 100644 --- a/src/Symfony/Framework/WebBundle/Util/Filesystem.php +++ b/src/Symfony/Framework/WebBundle/Util/Filesystem.php @@ -24,7 +24,7 @@ class Filesystem * * This method only copies the file if the origin file is newer than the target file. * - * By default, if the target already exists, it is not overriden. + * By default, if the target already exists, it is not overridden. * * To override existing files, pass the "override" option. * diff --git a/src/Symfony/Framework/WebBundle/Util/Finder.php b/src/Symfony/Framework/WebBundle/Util/Finder.php index c163ccc2ead1f..e17de759b02b1 100644 --- a/src/Symfony/Framework/WebBundle/Util/Finder.php +++ b/src/Symfony/Framework/WebBundle/Util/Finder.php @@ -241,7 +241,7 @@ public function discard() * * Currently supports Subversion, CVS, DARCS, Gnu Arch, Monotone, Bazaar-NG, GIT, Mercurial * - * @param bool $ignore falase when version control directories shall be included (default is true) + * @param bool $ignore false when version control directories shall be included (default is true) * * @return Finder Current object */ @@ -279,7 +279,7 @@ public function sortByType() /** * Executes function or method for each element. * - * Element match if functino or method returns true. + * Element match if function or method returns true. * * $finder->exec('myfunction'); * $finder->exec(array($object, 'mymethod')); diff --git a/src/Symfony/Framework/WebBundle/Util/Glob.php b/src/Symfony/Framework/WebBundle/Util/Glob.php index 12db4cb60740f..9748e64b3530a 100644 --- a/src/Symfony/Framework/WebBundle/Util/Glob.php +++ b/src/Symfony/Framework/WebBundle/Util/Glob.php @@ -50,7 +50,7 @@ public static function setStrictWildcardSlash($boolean) } /** - * Returns a compiled regex which is the equiavlent of the globbing pattern. + * Returns a compiled regex which is the equivalent of the globbing pattern. * * @param string $glob pattern * @return string regex From e84774a653a468d8b841b1f9b556099aeab0f090 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Apr 2010 22:31:51 +0800 Subject: [PATCH 49/54] [DependencyInjection] fixed phpdoc --- src/Symfony/Components/DependencyInjection/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Components/DependencyInjection/Container.php b/src/Symfony/Components/DependencyInjection/Container.php index 28f8e03a70862..7840ba04cb506 100644 --- a/src/Symfony/Components/DependencyInjection/Container.php +++ b/src/Symfony/Components/DependencyInjection/Container.php @@ -333,7 +333,7 @@ public function __unset($id) * * @return mixed * - * @throws \RuntimeException When calling to an undefined method + * @throws \BadMethodCallException When calling to an undefined method */ public function __call($method, $arguments) { From 52981aab2cb716c3c85c5686ab6ed94f5af8162f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Apr 2010 23:44:52 +0800 Subject: [PATCH 50/54] [RequestHandler] added Request::createFromUri() --- .../Components/RequestHandler/Request.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index 2e0734de0a209..fcf9320ab700f 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -92,6 +92,57 @@ public function setParameters(array $query = null, array $request = null, array $this->format = null; } + /** + * Creates a Request based on a given URI and configuration. + * + * @param string $uri The URI + * @param string $method The HTTP method + * @param array $parameters The request (GET) or query (POST) parameters + * @param array $cookies The request cookies ($_COOKIE) + * @param array $files The request files ($_FILES) + * @param array $server The server parameters ($_SERVER) + * + */ + static public function createFromUri($uri, $method = 'get', $parameters = array(), $cookies = array(), $files = array(), $server = array()) + { + if (in_array($method, array('post', 'put', 'delete'))) + { + $request = $parameters; + $query = array(); + } + else + { + $request = array(); + $query = $parameters; + } + + $queryString = false !== ($pos = strpos($uri, '?')) ? html_entity_decode(substr($uri, $pos + 1)) : ''; + parse_str($queryString, $qs); + if (is_array($qs)) + { + $query = array_replace($qs, $query); + } + + $server = array_replace(array( + 'HTTP_HOST' => 'localhost', + 'SERVER_NAME' => 'localhost', + 'SERVER_PORT' => 80, + 'HTTP_USER_AGENT' => 'SymfonyClient/1.0', + 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', + 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', + 'REMOTE_ADDR' => '127.0.0.1', + 'REQUEST_METHOD' => strtoupper($method), + 'PATH_INFO' => '', + 'REQUEST_URI' => $uri, + 'SCRIPT_NAME' => '', + 'SCRIPT_FILENAME' => '', + 'QUERY_STRING' => $queryString, + ), $server); + + return new self($request, $query, array(), $cookies, $files, $server); + } + /** * Clones a request and overrides some of its parameters. * From 4b49a370d629aedddb12a6bf2548c3871cf3f608 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Apr 2010 23:48:47 +0800 Subject: [PATCH 51/54] [RequestHandler] fixed phpdoc --- src/Symfony/Components/RequestHandler/Request.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index fcf9320ab700f..d473f9d84f5f5 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -102,6 +102,7 @@ public function setParameters(array $query = null, array $request = null, array * @param array $files The request files ($_FILES) * @param array $server The server parameters ($_SERVER) * + * @return Request A Request instance */ static public function createFromUri($uri, $method = 'get', $parameters = array(), $cookies = array(), $files = array(), $server = array()) { From d73865c2009817afebdf413c32c1ed082c1fb75a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 7 Apr 2010 00:11:22 +0800 Subject: [PATCH 52/54] [CssSelector] removed the use of lower-case() in XPath as it is not supported by PHP --- src/Symfony/Components/CssSelector/Node/FunctionNode.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Components/CssSelector/Node/FunctionNode.php b/src/Symfony/Components/CssSelector/Node/FunctionNode.php index a18b4872de401..87ae77db8d203 100644 --- a/src/Symfony/Components/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Components/CssSelector/Node/FunctionNode.php @@ -170,7 +170,11 @@ protected function _xpath_contains($xpath, $expr) { $expr = $expr->formatElement(); } - $xpath->addCondition(sprintf('contains(css:lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr)))); + + // FIXME: lower-case is only available with XPath 2 + //$xpath->addCondition(sprintf('contains(lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr)))); + $xpath->addCondition(sprintf('contains(string(.), %s)', XPathExpr::xpathLiteral($expr))); + // FIXME: Currently case insensitive matching doesn't seem to be happening return $xpath; From 173f4118f5091b64b3c6f3ba82c84d49259f19ee Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Wed, 7 Apr 2010 08:51:29 +0800 Subject: [PATCH 53/54] Fixed @package and @subpackage phpdoc tags --- .../Components/Console/Application.php | 6 +++--- .../Components/Console/Command/Command.php | 6 +++--- .../Console/Command/HelpCommand.php | 6 +++--- .../Console/Command/ListCommand.php | 6 +++--- .../Console/Helper/DialogHelper.php | 6 +++--- .../Console/Helper/FormatterHelper.php | 6 +++--- .../Components/Console/Helper/Helper.php | 6 +++--- .../Console/Helper/HelperInterface.php | 6 +++--- .../Components/Console/Helper/HelperSet.php | 6 +++--- .../Components/Console/Input/ArgvInput.php | 10 ++++----- .../Components/Console/Input/ArrayInput.php | 8 +++---- .../Components/Console/Input/Input.php | 6 +++--- .../Console/Input/InputArgument.php | 6 +++--- .../Console/Input/InputDefinition.php | 6 +++--- .../Console/Input/InputInterface.php | 6 +++--- .../Components/Console/Input/InputOption.php | 6 +++--- .../Components/Console/Input/StringInput.php | 6 +++--- .../Console/Output/ConsoleOutput.php | 6 +++--- .../Components/Console/Output/NullOutput.php | 6 +++--- .../Components/Console/Output/Output.php | 6 +++--- .../Console/Output/OutputInterface.php | 6 +++--- .../Console/Output/StreamOutput.php | 6 +++--- src/Symfony/Components/Console/Shell.php | 6 +++--- .../Console/Tester/ApplicationTester.php | 14 +++++++++++++ .../Console/Tester/CommandTester.php | 14 +++++++++++++ .../CssSelector/Node/AttribNode.php | 6 +++--- .../Components/CssSelector/Node/ClassNode.php | 6 +++--- .../CssSelector/Node/CombinedSelectorNode.php | 6 +++--- .../CssSelector/Node/ElementNode.php | 6 +++--- .../CssSelector/Node/FunctionNode.php | 6 +++--- .../Components/CssSelector/Node/HashNode.php | 6 +++--- .../CssSelector/Node/NodeInterface.php | 6 +++--- .../Components/CssSelector/Node/OrNode.php | 6 +++--- .../CssSelector/Node/PseudoNode.php | 6 +++--- src/Symfony/Components/CssSelector/Parser.php | 6 +++--- .../Components/CssSelector/SyntaxError.php | 6 +++--- src/Symfony/Components/CssSelector/Token.php | 6 +++--- .../Components/CssSelector/TokenStream.php | 6 +++--- .../Components/CssSelector/Tokenizer.php | 6 +++--- .../Components/CssSelector/XPathExpr.php | 6 +++--- .../Components/CssSelector/XPathExprOr.php | 6 +++--- .../AnnotatedContainerInterface.php | 6 +++--- .../DependencyInjection/Builder.php | 6 +++--- .../BuilderConfiguration.php | 6 +++--- .../DependencyInjection/Container.php | 6 +++--- .../ContainerInterface.php | 6 +++--- .../DependencyInjection/Definition.php | 6 +++--- .../DependencyInjection/Dumper/Dumper.php | 6 +++--- .../Dumper/DumperInterface.php | 6 +++--- .../Dumper/GraphvizDumper.php | 6 +++--- .../DependencyInjection/Dumper/PhpDumper.php | 6 +++--- .../DependencyInjection/Dumper/XmlDumper.php | 6 +++--- .../DependencyInjection/Dumper/YamlDumper.php | 6 +++--- .../DependencyInjection/FileResource.php | 6 +++--- .../DependencyInjection/Loader/FileLoader.php | 6 +++--- .../Loader/IniFileLoader.php | 6 +++--- .../DependencyInjection/Loader/Loader.php | 6 +++--- .../Loader/LoaderExtension.php | 6 +++--- .../Loader/LoaderExtensionInterface.php | 6 +++--- .../Loader/LoaderInterface.php | 6 +++--- .../Loader/XmlFileLoader.php | 6 +++--- .../Loader/YamlFileLoader.php | 6 +++--- .../DependencyInjection/Parameter.php | 6 +++--- .../DependencyInjection/Reference.php | 6 +++--- .../DependencyInjection/ResourceInterface.php | 6 +++--- .../DependencyInjection/SimpleXMLElement.php | 9 +++++++- .../Components/EventDispatcher/Event.php | 6 +++--- .../EventDispatcher/EventDispatcher.php | 6 +++--- .../OutputEscaper/ArrayDecorator.php | 6 +++--- .../Components/OutputEscaper/Escaper.php | 6 +++--- .../OutputEscaper/GetterDecorator.php | 8 +++---- .../OutputEscaper/IteratorDecorator.php | 6 +++--- .../OutputEscaper/ObjectDecorator.php | 6 +++--- .../OutputEscaper/SafeDecorator.php | 6 +++--- .../Exception/ForbiddenHttpException.php | 16 ++++++++++++++ .../Exception/HttpException.php | 19 ++++++++++++++++- .../Exception/NotFoundHttpException.php | 16 ++++++++++++++ .../Exception/UnauthorizedHttpException.php | 16 ++++++++++++++ .../Components/RequestHandler/Request.php | 6 +++--- .../RequestHandler/RequestHandler.php | 6 +++--- .../RequestHandler/RequestInterface.php | 6 +++--- .../Components/RequestHandler/Response.php | 6 +++--- .../RequestHandler/ResponseInterface.php | 6 +++--- .../Components/Routing/CompiledRoute.php | 6 +++--- .../Components/Routing/FileResource.php | 6 +++--- .../Generator/Dumper/GeneratorDumper.php | 6 +++--- .../Dumper/GeneratorDumperInterface.php | 6 +++--- .../Generator/Dumper/PhpGeneratorDumper.php | 6 +++--- .../Routing/Generator/UrlGenerator.php | 6 +++--- .../Generator/UrlGeneratorInterface.php | 6 +++--- .../Components/Routing/Loader/FileLoader.php | 6 +++--- .../Routing/Loader/LoaderInterface.php | 6 +++--- .../Routing/Loader/XmlFileLoader.php | 6 +++--- .../Routing/Loader/YamlFileLoader.php | 6 +++--- .../Routing/Matcher/ApacheUrlMatcher.php | 6 +++--- .../Matcher/Dumper/ApacheMatcherDumper.php | 6 +++--- .../Routing/Matcher/Dumper/MatcherDumper.php | 6 +++--- .../Matcher/Dumper/MatcherDumperInterface.php | 6 +++--- .../Matcher/Dumper/PhpMatcherDumper.php | 6 +++--- .../Components/Routing/Matcher/UrlMatcher.php | 6 +++--- .../Routing/Matcher/UrlMatcherInterface.php | 6 +++--- .../Components/Routing/ResourceInterface.php | 6 +++--- src/Symfony/Components/Routing/Route.php | 6 +++--- .../Components/Routing/RouteCollection.php | 6 +++--- .../Components/Routing/RouteCompiler.php | 6 +++--- .../Routing/RouteCompilerInterface.php | 6 +++--- src/Symfony/Components/Routing/Router.php | 6 +++--- .../Components/Routing/RouterInterface.php | 6 +++--- .../Templating/DebuggerInterface.php | 6 +++--- src/Symfony/Components/Templating/Engine.php | 6 +++--- .../Templating/Helper/AssetsHelper.php | 6 +++--- .../Components/Templating/Helper/Helper.php | 6 +++--- .../Templating/Helper/HelperInterface.php | 6 +++--- .../Templating/Helper/JavascriptsHelper.php | 6 +++--- .../Templating/Helper/SlotsHelper.php | 6 +++--- .../Templating/Helper/StylesheetsHelper.php | 6 +++--- .../Templating/Loader/CacheLoader.php | 8 +++---- .../Templating/Loader/ChainLoader.php | 6 +++--- .../Loader/CompilableLoaderInterface.php | 6 +++--- .../Templating/Loader/FilesystemLoader.php | 6 +++--- .../Components/Templating/Loader/Loader.php | 6 +++--- .../Templating/Loader/LoaderInterface.php | 6 +++--- .../Templating/Renderer/PhpRenderer.php | 6 +++--- .../Templating/Renderer/Renderer.php | 6 +++--- .../Templating/Renderer/RendererInterface.php | 8 +++---- .../Templating/Storage/FileStorage.php | 6 +++--- .../Components/Templating/Storage/Storage.php | 6 +++--- .../Templating/Storage/StringStorage.php | 6 +++--- src/Symfony/Components/Yaml/Dumper.php | 6 +++--- src/Symfony/Components/Yaml/Exception.php | 6 +++--- src/Symfony/Components/Yaml/Inline.php | 6 +++--- src/Symfony/Components/Yaml/Parser.php | 6 +++--- .../Components/Yaml/ParserException.php | 6 +++--- src/Symfony/Components/Yaml/Yaml.php | 6 +++--- src/Symfony/Foundation/Bundle/Bundle.php | 7 ++++--- .../Foundation/Bundle/BundleInterface.php | 7 ++++--- .../Foundation/Bundle/KernelBundle.php | 7 ++++--- .../Foundation/Bundle/KernelExtension.php | 16 +++++++------- .../Foundation/ClassCollectionLoader.php | 7 ++++--- .../Foundation/Debug/ErrorException.php | 7 ++++--- src/Symfony/Foundation/Debug/ErrorHandler.php | 7 ++++--- .../Foundation/Debug/EventDispatcher.php | 5 +++-- src/Symfony/Foundation/EventDispatcher.php | 5 +++-- src/Symfony/Foundation/Kernel.php | 21 ++++++++++--------- src/Symfony/Foundation/LoggerInterface.php | 7 ++++--- .../Foundation/UniversalClassLoader.php | 6 +++--- src/Symfony/Foundation/packager.php | 2 +- .../Framework/DoctrineBundle/Bundle.php | 7 ++++--- .../Command/BuildDoctrineCommand.php | 6 +++--- .../Command/BuildEntitiesDoctrineCommand.php | 6 +++--- .../Command/ClearCacheDoctrineCommand.php | 6 +++--- .../Command/ConvertMappingDoctrineCommand.php | 6 +++--- .../Command/DatabaseToolDoctrineCommand.php | 6 +++--- .../Command/DoctrineCommand.php | 6 +++--- ...nsureProductionSettingsDoctrineCommand.php | 6 +++--- .../GenerateProxiesDoctrineCommand.php | 6 +++--- .../Command/ImportMappingDoctrineCommand.php | 6 +++--- .../Command/InitEntityDoctrineCommand.php | 6 +++--- .../LoadDataFixturesDoctrineCommand.php | 8 +++---- .../Command/RunDqlDoctrineCommand.php | 8 +++---- .../Command/RunSqlDoctrineCommand.php | 8 +++---- .../Command/SchemaToolDoctrineCommand.php | 6 +++--- .../Command/VersionDoctrineCommand.php | 6 +++--- .../Controller/DoctrineController.php | 5 +++-- .../DataCollector/DoctrineDataCollector.php | 7 ++++--- .../DependencyInjection/DoctrineExtension.php | 6 +++--- .../DoctrineBundle/Logger/DbalLogger.php | 7 ++++--- .../Framework/ProfilerBundle/Bundle.php | 7 ++++--- .../DataCollector/AppDataCollector.php | 7 ++++--- .../DataCollector/ConfigDataCollector.php | 7 ++++--- .../DataCollector/DataCollector.php | 7 ++++--- .../DataCollector/DataCollectorInterface.php | 7 ++++--- .../DataCollector/DataCollectorManager.php | 7 ++++--- .../DataCollector/MemoryDataCollector.php | 7 ++++--- .../DataCollector/TimerDataCollector.php | 7 ++++--- .../DependencyInjection/ProfilerExtension.php | 5 +++-- .../Listener/WebDebugToolbar.php | 7 ++++--- .../ProfilerBundle/ProfilerStorage.php | 7 ++++--- .../Framework/SwiftmailerBundle/Bundle.php | 7 ++++--- .../SwiftmailerExtension.php | 8 +++---- src/Symfony/Framework/WebBundle/Bundle.php | 7 ++++--- .../Command/AssetsInstallCommand.php | 8 +++---- .../Framework/WebBundle/Command/Command.php | 8 +++---- .../WebBundle/Command/InitBundleCommand.php | 6 +++--- .../Command/RouterApacheDumperCommand.php | 8 +++---- .../WebBundle/Command/RouterDebugCommand.php | 8 +++---- .../WebBundle/Console/Application.php | 7 ++++--- .../Console/BootstrapApplication.php | 7 ++++--- .../Framework/WebBundle/Console/Shell.php | 7 ++++--- .../Framework/WebBundle/Controller.php | 5 +++-- .../Controller/DefaultController.php | 5 +++-- .../Controller/ExceptionController.php | 5 +++-- .../Controller/RedirectController.php | 5 +++-- .../Controller/TemplateController.php | 5 +++-- .../WebBundle/Debug/ExceptionFormatter.php | 7 ++++--- .../DependencyInjection/WebExtension.php | 7 ++++--- .../WebBundle/Helper/ActionsHelper.php | 7 ++++--- .../WebBundle/Helper/RequestHelper.php | 7 ++++--- .../WebBundle/Helper/RouterHelper.php | 7 ++++--- .../Framework/WebBundle/Helper/UserHelper.php | 7 ++++--- .../WebBundle/Listener/ControllerLoader.php | 5 +++-- .../WebBundle/Listener/ExceptionHandler.php | 7 ++++--- .../WebBundle/Listener/RequestParser.php | 7 ++++--- .../WebBundle/Listener/ResponseFilter.php | 7 ++++--- .../WebBundle/Session/NativeSession.php | 7 ++++--- .../WebBundle/Session/PdoSession.php | 7 ++++--- .../WebBundle/Session/SessionInterface.php | 7 ++++--- .../WebBundle/Templating/Debugger.php | 7 ++++--- .../Framework/WebBundle/Templating/Engine.php | 7 ++++--- src/Symfony/Framework/WebBundle/User.php | 7 ++++--- .../Framework/WebBundle/Util/Filesystem.php | 7 ++++--- .../Framework/WebBundle/Util/Finder.php | 7 ++++--- src/Symfony/Framework/WebBundle/Util/Glob.php | 9 ++++---- .../Framework/WebBundle/Util/Mustache.php | 9 +++++++- .../WebBundle/Util/NumberCompare.php | 10 ++++----- src/Symfony/Framework/ZendBundle/Bundle.php | 7 ++++--- .../DependencyInjection/ZendExtension.php | 6 +++--- .../ZendBundle/Logger/DebugLogger.php | 7 ++++--- .../Framework/ZendBundle/Logger/Logger.php | 7 ++++--- 219 files changed, 818 insertions(+), 652 deletions(-) diff --git a/src/Symfony/Components/Console/Application.php b/src/Symfony/Components/Console/Application.php index e9e4a469ea50a..0c93c814d8f23 100644 --- a/src/Symfony/Components/Console/Application.php +++ b/src/Symfony/Components/Console/Application.php @@ -19,7 +19,7 @@ use Symfony\Components\Console\Helper\DialogHelper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -40,8 +40,8 @@ * $app->addCommand(new SimpleCommand()); * $app->run(); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class Application diff --git a/src/Symfony/Components/Console/Command/Command.php b/src/Symfony/Components/Console/Command/Command.php index 6813f31791149..25b2a0091df81 100644 --- a/src/Symfony/Components/Console/Command/Command.php +++ b/src/Symfony/Components/Console/Command/Command.php @@ -10,7 +10,7 @@ use Symfony\Components\Console\Application; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ /** * Base class for all commands. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class Command diff --git a/src/Symfony/Components/Console/Command/HelpCommand.php b/src/Symfony/Components/Console/Command/HelpCommand.php index 8258c5c182905..537de5a84eae0 100644 --- a/src/Symfony/Components/Console/Command/HelpCommand.php +++ b/src/Symfony/Components/Console/Command/HelpCommand.php @@ -10,7 +10,7 @@ use Symfony\Components\Console\Command\Command; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ /** * HelpCommand displays the help for a given command. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class HelpCommand extends Command diff --git a/src/Symfony/Components/Console/Command/ListCommand.php b/src/Symfony/Components/Console/Command/ListCommand.php index 3fddbc224c5a9..6e05b5f04f276 100644 --- a/src/Symfony/Components/Console/Command/ListCommand.php +++ b/src/Symfony/Components/Console/Command/ListCommand.php @@ -10,7 +10,7 @@ use Symfony\Components\Console\Command\Command; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ /** * ListCommand displays the list of all available commands for the application. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class ListCommand extends Command diff --git a/src/Symfony/Components/Console/Helper/DialogHelper.php b/src/Symfony/Components/Console/Helper/DialogHelper.php index 154143a1a6c74..31c3d820f61a8 100644 --- a/src/Symfony/Components/Console/Helper/DialogHelper.php +++ b/src/Symfony/Components/Console/Helper/DialogHelper.php @@ -5,7 +5,7 @@ use Symfony\Components\Console\Output\OutputInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * The Dialog class provides helpers to interact with the user. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class DialogHelper extends Helper diff --git a/src/Symfony/Components/Console/Helper/FormatterHelper.php b/src/Symfony/Components/Console/Helper/FormatterHelper.php index 6eedca733a935..2d1c5fb52c5f2 100644 --- a/src/Symfony/Components/Console/Helper/FormatterHelper.php +++ b/src/Symfony/Components/Console/Helper/FormatterHelper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Helper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * The Formatter class provides helpers to format messages. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class FormatterHelper extends Helper diff --git a/src/Symfony/Components/Console/Helper/Helper.php b/src/Symfony/Components/Console/Helper/Helper.php index f083b47abe952..0a99683f72b9e 100644 --- a/src/Symfony/Components/Console/Helper/Helper.php +++ b/src/Symfony/Components/Console/Helper/Helper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Helper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Helper is the base class for all helper classes. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ abstract class Helper implements HelperInterface diff --git a/src/Symfony/Components/Console/Helper/HelperInterface.php b/src/Symfony/Components/Console/Helper/HelperInterface.php index f3de9aa65ea04..3d220bfea26cc 100644 --- a/src/Symfony/Components/Console/Helper/HelperInterface.php +++ b/src/Symfony/Components/Console/Helper/HelperInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Helper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * HelperInterface is the interface all helpers must implement. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ interface HelperInterface diff --git a/src/Symfony/Components/Console/Helper/HelperSet.php b/src/Symfony/Components/Console/Helper/HelperSet.php index 67d764f52e343..d6b5ca4bcbd40 100644 --- a/src/Symfony/Components/Console/Helper/HelperSet.php +++ b/src/Symfony/Components/Console/Helper/HelperSet.php @@ -5,7 +5,7 @@ use Symfony\Components\Console\Command\Command; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * HelperSet represents a set of helpers to be used with a command. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class HelperSet diff --git a/src/Symfony/Components/Console/Input/ArgvInput.php b/src/Symfony/Components/Console/Input/ArgvInput.php index ec3820c387cb9..0d19942240fb8 100644 --- a/src/Symfony/Components/Console/Input/ArgvInput.php +++ b/src/Symfony/Components/Console/Input/ArgvInput.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,7 +20,7 @@ * * By default, the `$_SERVER['argv']` array is used for the input values. * - * This can be overriden by explicitly passing the input values in the constructor: + * This can be overridden by explicitly passing the input values in the constructor: * * $input = new ArgvInput($_SERVER['argv']); * @@ -31,8 +31,8 @@ * the same rules as the argv one. It's almost always better to use the * `StringInput` when you want to provide your own input. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier * * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html @@ -46,7 +46,7 @@ class ArgvInput extends Input /** * Constructor. * - * @param array $argv An array of parameters from the CLI (in the argv format) + * @param array $argv An array of parameters from the CLI (in the argv format) * @param InputDefinition $definition A InputDefinition instance */ public function __construct(array $argv = null, InputDefinition $definition = null) diff --git a/src/Symfony/Components/Console/Input/ArrayInput.php b/src/Symfony/Components/Console/Input/ArrayInput.php index 4f4e624b10bfc..71cdefc36fe28 100644 --- a/src/Symfony/Components/Console/Input/ArrayInput.php +++ b/src/Symfony/Components/Console/Input/ArrayInput.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ * * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar')); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class ArrayInput extends Input @@ -29,7 +29,7 @@ class ArrayInput extends Input /** * Constructor. * - * @param array $param An array of parameters + * @param array $param An array of parameters * @param InputDefinition $definition A InputDefinition instance */ public function __construct(array $parameters, InputDefinition $definition = null) diff --git a/src/Symfony/Components/Console/Input/Input.php b/src/Symfony/Components/Console/Input/Input.php index 9b5423bc705c3..a5a4f1ec07ac5 100644 --- a/src/Symfony/Components/Console/Input/Input.php +++ b/src/Symfony/Components/Console/Input/Input.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * * `StringInput`: The input is provided as a string * * `ArrayInput`: The input is provided as an array * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ abstract class Input implements InputInterface diff --git a/src/Symfony/Components/Console/Input/InputArgument.php b/src/Symfony/Components/Console/Input/InputArgument.php index 43bbacf9cd7d9..aada8b6281798 100644 --- a/src/Symfony/Components/Console/Input/InputArgument.php +++ b/src/Symfony/Components/Console/Input/InputArgument.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Represents a command line argument. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class InputArgument diff --git a/src/Symfony/Components/Console/Input/InputDefinition.php b/src/Symfony/Components/Console/Input/InputDefinition.php index 1903d04fed090..3c3a69123f713 100644 --- a/src/Symfony/Components/Console/Input/InputDefinition.php +++ b/src/Symfony/Components/Console/Input/InputDefinition.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ * new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED), * )); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class InputDefinition diff --git a/src/Symfony/Components/Console/Input/InputInterface.php b/src/Symfony/Components/Console/Input/InputInterface.php index 953553e7805aa..8367c9123b6f9 100644 --- a/src/Symfony/Components/Console/Input/InputInterface.php +++ b/src/Symfony/Components/Console/Input/InputInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * InputInterface is the interface implemented by all input classes. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ interface InputInterface diff --git a/src/Symfony/Components/Console/Input/InputOption.php b/src/Symfony/Components/Console/Input/InputOption.php index 2937c5810af95..a547968d331c3 100644 --- a/src/Symfony/Components/Console/Input/InputOption.php +++ b/src/Symfony/Components/Console/Input/InputOption.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Represents a command line option. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class InputOption diff --git a/src/Symfony/Components/Console/Input/StringInput.php b/src/Symfony/Components/Console/Input/StringInput.php index c250c687a9345..6b3668dedfa0b 100644 --- a/src/Symfony/Components/Console/Input/StringInput.php +++ b/src/Symfony/Components/Console/Input/StringInput.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Input; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ * * $input = new StringInput('foo --bar="foobar"'); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class StringInput extends ArgvInput diff --git a/src/Symfony/Components/Console/Output/ConsoleOutput.php b/src/Symfony/Components/Console/Output/ConsoleOutput.php index 7950c25ec02df..94c132daa9d7a 100644 --- a/src/Symfony/Components/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Components/Console/Output/ConsoleOutput.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Output; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -22,8 +22,8 @@ * * $output = new StreamOutput(fopen('php://stdout', 'w')); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class ConsoleOutput extends StreamOutput diff --git a/src/Symfony/Components/Console/Output/NullOutput.php b/src/Symfony/Components/Console/Output/NullOutput.php index 86e2c326f8e01..5ef678a24bcf1 100644 --- a/src/Symfony/Components/Console/Output/NullOutput.php +++ b/src/Symfony/Components/Console/Output/NullOutput.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Output; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ * * $output = new NullOutput(); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class NullOutput extends Output diff --git a/src/Symfony/Components/Console/Output/Output.php b/src/Symfony/Components/Console/Output/Output.php index ef251393bb871..20a39f1c75892 100644 --- a/src/Symfony/Components/Console/Output/Output.php +++ b/src/Symfony/Components/Console/Output/Output.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Output; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * * verbose: -v (more output - debug) * * quiet: -q (no output) * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ abstract class Output implements OutputInterface diff --git a/src/Symfony/Components/Console/Output/OutputInterface.php b/src/Symfony/Components/Console/Output/OutputInterface.php index 26bc6b76ef72b..6e93b78d5c6d3 100644 --- a/src/Symfony/Components/Console/Output/OutputInterface.php +++ b/src/Symfony/Components/Console/Output/OutputInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Output; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * OutputInterface is the interface implemented by all Output classes. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ interface OutputInterface diff --git a/src/Symfony/Components/Console/Output/StreamOutput.php b/src/Symfony/Components/Console/Output/StreamOutput.php index 3023012d7a208..dfff19107366d 100644 --- a/src/Symfony/Components/Console/Output/StreamOutput.php +++ b/src/Symfony/Components/Console/Output/StreamOutput.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Console\Output; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -22,8 +22,8 @@ * * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class StreamOutput extends Output diff --git a/src/Symfony/Components/Console/Shell.php b/src/Symfony/Components/Console/Shell.php index 6e4a08ac88416..d62d8db97eeb6 100644 --- a/src/Symfony/Components/Console/Shell.php +++ b/src/Symfony/Components/Console/Shell.php @@ -7,7 +7,7 @@ use Symfony\Components\Console\Output\ConsoleOutput; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ * This class only works with a PHP compiled with readline support * (either --with-readline or --with-libedit) * - * @package symfony - * @subpackage cli + * @package Symfony + * @subpackage Components_Console * @author Fabien Potencier */ class Shell diff --git a/src/Symfony/Components/Console/Tester/ApplicationTester.php b/src/Symfony/Components/Console/Tester/ApplicationTester.php index aa31f71cb4c8c..dc8501856f427 100644 --- a/src/Symfony/Components/Console/Tester/ApplicationTester.php +++ b/src/Symfony/Components/Console/Tester/ApplicationTester.php @@ -6,6 +6,20 @@ use Symfony\Components\Console\Input\ArrayInput; use Symfony\Components\Console\Output\StreamOutput; +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * @package Symfony + * @subpackage Components_Console + * @author Fabien Potencier + */ class ApplicationTester { protected $application; diff --git a/src/Symfony/Components/Console/Tester/CommandTester.php b/src/Symfony/Components/Console/Tester/CommandTester.php index bc0ee8879ed3c..d7a8b813d1b68 100644 --- a/src/Symfony/Components/Console/Tester/CommandTester.php +++ b/src/Symfony/Components/Console/Tester/CommandTester.php @@ -6,6 +6,20 @@ use Symfony\Components\Console\Input\ArrayInput; use Symfony\Components\Console\Output\StreamOutput; +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * @package Symfony + * @subpackage Components_Console + * @author Fabien Potencier + */ class CommandTester { protected $command; diff --git a/src/Symfony/Components/CssSelector/Node/AttribNode.php b/src/Symfony/Components/CssSelector/Node/AttribNode.php index fe7300045c276..5b7a8a1b80051 100644 --- a/src/Symfony/Components/CssSelector/Node/AttribNode.php +++ b/src/Symfony/Components/CssSelector/Node/AttribNode.php @@ -6,7 +6,7 @@ use Symfony\Components\CssSelector\SyntaxError; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class AttribNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/ClassNode.php b/src/Symfony/Components/CssSelector/Node/ClassNode.php index 6b001739470af..729ee1f223800 100644 --- a/src/Symfony/Components/CssSelector/Node/ClassNode.php +++ b/src/Symfony/Components/CssSelector/Node/ClassNode.php @@ -5,7 +5,7 @@ use Symfony\Components\CssSelector\XPathExpr; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class ClassNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php index eec316e36625b..0a5914d52fcba 100644 --- a/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php +++ b/src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php @@ -5,7 +5,7 @@ use Symfony\Components\CssSelector\SyntaxError; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class CombinedSelectorNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/ElementNode.php b/src/Symfony/Components/CssSelector/Node/ElementNode.php index 9425de55a1450..ad76ffbac83d9 100644 --- a/src/Symfony/Components/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Components/CssSelector/Node/ElementNode.php @@ -5,7 +5,7 @@ use Symfony\Components\CssSelector\XPathExpr; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class ElementNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/FunctionNode.php b/src/Symfony/Components/CssSelector/Node/FunctionNode.php index 87ae77db8d203..ceb78e28ed5e9 100644 --- a/src/Symfony/Components/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Components/CssSelector/Node/FunctionNode.php @@ -6,7 +6,7 @@ use Symfony\Components\CssSelector\XPathExpr; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class FunctionNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/HashNode.php b/src/Symfony/Components/CssSelector/Node/HashNode.php index 7a7ae13b9ce6c..207cb2f5c0553 100644 --- a/src/Symfony/Components/CssSelector/Node/HashNode.php +++ b/src/Symfony/Components/CssSelector/Node/HashNode.php @@ -5,7 +5,7 @@ use Symfony\Components\CssSelector\XPathExpr; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class HashNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/NodeInterface.php b/src/Symfony/Components/CssSelector/Node/NodeInterface.php index aadcb7b320f33..9f818cd274a72 100644 --- a/src/Symfony/Components/CssSelector/Node/NodeInterface.php +++ b/src/Symfony/Components/CssSelector/Node/NodeInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector\Node; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ interface NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/OrNode.php b/src/Symfony/Components/CssSelector/Node/OrNode.php index b64142a02d685..fb4026e6ea326 100644 --- a/src/Symfony/Components/CssSelector/Node/OrNode.php +++ b/src/Symfony/Components/CssSelector/Node/OrNode.php @@ -5,7 +5,7 @@ use Symfony\Components\CssSelector\XPathExprOr; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class OrNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Node/PseudoNode.php b/src/Symfony/Components/CssSelector/Node/PseudoNode.php index 99867657b334c..9b6ed800e4023 100644 --- a/src/Symfony/Components/CssSelector/Node/PseudoNode.php +++ b/src/Symfony/Components/CssSelector/Node/PseudoNode.php @@ -5,7 +5,7 @@ use Symfony\Components\CssSelector\SyntaxError; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class PseudoNode implements NodeInterface diff --git a/src/Symfony/Components/CssSelector/Parser.php b/src/Symfony/Components/CssSelector/Parser.php index 6812005c5f444..933a1f68c58d7 100644 --- a/src/Symfony/Components/CssSelector/Parser.php +++ b/src/Symfony/Components/CssSelector/Parser.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class Parser diff --git a/src/Symfony/Components/CssSelector/SyntaxError.php b/src/Symfony/Components/CssSelector/SyntaxError.php index 47a3d9334ba88..3be18b519936b 100644 --- a/src/Symfony/Components/CssSelector/SyntaxError.php +++ b/src/Symfony/Components/CssSelector/SyntaxError.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class SyntaxError extends \LogicException diff --git a/src/Symfony/Components/CssSelector/Token.php b/src/Symfony/Components/CssSelector/Token.php index 8102816970b2b..c4489b9e2e7ca 100644 --- a/src/Symfony/Components/CssSelector/Token.php +++ b/src/Symfony/Components/CssSelector/Token.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class Token diff --git a/src/Symfony/Components/CssSelector/TokenStream.php b/src/Symfony/Components/CssSelector/TokenStream.php index e1774dd96e88a..7f6402e74a8bf 100644 --- a/src/Symfony/Components/CssSelector/TokenStream.php +++ b/src/Symfony/Components/CssSelector/TokenStream.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class TokenStream diff --git a/src/Symfony/Components/CssSelector/Tokenizer.php b/src/Symfony/Components/CssSelector/Tokenizer.php index c83b41cfbd241..15acf8a56e273 100644 --- a/src/Symfony/Components/CssSelector/Tokenizer.php +++ b/src/Symfony/Components/CssSelector/Tokenizer.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class Tokenizer diff --git a/src/Symfony/Components/CssSelector/XPathExpr.php b/src/Symfony/Components/CssSelector/XPathExpr.php index a8baedee22fcb..c358289d07cf3 100644 --- a/src/Symfony/Components/CssSelector/XPathExpr.php +++ b/src/Symfony/Components/CssSelector/XPathExpr.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class XPathExpr diff --git a/src/Symfony/Components/CssSelector/XPathExprOr.php b/src/Symfony/Components/CssSelector/XPathExprOr.php index 28cf88e8ef38a..04804dee42d15 100644 --- a/src/Symfony/Components/CssSelector/XPathExprOr.php +++ b/src/Symfony/Components/CssSelector/XPathExprOr.php @@ -3,7 +3,7 @@ namespace Symfony\Components\CssSelector; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * This component is a port of the Python lxml library, * which is copyright Infrae and distributed under the BSD license. * - * @package symfony - * @subpackage css_selector + * @package Symfony + * @subpackage Components_CssSelector * @author Fabien Potencier */ class XPathExprOr extends XPathExpr diff --git a/src/Symfony/Components/DependencyInjection/AnnotatedContainerInterface.php b/src/Symfony/Components/DependencyInjection/AnnotatedContainerInterface.php index 4946123e7efad..147300b820d07 100644 --- a/src/Symfony/Components/DependencyInjection/AnnotatedContainerInterface.php +++ b/src/Symfony/Components/DependencyInjection/AnnotatedContainerInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * AnnotatedContainerInterface is the interface implemented when a container knows how to deals with annotations. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ interface AnnotatedContainerInterface diff --git a/src/Symfony/Components/DependencyInjection/Builder.php b/src/Symfony/Components/DependencyInjection/Builder.php index 5eddaeea0ebe2..5027552697788 100644 --- a/src/Symfony/Components/DependencyInjection/Builder.php +++ b/src/Symfony/Components/DependencyInjection/Builder.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Builder is a DI container that provides an interface to build the services. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class Builder extends Container implements AnnotatedContainerInterface diff --git a/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php b/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php index 7da14fb9bf247..6b11a989c01cf 100644 --- a/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php +++ b/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\Loader\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * A BuilderConfiguration is a consistent set of definitions and parameters. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class BuilderConfiguration diff --git a/src/Symfony/Components/DependencyInjection/Container.php b/src/Symfony/Components/DependencyInjection/Container.php index 7840ba04cb506..e403657353398 100644 --- a/src/Symfony/Components/DependencyInjection/Container.php +++ b/src/Symfony/Components/DependencyInjection/Container.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -46,8 +46,8 @@ * * IGNORE_ON_INVALID_REFERENCE: Ignores the wrapping command asking for the reference * (for instance, ignore a setter if the service does not exist) * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class Container implements ContainerInterface, \ArrayAccess diff --git a/src/Symfony/Components/DependencyInjection/ContainerInterface.php b/src/Symfony/Components/DependencyInjection/ContainerInterface.php index 5fce378cf8845..149a0cacf4de5 100644 --- a/src/Symfony/Components/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Components/DependencyInjection/ContainerInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * ContainerInterface is the interface implemented by service container classes. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ interface ContainerInterface diff --git a/src/Symfony/Components/DependencyInjection/Definition.php b/src/Symfony/Components/DependencyInjection/Definition.php index f624203478918..6f2911dda8208 100644 --- a/src/Symfony/Components/DependencyInjection/Definition.php +++ b/src/Symfony/Components/DependencyInjection/Definition.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Definition represents a service definition. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class Definition diff --git a/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php b/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php index d32af853979fb..65212d51f5a66 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/Dumper.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\Builder; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * Dumper is the abstract class for all built-in dumpers. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ abstract class Dumper implements DumperInterface diff --git a/src/Symfony/Components/DependencyInjection/Dumper/DumperInterface.php b/src/Symfony/Components/DependencyInjection/Dumper/DumperInterface.php index 964a6052425de..f1ac040e64e23 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/DumperInterface.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/DumperInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection\Dumper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * DumperInterface is the interface implemented by service container dumper classes. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ interface DumperInterface diff --git a/src/Symfony/Components/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/GraphvizDumper.php index 37db58750e3de..1edea7f04de54 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/GraphvizDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/GraphvizDumper.php @@ -8,7 +8,7 @@ use Symfony\Components\DependencyInjection\Builder; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ * * dot -Tpng container.dot > foo.png * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class GraphvizDumper extends Dumper diff --git a/src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php index 5202c5f261c94..14c80e942d02c 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php @@ -8,7 +8,7 @@ use Symfony\Components\DependencyInjection\Parameter; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ /** * PhpDumper dumps a service container as a PHP class. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class PhpDumper extends Dumper diff --git a/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php index 74db69c7c96d4..0c0e975b647a3 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php @@ -7,7 +7,7 @@ use Symfony\Components\DependencyInjection\Reference; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ /** * XmlDumper dumps a service container as an XML string. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class XmlDumper extends Dumper diff --git a/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php index c614dad630f37..136784ad54dff 100644 --- a/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php @@ -8,7 +8,7 @@ use Symfony\Components\DependencyInjection\Reference; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ /** * YamlDumper dumps a service container as a YAML string. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class YamlDumper extends Dumper diff --git a/src/Symfony/Components/DependencyInjection/FileResource.php b/src/Symfony/Components/DependencyInjection/FileResource.php index 24e1e0d5ffe14..bf1c578787c2b 100644 --- a/src/Symfony/Components/DependencyInjection/FileResource.php +++ b/src/Symfony/Components/DependencyInjection/FileResource.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * FileResource represents a resource stored on the filesystem. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class FileResource implements ResourceInterface diff --git a/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php index 25e52f8e4488d..60b66d10f5d60 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/FileLoader.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * FileLoader is the abstract class used by all built-in loaders that are file based. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ abstract class FileLoader extends Loader diff --git a/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php index 35878fd0a4215..1c69fdce10a10 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php @@ -6,7 +6,7 @@ use Symfony\Components\DependencyInjection\FileResource; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * IniFileLoader loads parameters from INI files. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class IniFileLoader extends FileLoader diff --git a/src/Symfony/Components/DependencyInjection/Loader/Loader.php b/src/Symfony/Components/DependencyInjection/Loader/Loader.php index aff4c24efccc9..97f30719c6ef7 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/Loader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/Loader.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Loader is the abstract class used by all built-in loaders. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ abstract class Loader implements LoaderInterface diff --git a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php index 2edc2c0994baa..1a2b1ce94ccb2 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php +++ b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * LoaderExtension is a helper class that helps organize extensions better. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ abstract class LoaderExtension implements LoaderExtensionInterface diff --git a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php index aee78181a559b..98b62c13243ca 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php +++ b/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * LoaderExtensionInterface is the interface implemented by loader extension classes. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ interface LoaderExtensionInterface diff --git a/src/Symfony/Components/DependencyInjection/Loader/LoaderInterface.php b/src/Symfony/Components/DependencyInjection/Loader/LoaderInterface.php index e55e7a6d6b536..85dce17915dbb 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/LoaderInterface.php +++ b/src/Symfony/Components/DependencyInjection/Loader/LoaderInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * $container = new Builder(); * $container->merge($config); * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ interface LoaderInterface diff --git a/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php index 5bb3feee9b69f..69fef75f8c4c6 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php @@ -9,7 +9,7 @@ use Symfony\Components\DependencyInjection\FileResource; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ /** * XmlFileLoader loads XML files service definitions. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class XmlFileLoader extends FileLoader diff --git a/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php index c1d893850d0a2..3c3cf80cfd3c7 100644 --- a/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php @@ -10,7 +10,7 @@ use Symfony\Components\Yaml\Yaml; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ * * The YAML format does not support anonymous services (cf. the XML loader). * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class YamlFileLoader extends FileLoader diff --git a/src/Symfony/Components/DependencyInjection/Parameter.php b/src/Symfony/Components/DependencyInjection/Parameter.php index 1e33454c9a278..0556d3800390d 100644 --- a/src/Symfony/Components/DependencyInjection/Parameter.php +++ b/src/Symfony/Components/DependencyInjection/Parameter.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Parameter represents a parameter reference. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class Parameter diff --git a/src/Symfony/Components/DependencyInjection/Reference.php b/src/Symfony/Components/DependencyInjection/Reference.php index 099c91ebb4319..414c6389670c6 100644 --- a/src/Symfony/Components/DependencyInjection/Reference.php +++ b/src/Symfony/Components/DependencyInjection/Reference.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Reference represents a service reference. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ class Reference diff --git a/src/Symfony/Components/DependencyInjection/ResourceInterface.php b/src/Symfony/Components/DependencyInjection/ResourceInterface.php index fc940164d8739..64f359b6b2165 100644 --- a/src/Symfony/Components/DependencyInjection/ResourceInterface.php +++ b/src/Symfony/Components/DependencyInjection/ResourceInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * ResourceInterface is the interface that must be implemented by all Resource classes. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Components_DependencyInjection * @author Fabien Potencier */ interface ResourceInterface diff --git a/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php b/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php index 41700111e4bf4..66d02a12c411b 100644 --- a/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php +++ b/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php @@ -3,7 +3,7 @@ namespace Symfony\Components\DependencyInjection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -11,6 +11,13 @@ * with this source code in the file LICENSE. */ +/** + * SimpleXMLElement class. + * + * @package Symfony + * @subpackage Components_DependencyInjection + * @author Fabien Potencier + */ class SimpleXMLElement extends \SimpleXMLElement { public function getAttributeAsPhp($name) diff --git a/src/Symfony/Components/EventDispatcher/Event.php b/src/Symfony/Components/EventDispatcher/Event.php index f9d5070223f38..1e3e909fc0aa5 100644 --- a/src/Symfony/Components/EventDispatcher/Event.php +++ b/src/Symfony/Components/EventDispatcher/Event.php @@ -3,7 +3,7 @@ namespace Symfony\Components\EventDispatcher; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -13,8 +13,8 @@ /** * Event. * - * @package symfony - * @subpackage event_dispatcher + * @package Symfony + * @subpackage Components_EventDispatcher * @author Fabien Potencier */ class Event implements \ArrayAccess diff --git a/src/Symfony/Components/EventDispatcher/EventDispatcher.php b/src/Symfony/Components/EventDispatcher/EventDispatcher.php index 604516c87ec6a..89083934f3e6e 100644 --- a/src/Symfony/Components/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Components/EventDispatcher/EventDispatcher.php @@ -3,7 +3,7 @@ namespace Symfony\Components\EventDispatcher; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -15,8 +15,8 @@ * * @see http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/index.html Apple's Cocoa framework * - * @package symfony - * @subpackage event_dispatcher + * @package Symfony + * @subpackage Components_EventDispatcher * @author Fabien Potencier */ class EventDispatcher diff --git a/src/Symfony/Components/OutputEscaper/ArrayDecorator.php b/src/Symfony/Components/OutputEscaper/ArrayDecorator.php index 505aef85191e1..ecf5f2a452c32 100644 --- a/src/Symfony/Components/OutputEscaper/ArrayDecorator.php +++ b/src/Symfony/Components/OutputEscaper/ArrayDecorator.php @@ -3,7 +3,7 @@ namespace Symfony\Components\OutputEscaper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -15,8 +15,8 @@ * Output escaping decorator class for arrays. * * @see Escaper - * @package symfony - * @subpackage output_escaper + * @package Symfony + * @subpackage Components_OutputEscaper * @author Fabien Potencier * @author Mike Squire */ diff --git a/src/Symfony/Components/OutputEscaper/Escaper.php b/src/Symfony/Components/OutputEscaper/Escaper.php index 2d3011081b044..3cec532cfd973 100644 --- a/src/Symfony/Components/OutputEscaper/Escaper.php +++ b/src/Symfony/Components/OutputEscaper/Escaper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\OutputEscaper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Abstract class that provides an interface for escaping of output. * - * @package symfony - * @subpackage output_escaper + * @package Symfony + * @subpackage Components_OutputEscaper * @author Fabien Potencier * @author Mike Squire */ diff --git a/src/Symfony/Components/OutputEscaper/GetterDecorator.php b/src/Symfony/Components/OutputEscaper/GetterDecorator.php index 1cfc175fff1fe..48f48ece66d9e 100644 --- a/src/Symfony/Components/OutputEscaper/GetterDecorator.php +++ b/src/Symfony/Components/OutputEscaper/GetterDecorator.php @@ -3,7 +3,7 @@ namespace Symfony\Components\OutputEscaper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -15,8 +15,8 @@ * Abstract output escaping decorator class for "getter" objects. * * @see Escaper - * @package symfony - * @subpackage output_escaper + * @package Symfony + * @subpackage Components_OutputEscaper * @author Fabien Potencier * @author Mike Squire */ @@ -25,7 +25,7 @@ abstract class GetterDecorator extends Escaper /** * Returns the raw, unescaped value associated with the key supplied. * - * The key might be an index into an array or a value to be passed to the + * The key might be an index into an array or a value to be passed to the * decorated object's get() method. * * @param string $key The key to retrieve diff --git a/src/Symfony/Components/OutputEscaper/IteratorDecorator.php b/src/Symfony/Components/OutputEscaper/IteratorDecorator.php index ca00795b4555c..d367e69631f55 100644 --- a/src/Symfony/Components/OutputEscaper/IteratorDecorator.php +++ b/src/Symfony/Components/OutputEscaper/IteratorDecorator.php @@ -3,7 +3,7 @@ namespace Symfony\Components\OutputEscaper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ * into an iterator with each value escaped. * * @see Escaper - * @package symfony - * @subpackage output_escaper + * @package Symfony + * @subpackage Components_OutputEscaper * @author Fabien Potencier * @author Mike Squire */ diff --git a/src/Symfony/Components/OutputEscaper/ObjectDecorator.php b/src/Symfony/Components/OutputEscaper/ObjectDecorator.php index 77e49369b82e6..0dd1d96754a0a 100644 --- a/src/Symfony/Components/OutputEscaper/ObjectDecorator.php +++ b/src/Symfony/Components/OutputEscaper/ObjectDecorator.php @@ -3,7 +3,7 @@ namespace Symfony\Components\OutputEscaper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ * their return values. * * @see Escaper - * @package symfony - * @subpackage output_escaper + * @package Symfony + * @subpackage Components_OutputEscaper * @author Fabien Potencier * @author Mike Squire */ diff --git a/src/Symfony/Components/OutputEscaper/SafeDecorator.php b/src/Symfony/Components/OutputEscaper/SafeDecorator.php index 75ac82d6e2e27..f2525ba5820dd 100644 --- a/src/Symfony/Components/OutputEscaper/SafeDecorator.php +++ b/src/Symfony/Components/OutputEscaper/SafeDecorator.php @@ -3,7 +3,7 @@ namespace Symfony\Components\OutputEscaper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Marks a variable as being safe for output. * - * @package symfony - * @subpackage output_escaper + * @package Symfony + * @subpackage Components_OutputEscaper * @author Fabien Potencier */ class SafeDecorator extends \ArrayIterator diff --git a/src/Symfony/Components/RequestHandler/Exception/ForbiddenHttpException.php b/src/Symfony/Components/RequestHandler/Exception/ForbiddenHttpException.php index 96a1ff057a9d2..cabf2ccf72671 100644 --- a/src/Symfony/Components/RequestHandler/Exception/ForbiddenHttpException.php +++ b/src/Symfony/Components/RequestHandler/Exception/ForbiddenHttpException.php @@ -2,6 +2,22 @@ namespace Symfony\Components\RequestHandler\Exception; +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * ForbiddenHttpException. + * + * @package Symfony + * @subpackage Components_RequestHandler + * @author Fabien Potencier + */ class ForbiddenHttpException extends HttpException { public function __construct($message = '') diff --git a/src/Symfony/Components/RequestHandler/Exception/HttpException.php b/src/Symfony/Components/RequestHandler/Exception/HttpException.php index 077563e46420a..6622d295f12a8 100644 --- a/src/Symfony/Components/RequestHandler/Exception/HttpException.php +++ b/src/Symfony/Components/RequestHandler/Exception/HttpException.php @@ -2,7 +2,24 @@ namespace Symfony\Components\RequestHandler\Exception; -// by convention, exception code == response status code +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * HttpException. + * + * By convention, exception code == response status code. + * + * @package Symfony + * @subpackage Components_RequestHandler + * @author Fabien Potencier + */ class HttpException extends \Exception { } diff --git a/src/Symfony/Components/RequestHandler/Exception/NotFoundHttpException.php b/src/Symfony/Components/RequestHandler/Exception/NotFoundHttpException.php index 47f94bce1a406..1a917ec593cf4 100644 --- a/src/Symfony/Components/RequestHandler/Exception/NotFoundHttpException.php +++ b/src/Symfony/Components/RequestHandler/Exception/NotFoundHttpException.php @@ -2,6 +2,22 @@ namespace Symfony\Components\RequestHandler\Exception; +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * NotFoundHttpException. + * + * @package Symfony + * @subpackage Components_RequestHandler + * @author Fabien Potencier + */ class NotFoundHttpException extends HttpException { public function __construct($message = '') diff --git a/src/Symfony/Components/RequestHandler/Exception/UnauthorizedHttpException.php b/src/Symfony/Components/RequestHandler/Exception/UnauthorizedHttpException.php index c4b30efdbc8cf..1bca81d022e32 100644 --- a/src/Symfony/Components/RequestHandler/Exception/UnauthorizedHttpException.php +++ b/src/Symfony/Components/RequestHandler/Exception/UnauthorizedHttpException.php @@ -2,6 +2,22 @@ namespace Symfony\Components\RequestHandler\Exception; +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * UnauthorizedHttpException. + * + * @package Symfony + * @subpackage Components_RequestHandler + * @author Fabien Potencier + */ class UnauthorizedHttpException extends HttpException { public function __construct($message = '') diff --git a/src/Symfony/Components/RequestHandler/Request.php b/src/Symfony/Components/RequestHandler/Request.php index d473f9d84f5f5..d3b6fa0699205 100644 --- a/src/Symfony/Components/RequestHandler/Request.php +++ b/src/Symfony/Components/RequestHandler/Request.php @@ -3,7 +3,7 @@ namespace Symfony\Components\RequestHandler; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ * * You can reinitialize the request by calling the setParameters() method. * - * @package symfony - * @subpackage request_handler + * @package Symfony + * @subpackage Components_RequestHandler * @author Fabien Potencier */ class Request implements RequestInterface diff --git a/src/Symfony/Components/RequestHandler/RequestHandler.php b/src/Symfony/Components/RequestHandler/RequestHandler.php index 434af5bb24528..3f917bb8010ef 100644 --- a/src/Symfony/Components/RequestHandler/RequestHandler.php +++ b/src/Symfony/Components/RequestHandler/RequestHandler.php @@ -7,7 +7,7 @@ use Symfony\Components\RequestHandler\Exception\NotFoundHttpException; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ /** * RequestHandler notifies events to convert a Request object to a Response one. * - * @package symfony - * @subpackage request_handler + * @package Symfony + * @subpackage Components_RequestHandler * @author Fabien Potencier */ class RequestHandler diff --git a/src/Symfony/Components/RequestHandler/RequestInterface.php b/src/Symfony/Components/RequestHandler/RequestInterface.php index 0a1b69edbbd2f..6e445d2031fb2 100644 --- a/src/Symfony/Components/RequestHandler/RequestInterface.php +++ b/src/Symfony/Components/RequestHandler/RequestInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\RequestHandler; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * RequestInterface is the interface that all client request classes must implement. * - * @package symfony - * @subpackage request_handler + * @package Symfony + * @subpackage Components_RequestHandler * @author Fabien Potencier */ interface RequestInterface diff --git a/src/Symfony/Components/RequestHandler/Response.php b/src/Symfony/Components/RequestHandler/Response.php index ff6b9ef594a36..2e50f1938f3c1 100644 --- a/src/Symfony/Components/RequestHandler/Response.php +++ b/src/Symfony/Components/RequestHandler/Response.php @@ -3,7 +3,7 @@ namespace Symfony\Components\RequestHandler; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Response is the base implementation of a server response. * - * @package symfony - * @subpackage request_handler + * @package Symfony + * @subpackage Components_RequestHandler * @author Fabien Potencier */ class Response implements ResponseInterface diff --git a/src/Symfony/Components/RequestHandler/ResponseInterface.php b/src/Symfony/Components/RequestHandler/ResponseInterface.php index d0ffd64d8c247..0fa110dffc375 100644 --- a/src/Symfony/Components/RequestHandler/ResponseInterface.php +++ b/src/Symfony/Components/RequestHandler/ResponseInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\RequestHandler; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * ResponseInterface is the interface that all server response classes must implement. * - * @package symfony - * @subpackage request_handler + * @package Symfony + * @subpackage Components_RequestHandler * @author Fabien Potencier */ interface ResponseInterface diff --git a/src/Symfony/Components/Routing/CompiledRoute.php b/src/Symfony/Components/Routing/CompiledRoute.php index 1e2b287f19184..5884c16f4476b 100644 --- a/src/Symfony/Components/Routing/CompiledRoute.php +++ b/src/Symfony/Components/Routing/CompiledRoute.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * CompiledRoutes are returned by the RouteCompiler class. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class CompiledRoute diff --git a/src/Symfony/Components/Routing/FileResource.php b/src/Symfony/Components/Routing/FileResource.php index e01eb2f58175f..80523f2ffe145 100644 --- a/src/Symfony/Components/Routing/FileResource.php +++ b/src/Symfony/Components/Routing/FileResource.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * FileResource represents a resource stored on the filesystem. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class FileResource implements ResourceInterface diff --git a/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php b/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php index e6d5d65f795a9..c09f767bb20cb 100644 --- a/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php +++ b/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumper.php @@ -6,7 +6,7 @@ use Symfony\Components\Routing\Route; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * GeneratorDumper is the base class for all built-in generator dumpers. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ abstract class GeneratorDumper implements GeneratorDumperInterface diff --git a/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumperInterface.php b/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumperInterface.php index 3a6d1503cb014..3960fee4c41ef 100644 --- a/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumperInterface.php +++ b/src/Symfony/Components/Routing/Generator/Dumper/GeneratorDumperInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing\Generator\Dumper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * GeneratorDumperInterface is the interface that all generator dumper classes must implement. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface GeneratorDumperInterface diff --git a/src/Symfony/Components/Routing/Generator/Dumper/PhpGeneratorDumper.php b/src/Symfony/Components/Routing/Generator/Dumper/PhpGeneratorDumper.php index e901f2f0cc970..15a9a963d6e2e 100644 --- a/src/Symfony/Components/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/src/Symfony/Components/Routing/Generator/Dumper/PhpGeneratorDumper.php @@ -5,7 +5,7 @@ use Symfony\Components\Routing\Route; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class PhpGeneratorDumper extends GeneratorDumper diff --git a/src/Symfony/Components/Routing/Generator/UrlGenerator.php b/src/Symfony/Components/Routing/Generator/UrlGenerator.php index 75e154d7269d5..54169dc997191 100644 --- a/src/Symfony/Components/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Components/Routing/Generator/UrlGenerator.php @@ -6,7 +6,7 @@ use Symfony\Components\Routing\RouteCollection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * UrlGenerator generates URL based on a set of routes. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class UrlGenerator implements UrlGeneratorInterface diff --git a/src/Symfony/Components/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Components/Routing/Generator/UrlGeneratorInterface.php index 60b4a5c00e15c..a2af32ba8cbd5 100644 --- a/src/Symfony/Components/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Components/Routing/Generator/UrlGeneratorInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing\Generator; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * UrlGeneratorInterface is the interface that all URL generator classes must implements. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface UrlGeneratorInterface diff --git a/src/Symfony/Components/Routing/Loader/FileLoader.php b/src/Symfony/Components/Routing/Loader/FileLoader.php index 074754e3594a9..7384cb4d1eab8 100644 --- a/src/Symfony/Components/Routing/Loader/FileLoader.php +++ b/src/Symfony/Components/Routing/Loader/FileLoader.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * FileLoader is the abstract class used by all built-in loaders that are file based. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ abstract class FileLoader implements LoaderInterface diff --git a/src/Symfony/Components/Routing/Loader/LoaderInterface.php b/src/Symfony/Components/Routing/Loader/LoaderInterface.php index a9cc6575dd6cf..bd467fcddad60 100644 --- a/src/Symfony/Components/Routing/Loader/LoaderInterface.php +++ b/src/Symfony/Components/Routing/Loader/LoaderInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing\Loader; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * LoaderInterface is the interface that all loaders classes must implement. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface LoaderInterface diff --git a/src/Symfony/Components/Routing/Loader/XmlFileLoader.php b/src/Symfony/Components/Routing/Loader/XmlFileLoader.php index 17247f7b078b6..31c92ba692912 100644 --- a/src/Symfony/Components/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Components/Routing/Loader/XmlFileLoader.php @@ -7,7 +7,7 @@ use Symfony\Components\Routing\FileResource; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ /** * XmlFileLoader loads XML routing files. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class XmlFileLoader extends FileLoader diff --git a/src/Symfony/Components/Routing/Loader/YamlFileLoader.php b/src/Symfony/Components/Routing/Loader/YamlFileLoader.php index c97f7a1b59649..5f104799230fd 100644 --- a/src/Symfony/Components/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Components/Routing/Loader/YamlFileLoader.php @@ -8,7 +8,7 @@ use Symfony\Components\Yaml\Yaml; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ /** * YamlFileLoader loads Yaml routing files. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class YamlFileLoader extends FileLoader diff --git a/src/Symfony/Components/Routing/Matcher/ApacheUrlMatcher.php b/src/Symfony/Components/Routing/Matcher/ApacheUrlMatcher.php index cac89a3fd6f94..719b2d382f92b 100644 --- a/src/Symfony/Components/Routing/Matcher/ApacheUrlMatcher.php +++ b/src/Symfony/Components/Routing/Matcher/ApacheUrlMatcher.php @@ -6,7 +6,7 @@ use Symfony\Components\Routing\RouteCollection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper). * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class ApacheUrlMatcher extends UrlMatcher diff --git a/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php index ef0cc9bf1cf90..450d2352f8dff 100644 --- a/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ b/src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php @@ -5,7 +5,7 @@ use Symfony\Components\Routing\Route; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * ApacheMatcherDumper dumps a matcher in the Apache .htaccess format. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class ApacheMatcherDumper extends MatcherDumper diff --git a/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php b/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php index 12e72ac0f5df9..2e57e2964bb6a 100644 --- a/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php +++ b/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumper.php @@ -6,7 +6,7 @@ use Symfony\Components\Routing\Route; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * MatcherDumper is the abstract class for all built-in matcher dumpers. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ abstract class MatcherDumper implements MatcherDumperInterface diff --git a/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumperInterface.php b/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumperInterface.php index 8e8022af4173b..6d7cf5971017a 100644 --- a/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumperInterface.php +++ b/src/Symfony/Components/Routing/Matcher/Dumper/MatcherDumperInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing\Matcher\Dumper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * MatcherDumperInterface is the interface that all matcher dumper classes must implement. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface MatcherDumperInterface diff --git a/src/Symfony/Components/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Components/Routing/Matcher/Dumper/PhpMatcherDumper.php index dad60fea89077..682956304e769 100644 --- a/src/Symfony/Components/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Components/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -5,7 +5,7 @@ use Symfony\Components\Routing\Route; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class PhpMatcherDumper extends MatcherDumper diff --git a/src/Symfony/Components/Routing/Matcher/UrlMatcher.php b/src/Symfony/Components/Routing/Matcher/UrlMatcher.php index 27f6d07434174..ef1a31375ec46 100644 --- a/src/Symfony/Components/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Components/Routing/Matcher/UrlMatcher.php @@ -6,7 +6,7 @@ use Symfony\Components\Routing\RouteCollection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * UrlMatcher matches URL based on a set of routes. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class UrlMatcher implements UrlMatcherInterface diff --git a/src/Symfony/Components/Routing/Matcher/UrlMatcherInterface.php b/src/Symfony/Components/Routing/Matcher/UrlMatcherInterface.php index 4386e38d82a81..f4f4009e0dee3 100644 --- a/src/Symfony/Components/Routing/Matcher/UrlMatcherInterface.php +++ b/src/Symfony/Components/Routing/Matcher/UrlMatcherInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing\Matcher; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * UrlMatcherInterface is the interface that all URL matcher classes must implements. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface UrlMatcherInterface diff --git a/src/Symfony/Components/Routing/ResourceInterface.php b/src/Symfony/Components/Routing/ResourceInterface.php index 19f718e981952..c524b4e3bfc60 100644 --- a/src/Symfony/Components/Routing/ResourceInterface.php +++ b/src/Symfony/Components/Routing/ResourceInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * ResourceInterface is the interface that must be implemented by all Resource classes. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface ResourceInterface diff --git a/src/Symfony/Components/Routing/Route.php b/src/Symfony/Components/Routing/Route.php index 2d2c25d4bfda6..322688c702aa4 100644 --- a/src/Symfony/Components/Routing/Route.php +++ b/src/Symfony/Components/Routing/Route.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * A Route describes a route and its parameters. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class Route diff --git a/src/Symfony/Components/Routing/RouteCollection.php b/src/Symfony/Components/Routing/RouteCollection.php index 99a9f8c031cc6..339bc11ae9fde 100644 --- a/src/Symfony/Components/Routing/RouteCollection.php +++ b/src/Symfony/Components/Routing/RouteCollection.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * A RouteCollection represents a set of Route instances. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class RouteCollection diff --git a/src/Symfony/Components/Routing/RouteCompiler.php b/src/Symfony/Components/Routing/RouteCompiler.php index f89296bf0d047..5df61be52d055 100644 --- a/src/Symfony/Components/Routing/RouteCompiler.php +++ b/src/Symfony/Components/Routing/RouteCompiler.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * RouteCompiler compiles Route instances to CompiledRoute instances. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class RouteCompiler implements RouteCompilerInterface diff --git a/src/Symfony/Components/Routing/RouteCompilerInterface.php b/src/Symfony/Components/Routing/RouteCompilerInterface.php index 0cdc3f18447d5..446d23796d938 100644 --- a/src/Symfony/Components/Routing/RouteCompilerInterface.php +++ b/src/Symfony/Components/Routing/RouteCompilerInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * RouteCompilerInterface is the interface that all RouteCompiler classes must implements. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface RouteCompilerInterface diff --git a/src/Symfony/Components/Routing/Router.php b/src/Symfony/Components/Routing/Router.php index 8b760d9e57c67..98870e777e0b0 100644 --- a/src/Symfony/Components/Routing/Router.php +++ b/src/Symfony/Components/Routing/Router.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -15,8 +15,8 @@ * The Router class is an example of the integration of all pieces of the * routing system for easier use. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ class Router implements RouterInterface diff --git a/src/Symfony/Components/Routing/RouterInterface.php b/src/Symfony/Components/Routing/RouterInterface.php index 6267050d573f2..69c1c407619e9 100644 --- a/src/Symfony/Components/Routing/RouterInterface.php +++ b/src/Symfony/Components/Routing/RouterInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Routing; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ * * This interface is the concatenation of UrlMatcherInterface and UrlGeneratorInterface. * - * @package symfony - * @subpackage routing + * @package Symfony + * @subpackage Components_Routing * @author Fabien Potencier */ interface RouterInterface diff --git a/src/Symfony/Components/Templating/DebuggerInterface.php b/src/Symfony/Components/Templating/DebuggerInterface.php index 685718db2f003..59fcfa957f13e 100644 --- a/src/Symfony/Components/Templating/DebuggerInterface.php +++ b/src/Symfony/Components/Templating/DebuggerInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -15,8 +15,8 @@ * DebuggerInterface is the interface you need to implement * to debug template loader instances. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ interface DebuggerInterface diff --git a/src/Symfony/Components/Templating/Engine.php b/src/Symfony/Components/Templating/Engine.php index 0e33de9642325..39abfb42492d7 100644 --- a/src/Symfony/Components/Templating/Engine.php +++ b/src/Symfony/Components/Templating/Engine.php @@ -8,7 +8,7 @@ use Symfony\Components\Templating\Helper\HelperInterface; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,8 +19,8 @@ /** * Engine is the main class of the templating component. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class Engine diff --git a/src/Symfony/Components/Templating/Helper/AssetsHelper.php b/src/Symfony/Components/Templating/Helper/AssetsHelper.php index 834ea4b4969df..96e38f72c4685 100644 --- a/src/Symfony/Components/Templating/Helper/AssetsHelper.php +++ b/src/Symfony/Components/Templating/Helper/AssetsHelper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Helper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ * * * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class AssetsHelper extends Helper diff --git a/src/Symfony/Components/Templating/Helper/Helper.php b/src/Symfony/Components/Templating/Helper/Helper.php index c1d65bb32019e..c735c927dc08d 100644 --- a/src/Symfony/Components/Templating/Helper/Helper.php +++ b/src/Symfony/Components/Templating/Helper/Helper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Helper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Helper is the base class for all helper classes. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ abstract class Helper implements HelperInterface diff --git a/src/Symfony/Components/Templating/Helper/HelperInterface.php b/src/Symfony/Components/Templating/Helper/HelperInterface.php index a2570cad17c86..61704fc596aa7 100644 --- a/src/Symfony/Components/Templating/Helper/HelperInterface.php +++ b/src/Symfony/Components/Templating/Helper/HelperInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Helper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * HelperInterface is the interface all helpers must implement. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ interface HelperInterface diff --git a/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php b/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php index 8480b8e5cabeb..50c5e9ce459aa 100644 --- a/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php +++ b/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Helper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ * echo $this->javascripts; * * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class JavascriptsHelper extends Helper diff --git a/src/Symfony/Components/Templating/Helper/SlotsHelper.php b/src/Symfony/Components/Templating/Helper/SlotsHelper.php index 130bc0676d4d7..5a0450c0dd100 100644 --- a/src/Symfony/Components/Templating/Helper/SlotsHelper.php +++ b/src/Symfony/Components/Templating/Helper/SlotsHelper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Helper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * SlotsHelper manages template slots. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class SlotsHelper extends Helper diff --git a/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php b/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php index 94d4cf3c8c53c..b42bc8f139b8c 100644 --- a/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php +++ b/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Helper; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ * echo $this->stylesheets; * * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class StylesheetsHelper extends Helper diff --git a/src/Symfony/Components/Templating/Loader/CacheLoader.php b/src/Symfony/Components/Templating/Loader/CacheLoader.php index 1d25de0d7bdfc..ff63e3a7df0d1 100644 --- a/src/Symfony/Components/Templating/Loader/CacheLoader.php +++ b/src/Symfony/Components/Templating/Loader/CacheLoader.php @@ -6,7 +6,7 @@ use Symfony\Components\Templating\Storage\FileStorage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,10 +19,10 @@ * on the filesystem. * * This cache only caches on disk to allow PHP accelerators to cache the opcodes. - * All other mecanism would imply the use of `eval()`. + * All other mechanism would imply the use of `eval()`. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class CacheLoader extends Loader diff --git a/src/Symfony/Components/Templating/Loader/ChainLoader.php b/src/Symfony/Components/Templating/Loader/ChainLoader.php index 714919217f89a..7b26f5a46de5c 100644 --- a/src/Symfony/Components/Templating/Loader/ChainLoader.php +++ b/src/Symfony/Components/Templating/Loader/ChainLoader.php @@ -5,7 +5,7 @@ use Symfony\Components\Templating\Storage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * ChainLoader is a loader that calls other loaders to load templates. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class ChainLoader extends Loader diff --git a/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php b/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php index 242f562acc407..583f2d207c2e1 100644 --- a/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php +++ b/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Loader; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -15,8 +15,8 @@ * CompilableLoaderInterface is the interface a template loader must implement * if the templates are compilable. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ interface CompilableLoaderInterface diff --git a/src/Symfony/Components/Templating/Loader/FilesystemLoader.php b/src/Symfony/Components/Templating/Loader/FilesystemLoader.php index 120a558be7111..1a0e7fedacfd2 100644 --- a/src/Symfony/Components/Templating/Loader/FilesystemLoader.php +++ b/src/Symfony/Components/Templating/Loader/FilesystemLoader.php @@ -6,7 +6,7 @@ use Symfony\Components\Templating\Storage\FileStorage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * FilesystemLoader is a loader that read templates from the filesystem. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class FilesystemLoader extends Loader diff --git a/src/Symfony/Components/Templating/Loader/Loader.php b/src/Symfony/Components/Templating/Loader/Loader.php index 4df24149bed06..1ac5a77efc0eb 100644 --- a/src/Symfony/Components/Templating/Loader/Loader.php +++ b/src/Symfony/Components/Templating/Loader/Loader.php @@ -5,7 +5,7 @@ use Symfony\Components\Templating\DebuggerInterface; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * Loader is the base class for all template loader classes. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ abstract class Loader implements LoaderInterface diff --git a/src/Symfony/Components/Templating/Loader/LoaderInterface.php b/src/Symfony/Components/Templating/Loader/LoaderInterface.php index 9dda9a1ec235a..a664defb1d308 100644 --- a/src/Symfony/Components/Templating/Loader/LoaderInterface.php +++ b/src/Symfony/Components/Templating/Loader/LoaderInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Loader; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * LoaderInterface is the interface all loaders must implement. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ interface LoaderInterface diff --git a/src/Symfony/Components/Templating/Renderer/PhpRenderer.php b/src/Symfony/Components/Templating/Renderer/PhpRenderer.php index b83fd830b1545..14b8de5741da2 100644 --- a/src/Symfony/Components/Templating/Renderer/PhpRenderer.php +++ b/src/Symfony/Components/Templating/Renderer/PhpRenderer.php @@ -7,7 +7,7 @@ use Symfony\Components\Templating\Storage\StringStorage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ /** * PhpRenderer is a renderer for PHP templates. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class PhpRenderer extends Renderer diff --git a/src/Symfony/Components/Templating/Renderer/Renderer.php b/src/Symfony/Components/Templating/Renderer/Renderer.php index 65e815cbca16f..aedf69cee3655 100644 --- a/src/Symfony/Components/Templating/Renderer/Renderer.php +++ b/src/Symfony/Components/Templating/Renderer/Renderer.php @@ -5,7 +5,7 @@ use Symfony\Components\Templating\Engine; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -16,8 +16,8 @@ /** * Renderer is the base class for all template renderer. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ abstract class Renderer implements RendererInterface diff --git a/src/Symfony/Components/Templating/Renderer/RendererInterface.php b/src/Symfony/Components/Templating/Renderer/RendererInterface.php index a7ffd8c676245..e186175c0ae75 100644 --- a/src/Symfony/Components/Templating/Renderer/RendererInterface.php +++ b/src/Symfony/Components/Templating/Renderer/RendererInterface.php @@ -6,7 +6,7 @@ use Symfony\Components\Templating\Storage\Storage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,8 @@ /** * RendererInterface is the interface all renderer classes must implement. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ interface RendererInterface @@ -27,7 +27,7 @@ interface RendererInterface * Evaluates a template. * * @param Storage $template The template to render - * @param array $parameters An array of parameters to pass to the template + * @param array $parameters An array of parameters to pass to the template * * @return string|false The evaluated template, or false if the renderer is unable to render the template */ diff --git a/src/Symfony/Components/Templating/Storage/FileStorage.php b/src/Symfony/Components/Templating/Storage/FileStorage.php index 9cc74f74ce686..1ba70892cd75e 100644 --- a/src/Symfony/Components/Templating/Storage/FileStorage.php +++ b/src/Symfony/Components/Templating/Storage/FileStorage.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Storage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * FileStorage represents a template stored on the filesystem. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class FileStorage extends Storage diff --git a/src/Symfony/Components/Templating/Storage/Storage.php b/src/Symfony/Components/Templating/Storage/Storage.php index 157e0f15ec1f4..2760f418c0d5c 100644 --- a/src/Symfony/Components/Templating/Storage/Storage.php +++ b/src/Symfony/Components/Templating/Storage/Storage.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Storage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Storage is the base class for all storage classes. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ abstract class Storage diff --git a/src/Symfony/Components/Templating/Storage/StringStorage.php b/src/Symfony/Components/Templating/Storage/StringStorage.php index b14a003450c74..0e24b52f6255c 100644 --- a/src/Symfony/Components/Templating/Storage/StringStorage.php +++ b/src/Symfony/Components/Templating/Storage/StringStorage.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Templating\Storage; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * StringStorage represents a template stored in a string. * - * @package symfony - * @subpackage templating + * @package Symfony + * @subpackage Components_Templating * @author Fabien Potencier */ class StringStorage extends Storage diff --git a/src/Symfony/Components/Yaml/Dumper.php b/src/Symfony/Components/Yaml/Dumper.php index 2db3f6cf1e00d..98484365aaab9 100644 --- a/src/Symfony/Components/Yaml/Dumper.php +++ b/src/Symfony/Components/Yaml/Dumper.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Yaml; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -13,8 +13,8 @@ /** * Dumper dumps PHP variables to YAML strings. * - * @package symfony - * @subpackage yaml + * @package Symfony + * @subpackage Components_Yaml * @author Fabien Potencier */ class Dumper diff --git a/src/Symfony/Components/Yaml/Exception.php b/src/Symfony/Components/Yaml/Exception.php index 49cb7949ee6df..efcf8fc085c26 100644 --- a/src/Symfony/Components/Yaml/Exception.php +++ b/src/Symfony/Components/Yaml/Exception.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Yaml; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Exception class used by all exceptions thrown by the component. * - * @package symfony - * @subpackage yaml + * @package Symfony + * @subpackage Components_Yaml * @author Fabien Potencier */ class Exception extends \Exception diff --git a/src/Symfony/Components/Yaml/Inline.php b/src/Symfony/Components/Yaml/Inline.php index 7e3c630c891dd..8d4c730a8a7c1 100644 --- a/src/Symfony/Components/Yaml/Inline.php +++ b/src/Symfony/Components/Yaml/Inline.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Yaml; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -13,8 +13,8 @@ /** * Inline implements a YAML parser/dumper for the YAML inline syntax. * - * @package symfony - * @subpackage yaml + * @package Symfony + * @subpackage Components_Yaml * @author Fabien Potencier */ class Inline diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index a20896bcbe653..519cf8b9656b7 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Yaml; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -13,8 +13,8 @@ /** * Parser parses YAML strings to convert them to PHP arrays. * - * @package symfony - * @subpackage yaml + * @package Symfony + * @subpackage Components_Yaml * @author Fabien Potencier */ class Parser diff --git a/src/Symfony/Components/Yaml/ParserException.php b/src/Symfony/Components/Yaml/ParserException.php index 5ba22291de9e1..356c7f544b447 100644 --- a/src/Symfony/Components/Yaml/ParserException.php +++ b/src/Symfony/Components/Yaml/ParserException.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Yaml; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -14,8 +14,8 @@ /** * Exception class used by all exceptions thrown by the component. * - * @package symfony - * @subpackage yaml + * @package Symfony + * @subpackage Components_Yaml * @author Fabien Potencier */ class ParserException extends Exception diff --git a/src/Symfony/Components/Yaml/Yaml.php b/src/Symfony/Components/Yaml/Yaml.php index 7c744a578edac..dec8156d8c3d4 100644 --- a/src/Symfony/Components/Yaml/Yaml.php +++ b/src/Symfony/Components/Yaml/Yaml.php @@ -3,7 +3,7 @@ namespace Symfony\Components\Yaml; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * (c) 2004-2006 Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -13,8 +13,8 @@ /** * Yaml offers convenience methods to load and dump YAML. * - * @package symfony - * @subpackage yaml + * @package Symfony + * @subpackage Components_Yaml * @author Fabien Potencier */ class Yaml diff --git a/src/Symfony/Foundation/Bundle/Bundle.php b/src/Symfony/Foundation/Bundle/Bundle.php index 1956b0e74cea1..88d8d32958c05 100644 --- a/src/Symfony/Foundation/Bundle/Bundle.php +++ b/src/Symfony/Foundation/Bundle/Bundle.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * Bundle. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ abstract class Bundle implements BundleInterface diff --git a/src/Symfony/Foundation/Bundle/BundleInterface.php b/src/Symfony/Foundation/Bundle/BundleInterface.php index 0c536ea1a4a69..10acb5dc465fe 100644 --- a/src/Symfony/Foundation/Bundle/BundleInterface.php +++ b/src/Symfony/Foundation/Bundle/BundleInterface.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * BundleInterface. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ interface BundleInterface diff --git a/src/Symfony/Foundation/Bundle/KernelBundle.php b/src/Symfony/Foundation/Bundle/KernelBundle.php index 5f2b39eb2b1d9..3c6b3115fd909 100644 --- a/src/Symfony/Foundation/Bundle/KernelBundle.php +++ b/src/Symfony/Foundation/Bundle/KernelBundle.php @@ -10,7 +10,7 @@ use Symfony\Components\DependencyInjection\BuilderConfiguration; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,9 +19,10 @@ */ /** - * + * KernelBundle. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class KernelBundle extends Bundle diff --git a/src/Symfony/Foundation/Bundle/KernelExtension.php b/src/Symfony/Foundation/Bundle/KernelExtension.php index e5e316ef3a30e..32c040a120d6f 100644 --- a/src/Symfony/Foundation/Bundle/KernelExtension.php +++ b/src/Symfony/Foundation/Bundle/KernelExtension.php @@ -2,8 +2,12 @@ namespace Symfony\Foundation\Bundle; +use Symfony\Components\DependencyInjection\Loader\LoaderExtension; +use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Components\DependencyInjection\BuilderConfiguration; + /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -11,14 +15,12 @@ * file that was distributed with this source code. */ -use Symfony\Components\DependencyInjection\Loader\LoaderExtension; -use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Components\DependencyInjection\BuilderConfiguration; - /** + * KernelExtension. * - * @package Symfony - * @author Fabien Potencier + * @package Symfony + * @subpackage Foundation + * @author Fabien Potencier */ class KernelExtension extends LoaderExtension { diff --git a/src/Symfony/Foundation/ClassCollectionLoader.php b/src/Symfony/Foundation/ClassCollectionLoader.php index d97bf6787ea5c..eac732f83425a 100644 --- a/src/Symfony/Foundation/ClassCollectionLoader.php +++ b/src/Symfony/Foundation/ClassCollectionLoader.php @@ -3,7 +3,7 @@ namespace Symfony\Foundation; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * ClassCollectionLoader. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class ClassCollectionLoader diff --git a/src/Symfony/Foundation/Debug/ErrorException.php b/src/Symfony/Foundation/Debug/ErrorException.php index d1771e6ff4651..8545e20d0dccf 100644 --- a/src/Symfony/Foundation/Debug/ErrorException.php +++ b/src/Symfony/Foundation/Debug/ErrorException.php @@ -3,7 +3,7 @@ namespace Symfony\Foundation\Debug; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * ErrorException. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class ErrorException extends \Exception diff --git a/src/Symfony/Foundation/Debug/ErrorHandler.php b/src/Symfony/Foundation/Debug/ErrorHandler.php index 4dda26cdd26bd..f678ec2aa357f 100644 --- a/src/Symfony/Foundation/Debug/ErrorHandler.php +++ b/src/Symfony/Foundation/Debug/ErrorHandler.php @@ -3,7 +3,7 @@ namespace Symfony\Foundation\Debug; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * ErrorHandler. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class ErrorHandler diff --git a/src/Symfony/Foundation/Debug/EventDispatcher.php b/src/Symfony/Foundation/Debug/EventDispatcher.php index 307c263577a77..5171bb45917ab 100644 --- a/src/Symfony/Foundation/Debug/EventDispatcher.php +++ b/src/Symfony/Foundation/Debug/EventDispatcher.php @@ -9,7 +9,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -20,7 +20,8 @@ /** * EventDispatcher extends the original EventDispatcher class to add some debugging tools. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class EventDispatcher extends BaseEventDispatcher diff --git a/src/Symfony/Foundation/EventDispatcher.php b/src/Symfony/Foundation/EventDispatcher.php index 3919358680b80..c774d25ce0613 100644 --- a/src/Symfony/Foundation/EventDispatcher.php +++ b/src/Symfony/Foundation/EventDispatcher.php @@ -7,7 +7,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -19,7 +19,8 @@ * This EventDispatcher implementation uses a DependencyInjection container to * lazy load listeners. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class EventDispatcher extends BaseEventDispatcher diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 25ae066317a44..27f494beb574e 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -2,8 +2,15 @@ namespace Symfony\Foundation; +use Symfony\Components\DependencyInjection\ContainerInterface; +use Symfony\Components\DependencyInjection\Builder; +use Symfony\Components\DependencyInjection\BuilderConfiguration; +use Symfony\Components\DependencyInjection\Dumper\PhpDumper; +use Symfony\Components\DependencyInjection\FileResource; +use Symfony\Components\RequestHandler\RequestInterface; + /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -11,19 +18,13 @@ * file that was distributed with this source code. */ -use Symfony\Components\DependencyInjection\ContainerInterface; -use Symfony\Components\DependencyInjection\Builder; -use Symfony\Components\DependencyInjection\BuilderConfiguration; -use Symfony\Components\DependencyInjection\Dumper\PhpDumper; -use Symfony\Components\DependencyInjection\FileResource; -use Symfony\Components\RequestHandler\RequestInterface; - /** * The Kernel is the heart of the Symfony system. It manages an environment * that can host bundles. * - * @package Symfony - * @author Fabien Potencier + * @package Symfony + * @subpackage Foundation + * @author Fabien Potencier */ abstract class Kernel implements \Serializable { diff --git a/src/Symfony/Foundation/LoggerInterface.php b/src/Symfony/Foundation/LoggerInterface.php index 862e3da0e6d67..e9313c8c93cfe 100644 --- a/src/Symfony/Foundation/LoggerInterface.php +++ b/src/Symfony/Foundation/LoggerInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Foundation; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * LoggerInterface. * - * @package symfony + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ interface LoggerInterface diff --git a/src/Symfony/Foundation/UniversalClassLoader.php b/src/Symfony/Foundation/UniversalClassLoader.php index 69ed68798ef2d..1745e916a181c 100644 --- a/src/Symfony/Foundation/UniversalClassLoader.php +++ b/src/Symfony/Foundation/UniversalClassLoader.php @@ -3,7 +3,7 @@ namespace Symfony\Foundation; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -49,8 +49,8 @@ * directory, and it will then fallback to the framework/ directory if not * found before giving up. * - * @package symfony - * @subpackage foundation + * @package Symfony + * @subpackage Foundation * @author Fabien Potencier */ class UniversalClassLoader diff --git a/src/Symfony/Foundation/packager.php b/src/Symfony/Foundation/packager.php index 7f487fd1aa732..46726d16d5823 100644 --- a/src/Symfony/Foundation/packager.php +++ b/src/Symfony/Foundation/packager.php @@ -3,7 +3,7 @@ require_once __DIR__.'/UniversalClassLoader.php'; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * diff --git a/src/Symfony/Framework/DoctrineBundle/Bundle.php b/src/Symfony/Framework/DoctrineBundle/Bundle.php index 01b7b9f845feb..6d809879686b1 100644 --- a/src/Symfony/Framework/DoctrineBundle/Bundle.php +++ b/src/Symfony/Framework/DoctrineBundle/Bundle.php @@ -9,7 +9,7 @@ use Symfony\Framework\DoctrineBundle\DependencyInjection\DoctrineExtension; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,9 +18,10 @@ */ /** - * + * Bundle. * - * @package symfony + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php index 530fb406ce634..4d3441c92ab20 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php @@ -13,7 +13,7 @@ use Doctrine\DBAL\Connection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -24,8 +24,8 @@ /** * Build command allows you to easily build and re-build your Doctrine development environment * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage * @author Kris Wallsmith diff --git a/src/Symfony/Framework/DoctrineBundle/Command/BuildEntitiesDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/BuildEntitiesDoctrineCommand.php index 7e49f2b2ce0f9..5c6cb3131a65a 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/BuildEntitiesDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/BuildEntitiesDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ /** * Build all Bundle entity classes from mapping information. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/ClearCacheDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/ClearCacheDoctrineCommand.php index 56f6f6d6cffe3..1a09ef97cae20 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/ClearCacheDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/ClearCacheDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ /** * Manage the cache clearing of the Doctrine ORM. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/ConvertMappingDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/ConvertMappingDoctrineCommand.php index f867b29976aa8..e4d97186786d8 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/ConvertMappingDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/ConvertMappingDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -24,8 +24,8 @@ * Convert Doctrine ORM metadata mapping information between the various supported * formats. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php index ed440f852216a..e20331bbbc5bf 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php @@ -13,7 +13,7 @@ use Doctrine\DBAL\Connection; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -24,8 +24,8 @@ /** * Database tool allows you to easily drop and create your configured databases. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php index 1216564d0f20b..10913bf8e9acd 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php @@ -15,7 +15,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -26,8 +26,8 @@ /** * Base class for Doctrine console commands to extend from. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier */ abstract class DoctrineCommand extends Command diff --git a/src/Symfony/Framework/DoctrineBundle/Command/EnsureProductionSettingsDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/EnsureProductionSettingsDoctrineCommand.php index b6a04dd1c0dbe..81fac0093dfe1 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/EnsureProductionSettingsDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/EnsureProductionSettingsDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ /** * Ensure the Doctrine ORM is configured properly for a production environment. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php index 193d60d66fab6..8883a33e1bbf9 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php @@ -10,7 +10,7 @@ use Symfony\Framework\WebBundle\Util\Filesystem; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ /** * Generate the Doctrine ORM entity proxies to your cache directory. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier */ class GenerateProxiesDoctrineCommand extends DoctrineCommand diff --git a/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php index d551bbd27978e..8e8906eaae377 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php @@ -9,7 +9,7 @@ use Symfony\Components\Console\Output\Output; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,8 +21,8 @@ * Import the initial mapping information for entities from an existing database * into a bundle. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php index b30d8a8b40fc9..ebece434f4c3f 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ /** * Initialize a new Doctrine entity inside a bundle. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php index 49635e7a5c214..2c80c4560913c 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php @@ -15,7 +15,7 @@ use Doctrine\ORM\Internal\CommitOrderCalculator; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -24,10 +24,10 @@ */ /** - * Load data fixtures from bundles + * Load data fixtures from bundles. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php index edcd95a6ef94d..9604b7396f02a 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,10 +21,10 @@ */ /** - * Execute a Doctrine DQL query and output the results + * Execute a Doctrine DQL query and output the results. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php index a0bb433a9a38c..4f147a0f1ae26 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -21,10 +21,10 @@ */ /** - * Execute a SQL query and output the results + * Execute a SQL query and output the results. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php index f6c6ef5659e4c..b6b0cc4ddedd1 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ /** * Create, drop, and update your Doctrine ORM schema in the DBMS. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Command/VersionDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/VersionDoctrineCommand.php index d8eb4795b1466..86fe1aba0f30e 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/VersionDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/VersionDoctrineCommand.php @@ -12,7 +12,7 @@ use Doctrine\Common\Cli\CliController as DoctrineCliController; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -23,8 +23,8 @@ /** * Check what version of the Doctrine ORM being used. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php b/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php index ada36da00e6a1..08f10ef8344db 100644 --- a/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php +++ b/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php @@ -7,7 +7,7 @@ use Symfony\Components\RequestHandler\Exception\NotFoundHttpException; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,7 +18,8 @@ /** * Doctrine ORM controller gives you access to entity managers and DQL queries. * - * @package symfony + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier * @author Jonathan H. Wage */ diff --git a/src/Symfony/Framework/DoctrineBundle/DataCollector/DoctrineDataCollector.php b/src/Symfony/Framework/DoctrineBundle/DataCollector/DoctrineDataCollector.php index 64e5819382c07..e997f2afde998 100644 --- a/src/Symfony/Framework/DoctrineBundle/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Framework/DoctrineBundle/DataCollector/DoctrineDataCollector.php @@ -5,7 +5,7 @@ use Symfony\Framework\ProfilerBundle\DataCollector\DataCollector; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * DoctrineDataCollector. * - * @package symfony + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier */ class DoctrineDataCollector extends DataCollector diff --git a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php index 5ba85edf8bf32..77e73fcff00bc 100644 --- a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php +++ b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php @@ -9,7 +9,7 @@ use Symfony\Components\DependencyInjection\Reference; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,8 +20,8 @@ /** * DoctrineExtension is an extension for the Doctrine DBAL and ORM library. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier */ class DoctrineExtension extends LoaderExtension diff --git a/src/Symfony/Framework/DoctrineBundle/Logger/DbalLogger.php b/src/Symfony/Framework/DoctrineBundle/Logger/DbalLogger.php index 83d9fcc958b9a..12c56b9afaad0 100644 --- a/src/Symfony/Framework/DoctrineBundle/Logger/DbalLogger.php +++ b/src/Symfony/Framework/DoctrineBundle/Logger/DbalLogger.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Logging\DebugStack; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -15,9 +15,10 @@ */ /** - * + * DbalLogger. * - * @package symfony + * @package Symfony + * @subpackage Framework_DoctrineBundle * @author Fabien Potencier */ class DbalLogger extends DebugStack diff --git a/src/Symfony/Framework/ProfilerBundle/Bundle.php b/src/Symfony/Framework/ProfilerBundle/Bundle.php index 527147c50cf1c..e922af150d759 100644 --- a/src/Symfony/Framework/ProfilerBundle/Bundle.php +++ b/src/Symfony/Framework/ProfilerBundle/Bundle.php @@ -8,7 +8,7 @@ use Symfony\Framework\ProfilerBundle\DependencyInjection\ProfilerExtension; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * Bundle. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class Bundle extends BaseBundle diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/AppDataCollector.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/AppDataCollector.php index dfa8e7318b261..b933d13ff0034 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/AppDataCollector.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/AppDataCollector.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\ProfilerBundle\DataCollector; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * AppDataCollector. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class AppDataCollector extends DataCollector diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php index 32cbbbd28bb1a..5798590d2a6f0 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php @@ -5,7 +5,7 @@ use Symfony\Foundation\Kernel; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * ConfigDataCollector. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class ConfigDataCollector extends DataCollector diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollector.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollector.php index e23efcb60901d..ac0f4dbfd0c1c 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollector.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollector.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * DataCollector. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ abstract class DataCollector implements DataCollectorInterface diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorInterface.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorInterface.php index fe2f8eba407fe..1af38e454ff95 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorInterface.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\ProfilerBundle\DataCollector; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * DataCollectorInterface. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ interface DataCollectorInterface diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php index b4e94d5506bf8..fa558a75bff6e 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php @@ -8,7 +8,7 @@ use Symfony\Framework\ProfilerBundle\ProfilerStorage; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * DataCollectorManager. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class DataCollectorManager diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/MemoryDataCollector.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/MemoryDataCollector.php index 17d6789f30459..7721529b80321 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/MemoryDataCollector.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/MemoryDataCollector.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\ProfilerBundle\DataCollector; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * MemoryDataCollector. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class MemoryDataCollector extends DataCollector diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/TimerDataCollector.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/TimerDataCollector.php index 10d9c095aa9f7..47ef2229bfda4 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/TimerDataCollector.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/TimerDataCollector.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\ProfilerBundle\DataCollector; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * TimerDataCollector. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class TimerDataCollector extends DataCollector diff --git a/src/Symfony/Framework/ProfilerBundle/DependencyInjection/ProfilerExtension.php b/src/Symfony/Framework/ProfilerBundle/DependencyInjection/ProfilerExtension.php index cbf1785100d77..4dd4d972c0203 100644 --- a/src/Symfony/Framework/ProfilerBundle/DependencyInjection/ProfilerExtension.php +++ b/src/Symfony/Framework/ProfilerBundle/DependencyInjection/ProfilerExtension.php @@ -7,7 +7,7 @@ use Symfony\Components\DependencyInjection\BuilderConfiguration; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,7 +18,8 @@ /** * ProfilerExtension manages the data collectors and the web debug toolbar. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class ProfilerExtension extends LoaderExtension diff --git a/src/Symfony/Framework/ProfilerBundle/Listener/WebDebugToolbar.php b/src/Symfony/Framework/ProfilerBundle/Listener/WebDebugToolbar.php index 71e32db83c887..2dc4c9e50b8af 100644 --- a/src/Symfony/Framework/ProfilerBundle/Listener/WebDebugToolbar.php +++ b/src/Symfony/Framework/ProfilerBundle/Listener/WebDebugToolbar.php @@ -8,7 +8,7 @@ use Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * WebDebugToolbar. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class WebDebugToolbar diff --git a/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php b/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php index 12ae1247ee226..308ca21a0f6ca 100644 --- a/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php +++ b/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\ProfilerBundle; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * ProfilerStorage. * - * @package symfony + * @package Symfony + * @subpackage Framework_ProfilerBundle * @author Fabien Potencier */ class ProfilerStorage diff --git a/src/Symfony/Framework/SwiftmailerBundle/Bundle.php b/src/Symfony/Framework/SwiftmailerBundle/Bundle.php index 8def508fe6b4d..17dbd25deb2b6 100644 --- a/src/Symfony/Framework/SwiftmailerBundle/Bundle.php +++ b/src/Symfony/Framework/SwiftmailerBundle/Bundle.php @@ -8,7 +8,7 @@ use Symfony\Framework\SwiftmailerBundle\DependencyInjection\SwiftmailerExtension; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * Bundle. * - * @package symfony + * @package Symfony + * @subpackage Framework_SwiftmailerBundle * @author Fabien Potencier */ class Bundle extends BaseBundle diff --git a/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php b/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php index e8584dac7ffde..21779c5820dbc 100644 --- a/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php +++ b/src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php @@ -8,7 +8,7 @@ use Symfony\Components\DependencyInjection\Reference; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,10 +17,10 @@ */ /** - * SwiftMailerExtension is an extension for the Swift Mailer library. + * SwiftMailerExtension is an extension for the SwiftMailer library. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Framework_SwiftmailerBundle * @author Fabien Potencier */ class SwiftMailerExtension extends LoaderExtension diff --git a/src/Symfony/Framework/WebBundle/Bundle.php b/src/Symfony/Framework/WebBundle/Bundle.php index f0725b6828b7d..5218a31a29881 100644 --- a/src/Symfony/Framework/WebBundle/Bundle.php +++ b/src/Symfony/Framework/WebBundle/Bundle.php @@ -10,7 +10,7 @@ use Symfony\Framework\WebBundle\DependencyInjection\WebExtension; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,9 +19,10 @@ */ /** - * + * Bundle. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class Bundle extends BaseBundle diff --git a/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php b/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php index fa3b9ad12af11..d789044b80ecc 100644 --- a/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php @@ -10,7 +10,7 @@ use Symfony\Framework\WebBundle\Util\Filesystem; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,10 +19,10 @@ */ /** - * + * AssetsInstallCommand. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class AssetsInstallCommand extends Command diff --git a/src/Symfony/Framework/WebBundle/Command/Command.php b/src/Symfony/Framework/WebBundle/Command/Command.php index 6a1cef89ad459..0a178bedd2ff5 100644 --- a/src/Symfony/Framework/WebBundle/Command/Command.php +++ b/src/Symfony/Framework/WebBundle/Command/Command.php @@ -10,7 +10,7 @@ use Symfony\Components\Console\Command\Command as BaseCommand; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,10 +19,10 @@ */ /** - * + * Command. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ abstract class Command extends BaseCommand diff --git a/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php b/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php index 7fe622bbef227..117e51b6e4217 100644 --- a/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php @@ -11,7 +11,7 @@ use Symfony\Framework\WebBundle\Util\Mustache; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -22,8 +22,8 @@ /** * Initializes a new bundle. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class InitBundleCommand extends Command diff --git a/src/Symfony/Framework/WebBundle/Command/RouterApacheDumperCommand.php b/src/Symfony/Framework/WebBundle/Command/RouterApacheDumperCommand.php index d1b70fb7bf3bd..db1e923be2608 100644 --- a/src/Symfony/Framework/WebBundle/Command/RouterApacheDumperCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/RouterApacheDumperCommand.php @@ -10,7 +10,7 @@ use Symfony\Components\Routing\Matcher\Dumper\ApacheMatcherDumper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,10 +19,10 @@ */ /** - * + * RouterApacheDumperCommand. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class RouterApacheDumperCommand extends Command diff --git a/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php b/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php index 952f4c61ef14a..4b112cd339d60 100644 --- a/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php @@ -10,7 +10,7 @@ use Symfony\Components\Routing\Matcher\Dumper\ApacheMatcherDumper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,10 +19,10 @@ */ /** - * + * RouterDebugCommand. * - * @package symfony - * @subpackage console + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class RouterDebugCommand extends Command diff --git a/src/Symfony/Framework/WebBundle/Console/Application.php b/src/Symfony/Framework/WebBundle/Console/Application.php index 8151004bda636..7b999219b236c 100644 --- a/src/Symfony/Framework/WebBundle/Console/Application.php +++ b/src/Symfony/Framework/WebBundle/Console/Application.php @@ -9,7 +9,7 @@ use Symfony\Foundation\Kernel; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,9 +18,10 @@ */ /** + * Application. * - * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class Application extends BaseApplication diff --git a/src/Symfony/Framework/WebBundle/Console/BootstrapApplication.php b/src/Symfony/Framework/WebBundle/Console/BootstrapApplication.php index 33f4e57107b0c..eeecf565bb169 100644 --- a/src/Symfony/Framework/WebBundle/Console/BootstrapApplication.php +++ b/src/Symfony/Framework/WebBundle/Console/BootstrapApplication.php @@ -10,7 +10,7 @@ use Symfony\Framework\WebBundle\Command\InitApplicationCommand; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,9 +19,10 @@ */ /** - * + * BootstrapApplication. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class BootstrapApplication extends BaseApplication diff --git a/src/Symfony/Framework/WebBundle/Console/Shell.php b/src/Symfony/Framework/WebBundle/Console/Shell.php index 7d158a49e51b6..735fc5212542c 100644 --- a/src/Symfony/Framework/WebBundle/Console/Shell.php +++ b/src/Symfony/Framework/WebBundle/Console/Shell.php @@ -5,7 +5,7 @@ use Symfony\Components\Console\Shell as BaseShell; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * Shell. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class Shell extends BaseShell diff --git a/src/Symfony/Framework/WebBundle/Controller.php b/src/Symfony/Framework/WebBundle/Controller.php index 8803e4f8b5fd6..1d8698c1a1187 100644 --- a/src/Symfony/Framework/WebBundle/Controller.php +++ b/src/Symfony/Framework/WebBundle/Controller.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,7 +16,8 @@ /** * WebBundle Controller gives you convenient access to all commonly needed services. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class Controller diff --git a/src/Symfony/Framework/WebBundle/Controller/DefaultController.php b/src/Symfony/Framework/WebBundle/Controller/DefaultController.php index 409941712f054..9830f4bcd880d 100644 --- a/src/Symfony/Framework/WebBundle/Controller/DefaultController.php +++ b/src/Symfony/Framework/WebBundle/Controller/DefaultController.php @@ -6,7 +6,7 @@ use Symfony\Components\RequestHandler\Request; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,7 +17,8 @@ /** * * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class DefaultController extends Controller diff --git a/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php b/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php index a8ecc0bd248ee..1b54d6c1902d5 100644 --- a/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php +++ b/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php @@ -9,7 +9,7 @@ use Symfony\Components\RequestHandler\Exception\HttpException; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -20,7 +20,8 @@ /** * * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class ExceptionController extends Controller diff --git a/src/Symfony/Framework/WebBundle/Controller/RedirectController.php b/src/Symfony/Framework/WebBundle/Controller/RedirectController.php index 38fb081fe3c96..6d370d02f8821 100644 --- a/src/Symfony/Framework/WebBundle/Controller/RedirectController.php +++ b/src/Symfony/Framework/WebBundle/Controller/RedirectController.php @@ -6,7 +6,7 @@ use Symfony\Components\RequestHandler\Request; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,7 +17,8 @@ /** * * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class RedirectController extends Controller diff --git a/src/Symfony/Framework/WebBundle/Controller/TemplateController.php b/src/Symfony/Framework/WebBundle/Controller/TemplateController.php index 49b165d84279d..76be9ffaa611c 100644 --- a/src/Symfony/Framework/WebBundle/Controller/TemplateController.php +++ b/src/Symfony/Framework/WebBundle/Controller/TemplateController.php @@ -6,7 +6,7 @@ use Symfony\Components\RequestHandler\Request; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,7 +17,8 @@ /** * * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class TemplateController extends Controller diff --git a/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php b/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php index 9b2e74ee31c1b..0b24111791a9b 100644 --- a/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php +++ b/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php @@ -5,7 +5,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * ExceptionFormatter. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class ExceptionFormatter diff --git a/src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php b/src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php index c6052d1c5d511..21e65da08b080 100644 --- a/src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php +++ b/src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php @@ -8,7 +8,7 @@ use Symfony\Components\DependencyInjection\Reference; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * WebExtension. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class WebExtension extends LoaderExtension diff --git a/src/Symfony/Framework/WebBundle/Helper/ActionsHelper.php b/src/Symfony/Framework/WebBundle/Helper/ActionsHelper.php index ad027296fadbe..e0296d7b12b6c 100644 --- a/src/Symfony/Framework/WebBundle/Helper/ActionsHelper.php +++ b/src/Symfony/Framework/WebBundle/Helper/ActionsHelper.php @@ -7,7 +7,7 @@ use Symfony\Components\OutputEscaper\Escaper; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,9 +16,10 @@ */ /** - * + * ActionsHelper. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class ActionsHelper extends Helper diff --git a/src/Symfony/Framework/WebBundle/Helper/RequestHelper.php b/src/Symfony/Framework/WebBundle/Helper/RequestHelper.php index a0c46d4d1ab30..5115cdd676e9c 100644 --- a/src/Symfony/Framework/WebBundle/Helper/RequestHelper.php +++ b/src/Symfony/Framework/WebBundle/Helper/RequestHelper.php @@ -6,7 +6,7 @@ use Symfony\Components\RequestHandler\Request; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -15,9 +15,10 @@ */ /** - * + * RequestHelper. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class RequestHelper extends Helper diff --git a/src/Symfony/Framework/WebBundle/Helper/RouterHelper.php b/src/Symfony/Framework/WebBundle/Helper/RouterHelper.php index e48051e4e6e82..cb34e67b3edaf 100644 --- a/src/Symfony/Framework/WebBundle/Helper/RouterHelper.php +++ b/src/Symfony/Framework/WebBundle/Helper/RouterHelper.php @@ -6,7 +6,7 @@ use Symfony\Components\Routing\Router; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -15,9 +15,10 @@ */ /** - * + * RouterHelper. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class RouterHelper extends Helper diff --git a/src/Symfony/Framework/WebBundle/Helper/UserHelper.php b/src/Symfony/Framework/WebBundle/Helper/UserHelper.php index 96ad9ce815b33..bb498e007b399 100644 --- a/src/Symfony/Framework/WebBundle/Helper/UserHelper.php +++ b/src/Symfony/Framework/WebBundle/Helper/UserHelper.php @@ -6,7 +6,7 @@ use Symfony\Framework\WebBundle\User; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -15,9 +15,10 @@ */ /** - * + * UserHelper. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class UserHelper extends Helper diff --git a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php index 9984af5a0f37d..f42c22b9b3f41 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php +++ b/src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php @@ -7,7 +7,7 @@ use Symfony\Components\EventDispatcher\Event; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -19,7 +19,8 @@ * ControllerLoader listen to the core.load_controller and finds the controller * to execute based on the request parameters. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class ControllerLoader diff --git a/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php b/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php index 0abee28d4cf7b..9d71158da846e 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php +++ b/src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php @@ -7,7 +7,7 @@ use Symfony\Foundation\LoggerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,9 +16,10 @@ */ /** - * + * ExceptionHandler. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class ExceptionHandler diff --git a/src/Symfony/Framework/WebBundle/Listener/RequestParser.php b/src/Symfony/Framework/WebBundle/Listener/RequestParser.php index d19c50b68a4b9..156ab0d9ff7e8 100644 --- a/src/Symfony/Framework/WebBundle/Listener/RequestParser.php +++ b/src/Symfony/Framework/WebBundle/Listener/RequestParser.php @@ -8,7 +8,7 @@ use Symfony\Components\Routing\RouterInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * RequestParser. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class RequestParser diff --git a/src/Symfony/Framework/WebBundle/Listener/ResponseFilter.php b/src/Symfony/Framework/WebBundle/Listener/ResponseFilter.php index 6f64e1c020d59..e0f0138f679ad 100644 --- a/src/Symfony/Framework/WebBundle/Listener/ResponseFilter.php +++ b/src/Symfony/Framework/WebBundle/Listener/ResponseFilter.php @@ -8,7 +8,7 @@ use Symfony\Components\RequestHandler\ResponseInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -17,9 +17,10 @@ */ /** - * + * ResponseFilter. * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class ResponseFilter diff --git a/src/Symfony/Framework/WebBundle/Session/NativeSession.php b/src/Symfony/Framework/WebBundle/Session/NativeSession.php index f70e39536e228..a1cada807c79f 100644 --- a/src/Symfony/Framework/WebBundle/Session/NativeSession.php +++ b/src/Symfony/Framework/WebBundle/Session/NativeSession.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Session; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** + * NativeSession. * - * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class NativeSession implements SessionInterface diff --git a/src/Symfony/Framework/WebBundle/Session/PdoSession.php b/src/Symfony/Framework/WebBundle/Session/PdoSession.php index 218c332aba10d..60c71c04b5a55 100644 --- a/src/Symfony/Framework/WebBundle/Session/PdoSession.php +++ b/src/Symfony/Framework/WebBundle/Session/PdoSession.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Session; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** + * PdoSession. * - * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class PdoSession extends NativeSession diff --git a/src/Symfony/Framework/WebBundle/Session/SessionInterface.php b/src/Symfony/Framework/WebBundle/Session/SessionInterface.php index fb2661d158480..8f4fb635c3f14 100644 --- a/src/Symfony/Framework/WebBundle/Session/SessionInterface.php +++ b/src/Symfony/Framework/WebBundle/Session/SessionInterface.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Session; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** + * SessionInterface. * - * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ interface SessionInterface diff --git a/src/Symfony/Framework/WebBundle/Templating/Debugger.php b/src/Symfony/Framework/WebBundle/Templating/Debugger.php index 280494f8bc261..5f3477160f533 100644 --- a/src/Symfony/Framework/WebBundle/Templating/Debugger.php +++ b/src/Symfony/Framework/WebBundle/Templating/Debugger.php @@ -6,7 +6,7 @@ use Symfony\Foundation\LoggerInterface; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -17,8 +17,9 @@ /** * Binds the Symfony templating loader debugger to the Symfony logger. * - * @package symfony - * @author Fabien Potencier + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier */ class Debugger implements DebuggerInterface { diff --git a/src/Symfony/Framework/WebBundle/Templating/Engine.php b/src/Symfony/Framework/WebBundle/Templating/Engine.php index 2c42ad7158cda..62d256f822add 100644 --- a/src/Symfony/Framework/WebBundle/Templating/Engine.php +++ b/src/Symfony/Framework/WebBundle/Templating/Engine.php @@ -8,7 +8,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface; /* - * This file is part of the symfony package. + * This file is part of the Symfony package. * * (c) Fabien Potencier * @@ -20,8 +20,9 @@ * This engine knows how to render Symfony templates and automatically * escapes template parameters. * - * @package symfony - * @author Fabien Potencier + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier */ class Engine extends BaseEngine { diff --git a/src/Symfony/Framework/WebBundle/User.php b/src/Symfony/Framework/WebBundle/User.php index 5831f6d30b3ea..1dcd67726b305 100644 --- a/src/Symfony/Framework/WebBundle/User.php +++ b/src/Symfony/Framework/WebBundle/User.php @@ -7,7 +7,7 @@ use Symfony\Framework\WebBundle\Session\SessionInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -16,9 +16,10 @@ */ /** + * User. * - * - * @package symfony + * @package Symfony + * @subpackage Framework_WebBundle * @author Fabien Potencier */ class User diff --git a/src/Symfony/Framework/WebBundle/Util/Filesystem.php b/src/Symfony/Framework/WebBundle/Util/Filesystem.php index 8288d9b0029d4..793453c222b7a 100644 --- a/src/Symfony/Framework/WebBundle/Util/Filesystem.php +++ b/src/Symfony/Framework/WebBundle/Util/Filesystem.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Util; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,8 +14,9 @@ /** * Provides basic utility to manipulate the file system. * - * @package symfony - * @author Fabien Potencier + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier */ class Filesystem { diff --git a/src/Symfony/Framework/WebBundle/Util/Finder.php b/src/Symfony/Framework/WebBundle/Util/Finder.php index e17de759b02b1..cb38db59c53f0 100644 --- a/src/Symfony/Framework/WebBundle/Util/Finder.php +++ b/src/Symfony/Framework/WebBundle/Util/Finder.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Util; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -24,8 +24,9 @@ * * Interface loosely based on perl File::Find::Rule module. * - * @package symfony - * @author Fabien Potencier + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier */ class Finder { diff --git a/src/Symfony/Framework/WebBundle/Util/Glob.php b/src/Symfony/Framework/WebBundle/Util/Glob.php index 9748e64b3530a..580098de8fd44 100644 --- a/src/Symfony/Framework/WebBundle/Util/Glob.php +++ b/src/Symfony/Framework/WebBundle/Util/Glob.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Util; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -28,10 +28,11 @@ * * based on perl Text::Glob module. * - * @package symfony - * @author Fabien Potencier php port + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier php port * @author Richard Clamp perl version - * @copyright 2004-2005 Fabien Potencier + * @copyright 2004-2005 Fabien Potencier * @copyright 2002 Richard Clamp */ class Glob diff --git a/src/Symfony/Framework/WebBundle/Util/Mustache.php b/src/Symfony/Framework/WebBundle/Util/Mustache.php index 7d43d7c93c134..50a3875112a53 100644 --- a/src/Symfony/Framework/WebBundle/Util/Mustache.php +++ b/src/Symfony/Framework/WebBundle/Util/Mustache.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Util; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -11,6 +11,13 @@ * with this source code in the file LICENSE. */ +/** + * Mustache. + * + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier + */ class Mustache { static public function renderFile($file, $parameters) diff --git a/src/Symfony/Framework/WebBundle/Util/NumberCompare.php b/src/Symfony/Framework/WebBundle/Util/NumberCompare.php index 5e7a7e6ef9824..0be9ef49a6aec 100644 --- a/src/Symfony/Framework/WebBundle/Util/NumberCompare.php +++ b/src/Symfony/Framework/WebBundle/Util/NumberCompare.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\WebBundle\Util; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -27,11 +27,11 @@ * * based on perl Number::Compare module. * - * @package symfony - * @subpackage util - * @author Fabien Potencier php port + * @package Symfony + * @subpackage Framework_WebBundle + * @author Fabien Potencier php port * @author Richard Clamp perl version - * @copyright 2004-2005 Fabien Potencier + * @copyright 2004-2005 Fabien Potencier * @copyright 2002 Richard Clamp * @see http://physics.nist.gov/cuu/Units/binary.html */ diff --git a/src/Symfony/Framework/ZendBundle/Bundle.php b/src/Symfony/Framework/ZendBundle/Bundle.php index 321e110fcaa78..d8723c89fb53b 100644 --- a/src/Symfony/Framework/ZendBundle/Bundle.php +++ b/src/Symfony/Framework/ZendBundle/Bundle.php @@ -9,7 +9,7 @@ use Symfony\Framework\ZendBundle\DependencyInjection\ZendExtension; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,9 +18,10 @@ */ /** - * + * Bundle. * - * @package symfony + * @package Symfony + * @subpackage Framework_ZendBundle * @author Fabien Potencier */ class Bundle extends BaseBundle diff --git a/src/Symfony/Framework/ZendBundle/DependencyInjection/ZendExtension.php b/src/Symfony/Framework/ZendBundle/DependencyInjection/ZendExtension.php index 848dc951f25cb..99771132de2c0 100644 --- a/src/Symfony/Framework/ZendBundle/DependencyInjection/ZendExtension.php +++ b/src/Symfony/Framework/ZendBundle/DependencyInjection/ZendExtension.php @@ -7,7 +7,7 @@ use Symfony\Components\DependencyInjection\BuilderConfiguration; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -18,8 +18,8 @@ /** * ZendExtension is an extension for the Zend Framework libraries. * - * @package symfony - * @subpackage dependency_injection + * @package Symfony + * @subpackage Framework_ZendBundle * @author Fabien Potencier */ class ZendExtension extends LoaderExtension diff --git a/src/Symfony/Framework/ZendBundle/Logger/DebugLogger.php b/src/Symfony/Framework/ZendBundle/Logger/DebugLogger.php index 1197acd6b9767..3e31e84c37745 100644 --- a/src/Symfony/Framework/ZendBundle/Logger/DebugLogger.php +++ b/src/Symfony/Framework/ZendBundle/Logger/DebugLogger.php @@ -3,7 +3,7 @@ namespace Symfony\Framework\ZendBundle\Logger; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -12,9 +12,10 @@ */ /** - * + * DebugLogger. * - * @package symfony + * @package Symfony + * @subpackage Framework_ZendBundle * @author Fabien Potencier */ class DebugLogger extends \Zend_Log_Writer_Abstract diff --git a/src/Symfony/Framework/ZendBundle/Logger/Logger.php b/src/Symfony/Framework/ZendBundle/Logger/Logger.php index 13bf8985774b7..d21ea66680faa 100644 --- a/src/Symfony/Framework/ZendBundle/Logger/Logger.php +++ b/src/Symfony/Framework/ZendBundle/Logger/Logger.php @@ -5,7 +5,7 @@ use Symfony\Foundation\LoggerInterface; /* - * This file is part of the symfony framework. + * This file is part of the Symfony framework. * * (c) Fabien Potencier * @@ -14,9 +14,10 @@ */ /** - * + * Logger. * - * @package symfony + * @package Symfony + * @subpackage Framework_ZendBundle * @author Fabien Potencier */ class Logger extends \Zend_Log implements LoggerInterface From 5409f0efe93b2ce5b59a849b6eb7b000804c75ce Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Wed, 7 Apr 2010 09:07:59 +0800 Subject: [PATCH 54/54] Fixed trailing whitespaces --- src/Symfony/Components/CssSelector/Parser.php | 2 +- src/Symfony/Components/EventDispatcher/Event.php | 2 +- .../Components/EventDispatcher/EventDispatcher.php | 2 +- src/Symfony/Components/Routing/Router.php | 2 +- .../Templating/Helper/JavascriptsHelper.php | 2 +- .../Templating/Helper/StylesheetsHelper.php | 2 +- src/Symfony/Foundation/bootstrap.php | 10 ++++++---- .../DoctrineBundle/Command/BuildDoctrineCommand.php | 2 +- .../Command/DatabaseToolDoctrineCommand.php | 2 +- .../Command/LoadDataFixturesDoctrineCommand.php | 2 +- .../Command/SchemaToolDoctrineCommand.php | 2 +- .../DoctrineBundle/Controller/DoctrineController.php | 11 ++++++----- .../DependencyInjection/DoctrineExtension.php | 2 +- .../WebBundle/Command/InitBundleCommand.php | 2 +- .../WebBundle/Controller/DefaultController.php | 2 +- .../WebBundle/Controller/ExceptionController.php | 2 +- .../WebBundle/Controller/TemplateController.php | 2 +- .../Framework/WebBundle/Debug/ExceptionFormatter.php | 6 +++--- .../Framework/WebBundle/Session/NativeSession.php | 4 ++-- src/Symfony/Framework/WebBundle/User.php | 12 ++++++------ .../DependencyInjection/BuilderConfigurationTest.php | 2 +- .../Components/DependencyInjection/BuilderTest.php | 2 +- .../Components/DependencyInjection/ContainerTest.php | 2 +- .../DependencyInjection/CrossCheckTest.php | 2 +- .../DependencyInjection/DefinitionTest.php | 2 +- .../DependencyInjection/Dumper/DumperTest.php | 2 +- .../Dumper/GraphvizDumperTest.php | 2 +- .../DependencyInjection/Dumper/PhpDumperTest.php | 2 +- .../DependencyInjection/Dumper/XmlDumperTest.php | 2 +- .../DependencyInjection/Dumper/YamlDumperTest.php | 2 +- .../DependencyInjection/FileResourceTest.php | 2 +- .../DependencyInjection/Loader/FileLoaderTest.php | 2 +- .../DependencyInjection/Loader/IniFileLoaderTest.php | 2 +- .../Loader/LoaderExtensionTest.php | 2 +- .../DependencyInjection/Loader/LoaderTest.php | 2 +- .../DependencyInjection/Loader/XmlFileLoaderTest.php | 2 +- .../Loader/YamlFileLoaderTest.php | 2 +- .../Components/DependencyInjection/ParameterTest.php | 2 +- .../Components/DependencyInjection/ReferenceTest.php | 2 +- .../Tests/Components/OutputEscaper/EscaperTest.php | 2 +- .../Tests/Components/Templating/EngineTest.php | 2 +- .../Components/Templating/Helper/AssetsTest.php | 2 +- .../Components/Templating/Helper/HelperTest.php | 2 +- .../Templating/Helper/JavascriptsHelperTest.php | 2 +- .../Components/Templating/Helper/SlotsHelperTest.php | 2 +- .../Templating/Helper/StylesheetsHelperTest.php | 2 +- .../Components/Templating/Loader/CacheLoaderTest.php | 2 +- .../Components/Templating/Loader/ChainLoaderTest.php | 2 +- .../Templating/Loader/FilesystemLoaderTest.php | 2 +- .../Components/Templating/Loader/LoaderTest.php | 2 +- .../Templating/Renderer/PhpRendererTest.php | 2 +- .../Components/Templating/Renderer/RendererTest.php | 2 +- .../Templating/Storage/FileStorageTest.php | 2 +- .../Components/Templating/Storage/StorageTest.php | 2 +- .../Templating/Storage/StringStorageTest.php | 2 +- tests/Symfony/Tests/Components/Yaml/DumperTest.php | 2 +- 56 files changed, 74 insertions(+), 71 deletions(-) diff --git a/src/Symfony/Components/CssSelector/Parser.php b/src/Symfony/Components/CssSelector/Parser.php index 933a1f68c58d7..929fa808a6eca 100644 --- a/src/Symfony/Components/CssSelector/Parser.php +++ b/src/Symfony/Components/CssSelector/Parser.php @@ -282,7 +282,7 @@ protected function parseSimpleSelector($stream) } /** - * @throws SyntaxError When encountered unexpected selector + * @throws SyntaxError When encountered unexpected selector */ protected function parseAttrib($selector, $stream) { diff --git a/src/Symfony/Components/EventDispatcher/Event.php b/src/Symfony/Components/EventDispatcher/Event.php index 1e3e909fc0aa5..a2319805f76e3 100644 --- a/src/Symfony/Components/EventDispatcher/Event.php +++ b/src/Symfony/Components/EventDispatcher/Event.php @@ -5,7 +5,7 @@ /* * This file is part of the Symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/Symfony/Components/EventDispatcher/EventDispatcher.php b/src/Symfony/Components/EventDispatcher/EventDispatcher.php index 89083934f3e6e..ff5cc500ee2e7 100644 --- a/src/Symfony/Components/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Components/EventDispatcher/EventDispatcher.php @@ -5,7 +5,7 @@ /* * This file is part of the Symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/Symfony/Components/Routing/Router.php b/src/Symfony/Components/Routing/Router.php index 98870e777e0b0..77b7ed418d173 100644 --- a/src/Symfony/Components/Routing/Router.php +++ b/src/Symfony/Components/Routing/Router.php @@ -252,7 +252,7 @@ protected function getCacheFile($class, $extension = 'php') } /** - * @throws \RuntimeException When cache file can't be wrote + * @throws \RuntimeException When cache file can't be wrote */ protected function writeCacheFile($file, $content) { diff --git a/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php b/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php index 50c5e9ce459aa..7f3ef61497412 100644 --- a/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php +++ b/src/Symfony/Components/Templating/Helper/JavascriptsHelper.php @@ -85,7 +85,7 @@ public function render() /** * Outputs HTML representation of the links to JavaScripts. - * + * */ public function output() { diff --git a/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php b/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php index b42bc8f139b8c..969956a50466c 100644 --- a/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php +++ b/src/Symfony/Components/Templating/Helper/StylesheetsHelper.php @@ -85,7 +85,7 @@ public function render() /** * Outputs HTML representation of the links to stylesheets. - * + * */ public function output() { diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index 189f61bb4ee87..c18d3ed181639 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -77,13 +77,13 @@ public function boot(ContainerInterface $container) namespace Symfony\Foundation\Bundle; - - use Symfony\Components\DependencyInjection\Loader\LoaderExtension; use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; use Symfony\Components\DependencyInjection\BuilderConfiguration; + + class KernelExtension extends LoaderExtension { public function configLoad($config) @@ -193,6 +193,7 @@ public function register() set_error_handler(array($this, 'handle')); } + public function handle($level, $message, $file, $line, $context) { if (0 === $this->level) @@ -217,6 +218,7 @@ public function handle($level, $message, $file, $line, $context) class ClassCollectionLoader { + static public function load($classes, $cacheDir, $name, $autoReload) { $cache = $cacheDir.'/'.$name.'.php'; @@ -310,8 +312,6 @@ static protected function writeCacheFile($file, $content) namespace Symfony\Foundation; - - use Symfony\Components\DependencyInjection\ContainerInterface; use Symfony\Components\DependencyInjection\Builder; use Symfony\Components\DependencyInjection\BuilderConfiguration; @@ -320,6 +320,8 @@ static protected function writeCacheFile($file, $content) use Symfony\Components\RequestHandler\RequestInterface; + + abstract class Kernel implements \Serializable { protected $bundles; diff --git a/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php index 4d3441c92ab20..9599b5fafec7a 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($input->hasOption('and-load')) { $dirOrFile = $input->getOption('and-load'); - $this->runCommand('doctrine:load-data-fixtures', + $this->runCommand('doctrine:load-data-fixtures', array('--dir-or-file' => $dirOrFile, '--append' => false) ); } diff --git a/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php index e20331bbbc5bf..448130936203e 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { - throw new \InvalidArgumentException(sprintf('Could not find any configured connections', $input->getOption('connection'))); + throw new \InvalidArgumentException(sprintf('Could not find any configured connections', $input->getOption('connection'))); } } } diff --git a/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php index 2c80c4560913c..741408ee10112 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php @@ -139,7 +139,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } } - + protected function purgeEntityManager(EntityManager $em) { $classes = array(); diff --git a/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php index b6b0cc4ddedd1..b3e33e2f0a3f8 100644 --- a/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php +++ b/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php @@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { - $output->writeln(sprintf('Could not find any configured connections', $input->getOption('connection'))); + $output->writeln(sprintf('Could not find any configured connections', $input->getOption('connection'))); } } } diff --git a/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php b/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php index 08f10ef8344db..25a02bcf7aa85 100644 --- a/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php +++ b/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php @@ -38,10 +38,10 @@ public function getDatabaseConnection($name = null) } /** - * Get the default entity manager service or the entity manager + * Get the default entity manager service or the entity manager * with the given name. * - * @param string $name Optional entity manager service name + * @param string $name Optional entity manager service name * @return object $em */ protected function getEntityManager($name = null) @@ -59,7 +59,7 @@ protected function getEntityManager($name = null) /** * Create a new QueryBuilder instance. * - * @param string $name Optional entity manager service name + * @param string $name Optional entity manager service name * @return object QueryBuilder */ public function createQueryBuilder($name = null) @@ -70,8 +70,9 @@ public function createQueryBuilder($name = null) /** * Create a new Query instance. * - * @param string $dql Optional Dql string to create the query from - * @param string $name Optional entity manager service name + * @param string $dql Optional Dql string to create the query from + * @param string $name Optional entity manager service name + * * @return object QueryBuilder */ public function createQuery($dql = '', $name = null) diff --git a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php index 77e73fcff00bc..0c208770981c6 100644 --- a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php +++ b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php @@ -145,7 +145,7 @@ public function dbalLoad($config) $configuration->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), $driverDef); } - $configuration->setAlias('database_connection', + $configuration->setAlias('database_connection', null !== $this->alias ? $this->alias : sprintf( 'doctrine.dbal.%s_connection', $config['default_connection'] ) diff --git a/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php b/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php index 117e51b6e4217..6154af0460f3e 100644 --- a/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php +++ b/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php @@ -43,7 +43,7 @@ protected function configure() /** * @see Command - * + * * @throws \InvalidArgumentException When namespace doesn't end with Bundle * @throws \RuntimeException When bundle can't be executed */ diff --git a/src/Symfony/Framework/WebBundle/Controller/DefaultController.php b/src/Symfony/Framework/WebBundle/Controller/DefaultController.php index 9830f4bcd880d..a8ec4b21f2e78 100644 --- a/src/Symfony/Framework/WebBundle/Controller/DefaultController.php +++ b/src/Symfony/Framework/WebBundle/Controller/DefaultController.php @@ -15,7 +15,7 @@ */ /** - * + * DefaultController. * * @package Symfony * @subpackage Framework_WebBundle diff --git a/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php b/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php index 1b54d6c1902d5..ba765334a756a 100644 --- a/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php +++ b/src/Symfony/Framework/WebBundle/Controller/ExceptionController.php @@ -18,7 +18,7 @@ */ /** - * + * ExceptionController. * * @package Symfony * @subpackage Framework_WebBundle diff --git a/src/Symfony/Framework/WebBundle/Controller/TemplateController.php b/src/Symfony/Framework/WebBundle/Controller/TemplateController.php index 76be9ffaa611c..02e119dd676c1 100644 --- a/src/Symfony/Framework/WebBundle/Controller/TemplateController.php +++ b/src/Symfony/Framework/WebBundle/Controller/TemplateController.php @@ -15,7 +15,7 @@ */ /** - * + * TemplateController. * * @package Symfony * @subpackage Framework_WebBundle diff --git a/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php b/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php index 0b24111791a9b..c2d1a6ba2a2ac 100644 --- a/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php +++ b/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php @@ -145,7 +145,7 @@ protected function formatArgs($args, $single = false, $format = 'html') { $formattedValue = $value; } - + $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escape($key), $formattedValue); } @@ -154,12 +154,12 @@ protected function formatArgs($args, $single = false, $format = 'html') /** * Formats a file path. - * + * * @param string $file An absolute file path * @param integer $line The line number * @param string $format The output format (txt or html) * @param string $text Use this text for the link rather than the file path - * + * * @return string */ protected function formatFile($file, $line, $format = 'html', $text = null) diff --git a/src/Symfony/Framework/WebBundle/Session/NativeSession.php b/src/Symfony/Framework/WebBundle/Session/NativeSession.php index a1cada807c79f..d01dceff38e86 100644 --- a/src/Symfony/Framework/WebBundle/Session/NativeSession.php +++ b/src/Symfony/Framework/WebBundle/Session/NativeSession.php @@ -85,13 +85,13 @@ public function __construct($options = null) self::$sessionStarted = true; } } - + /** * Reads data from this storage. * * The preferred format for a key is directory style so naming conflicts can be avoided. * - * @param string $key A unique key identifying your data + * @param string $key A unique key identifying your data * * @return mixed Data associated with the key */ diff --git a/src/Symfony/Framework/WebBundle/User.php b/src/Symfony/Framework/WebBundle/User.php index 1dcd67726b305..8da493783de86 100644 --- a/src/Symfony/Framework/WebBundle/User.php +++ b/src/Symfony/Framework/WebBundle/User.php @@ -64,10 +64,10 @@ public function getAttribute($name, $default = null) } /** - * Sets an user attribute - * + * Sets an user attribute. + * * @param string $name - * @param mixed $value + * @param mixed $value */ public function setAttribute($name, $value) { @@ -105,9 +105,9 @@ public function getCulture() } /** - * Sets the user culture - * - * @param string $culture + * Sets the user culture. + * + * @param string $culture */ public function setCulture($culture) { diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php index 9545ab73a3258..2ac37e7158b7e 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php index dd92d55d9fa6d..cd7164adc2784 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php index 9615c56ac0a2e..13c79e4be7360 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php index 7e769233461f5..70d5a02e97325 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php index d569a807745e9..4a5c614556220 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php index ae4bd018fea3a..f003eaa337ee6 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php index f8ae12a929d10..4d17150a18f50 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/GraphvizDumperTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php index a13ad04786196..ecdbdaf35e694 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php index 2f9fd4d72cb8b..f217fc661f009 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php index 0b650ceb24e62..56d7cca19f033 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php index 11f2f36413dcc..51d3f82565164 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/FileResourceTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php index e126c14ef2797..90e31ff80b6bf 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/FileLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php index 46c09a91de000..5038512de112d 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php index b152812002008..c28ff06318f10 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php index 975c63f12f771..353e252a0724b 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php index 725ff0acfc3a3..561feb9f41ceb 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php index 7c7a26f0164f0..a89000c9ed5d5 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php index 02b6224d4f140..358f7163f0c89 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ParameterTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php index bee62af42c87c..d23dd6b76d6be 100644 --- a/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php +++ b/tests/Symfony/Tests/Components/DependencyInjection/ReferenceTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php index 49221573bc186..1e228d9de3a64 100644 --- a/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php +++ b/tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/EngineTest.php b/tests/Symfony/Tests/Components/Templating/EngineTest.php index 0c7c9feb86886..2fac620557d1d 100644 --- a/tests/Symfony/Tests/Components/Templating/EngineTest.php +++ b/tests/Symfony/Tests/Components/Templating/EngineTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php index b86b2c34750ac..cb91216452b8c 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php index 96226cc716105..23302f8842db7 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/HelperTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php index cfd63115a94cd..dc052bc4a703b 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/JavascriptsHelperTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php index 90d0e0a13650d..849d64c207def 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php index 8316636464368..1ed15c93e077c 100644 --- a/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php +++ b/tests/Symfony/Tests/Components/Templating/Helper/StylesheetsHelperTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php index d9992b6c4d499..def8c3822b69f 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php index 5e5c9a76c29bf..e3b176081320e 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/ChainLoaderTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php index db93d11273846..1b358af09c3c4 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/FilesystemLoaderTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php index bfaeb21d81213..6b3b981914a8f 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php index d7f2ead7d496f..3c7749ba3e38b 100644 --- a/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php +++ b/tests/Symfony/Tests/Components/Templating/Renderer/PhpRendererTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php b/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php index 69d93bbe16b54..e47e135265e52 100644 --- a/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php +++ b/tests/Symfony/Tests/Components/Templating/Renderer/RendererTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php index bd5a9d84c4445..650b6762743f8 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/FileStorageTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php index eb2cfeb1ee61e..56cacb1607a8b 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/StorageTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php index 4db7f15715165..656295fea6952 100644 --- a/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php +++ b/tests/Symfony/Tests/Components/Templating/Storage/StringStorageTest.php @@ -4,7 +4,7 @@ * This file is part of the symfony package. * * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/tests/Symfony/Tests/Components/Yaml/DumperTest.php b/tests/Symfony/Tests/Components/Yaml/DumperTest.php index 4ca0873602e24..6558b11dae61f 100644 --- a/tests/Symfony/Tests/Components/Yaml/DumperTest.php +++ b/tests/Symfony/Tests/Components/Yaml/DumperTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */