diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ecca78e05..383bec81f6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,9 @@ Contributing Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the [Contributing Code][1] part of the documentation. If you're submitting -a pull request, please follow the guidelines in the [Submitting a Patch][2] section. +a pull request, please follow the guidelines in the [Submitting a Patch][2] section +and use the [Pull Request Template][3]. [1]: http://symfony.com/doc/current/contributing/code/index.html [2]: http://symfony.com/doc/current/contributing/code/patches.html#check-list +[3]: http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request diff --git a/README.md b/README.md index f50ccefeb3..8ec144b00d 100644 --- a/README.md +++ b/README.md @@ -46,17 +46,19 @@ Contributing Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the [Contributing Code][4] part of the documentation. If you're submitting -a pull request, please follow the guidelines in the [Submitting a Patch][5] section. +a pull request, please follow the guidelines in the [Submitting a Patch][5] section +and use [Pull Request Template][6]. Running Symfony2 Tests ---------------------- Information on how to run the Symfony2 test suite can be found in the -[Running Symfony2 Tests][6] section. +[Running Symfony2 Tests][7] section. [1]: http://symfony.com/download [2]: http://symfony.com/get_started [3]: http://symfony.com/doc/current/ [4]: http://symfony.com/doc/current/contributing/code/index.html [5]: http://symfony.com/doc/current/contributing/code/patches.html#check-list -[6]: http://symfony.com/doc/master/contributing/code/tests.html +[6]: http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request +[7]: http://symfony.com/doc/master/contributing/code/tests.html diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php index 641deb7683..ce674b190c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php @@ -31,6 +31,35 @@ class InternalController extends ContainerAware */ public function indexAction($path, $controller) { + // safeguard + if (!is_string($controller)) { + throw new \RuntimeException('A Controller must be a string.'); + } + + // check that the controller looks like a controller + if (false === strpos($controller, '::')) { + $count = substr_count($controller, ':'); + if (2 == $count) { + // the convention already enforces the Controller suffix + } elseif (1 == $count) { + // controller in the service:method notation + list($service, $method) = explode(':', $controller, 2); + $class = get_class($this->container->get($service)); + + if (!preg_match('/Controller$/', $class)) { + throw new \RuntimeException('A Controller class name must end with Controller.'); + } + } else { + throw new \LogicException('Unable to parse the Controller name.'); + } + } else { + list($class, $method) = explode('::', $controller, 2); + + if (!preg_match('/Controller$/', $class)) { + throw new \RuntimeException('A Controller class name must end with Controller.'); + } + } + $request = $this->container->get('request'); $attributes = $request->attributes; diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php b/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php index 8beaf28c0b..6aba2501d6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php @@ -151,8 +151,13 @@ class HttpKernel extends BaseHttpKernel $request = $this->container->get('request'); - // controller or URI? - if (0 === strpos($controller, '/')) { + // controller or URI or path? + if (0 === strpos($controller, 'http://') || 0 === strpos($controller, 'https://')) { + $subRequest = Request::create($controller, 'get', array(), $request->cookies->all(), array(), $request->server->all()); + if ($session = $request->getSession()) { + $subRequest->setSession($session); + } + } elseif (0 === strpos($controller, '/')) { $subRequest = Request::create($request->getUriForPath($controller), 'get', array(), $request->cookies->all(), array(), $request->server->all()); if ($session = $request->getSession()) { $subRequest->setSession($session); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/InternalControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/InternalControllerTest.php new file mode 100644 index 0000000000..2b35ff1424 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/InternalControllerTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\InternalController; +use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +use Symfony\Component\HttpFoundation\Request; + +class InternalControllerTest extends TestCase +{ + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage A Controller class name must end with Controller. + */ + public function testWithAClassMethodController() + { + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + + $controller = new InternalController(); + $controller->setContainer($container); + + $controller->indexAction('/', 'Symfony\Component\HttpFoundation\Request::getPathInfo'); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage A Controller class name must end with Controller. + */ + public function testWithAServiceController() + { + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container + ->expects($this->once()) + ->method('get') + ->will($this->returnValue(new Request())) + ; + + $controller = new InternalController(); + $controller->setContainer($container); + + $controller->indexAction('/', 'service:method'); + } +} diff --git a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php index ed08aac272..b081815453 100644 --- a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php @@ -66,7 +66,7 @@ class StubLocaleTest extends LocaleTestCase public function testGetCurrenciesData() { - $symbol = $this->isSameAsIcuVersion('4.8') ? 'BR$' : 'R$'; + $symbol = $this->isGreaterOrEqualThanIcuVersion('4.8') ? 'BR$' : 'R$'; $currencies = StubLocale::getCurrenciesData('en'); $this->assertEquals($symbol, $currencies['BRL']['symbol']); diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 90c38af2fe..aeb53475f0 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -57,18 +57,9 @@ class PhpProcess extends Process } /** - * Runs the process. - * - * @param Closure|string|array $callback A PHP callback to run whenever there is some - * output available on STDOUT or STDERR - * - * @return integer The exit status code - * - * @throws Exception\RuntimeException - * - * @api + * {@inheritdoc} */ - public function run($callback = null) + public function start($callback = null) { if (null === $this->getCommandLine()) { if (false === $php = $this->executableFinder->find()) { @@ -77,6 +68,6 @@ class PhpProcess extends Process $this->setCommandLine($php); } - return parent::run($callback); + return parent::start($callback); } } diff --git a/src/Symfony/Component/Process/Tests/PhpProcessTest.php b/src/Symfony/Component/Process/Tests/PhpProcessTest.php new file mode 100644 index 0000000000..7bcdd2f05d --- /dev/null +++ b/src/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -0,0 +1,21 @@ +start(); + $process->wait(); + $this->assertEquals($expected, $process->getOutput()); + } +}