Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
639
vendor/symfony/browser-kit/Tests/ClientTest.php
vendored
639
vendor/symfony/browser-kit/Tests/ClientTest.php
vendored
|
@ -1,639 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\Client;
|
||||
use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\CookieJar;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
|
||||
class SpecialResponse extends Response
|
||||
{
|
||||
}
|
||||
|
||||
class TestClient extends Client
|
||||
{
|
||||
protected $nextResponse = null;
|
||||
protected $nextScript = null;
|
||||
|
||||
public function setNextResponse(Response $response)
|
||||
{
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
public function setNextScript($script)
|
||||
{
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function doRequest($request)
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return new Response();
|
||||
}
|
||||
|
||||
$response = $this->nextResponse;
|
||||
$this->nextResponse = null;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function filterResponse($response)
|
||||
{
|
||||
if ($response instanceof SpecialResponse) {
|
||||
return new Response($response->getContent(), $response->getStatus(), $response->getHeaders());
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getScript($request)
|
||||
{
|
||||
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
|
||||
$path = $r->getFileName();
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
require_once('$path');
|
||||
|
||||
echo serialize($this->nextScript);
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
||||
class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\BrowserKit\Client::getHistory
|
||||
*/
|
||||
public function testGetHistory()
|
||||
{
|
||||
$client = new TestClient(array(), $history = new History());
|
||||
$this->assertSame($history, $client->getHistory(), '->getHistory() returns the History');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\BrowserKit\Client::getCookieJar
|
||||
*/
|
||||
public function testGetCookieJar()
|
||||
{
|
||||
$client = new TestClient(array(), null, $cookieJar = new CookieJar());
|
||||
$this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\BrowserKit\Client::getRequest
|
||||
*/
|
||||
public function testGetRequest()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://example.com/');
|
||||
|
||||
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
|
||||
}
|
||||
|
||||
public function testGetRequestWithIpAsHost()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1'));
|
||||
|
||||
$this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri());
|
||||
}
|
||||
|
||||
public function testGetResponse()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('foo'));
|
||||
$client->request('GET', 'http://example.com/');
|
||||
|
||||
$this->assertEquals('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request');
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request');
|
||||
}
|
||||
|
||||
public function testGetInternalResponse()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new SpecialResponse('foo'));
|
||||
$client->request('GET', 'http://example.com/');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse());
|
||||
$this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getInternalResponse());
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getResponse());
|
||||
}
|
||||
|
||||
public function testGetContent()
|
||||
{
|
||||
$json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}';
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('POST', 'http://example.com/jsonrpc', array(), array(), array(), $json);
|
||||
$this->assertEquals($json, $client->getRequest()->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\BrowserKit\Client::getCrawler
|
||||
*/
|
||||
public function testGetCrawler()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('foo'));
|
||||
$crawler = $client->request('GET', 'http://example.com/');
|
||||
|
||||
$this->assertSame($crawler, $client->getCrawler(), '->getCrawler() returns the Crawler of the last request');
|
||||
}
|
||||
|
||||
public function testRequestHttpHeaders()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', '/');
|
||||
$headers = $client->getRequest()->getServer();
|
||||
$this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com');
|
||||
$headers = $client->getRequest()->getServer();
|
||||
$this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
|
||||
|
||||
$client->request('GET', 'https://www.example.com');
|
||||
$headers = $client->getRequest()->getServer();
|
||||
$this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com:8080');
|
||||
$headers = $client->getRequest()->getServer();
|
||||
$this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port');
|
||||
}
|
||||
|
||||
public function testRequestURIConversion()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', '/foo');
|
||||
$this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com');
|
||||
$this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/');
|
||||
$client->request('GET', '/foo');
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo');
|
||||
$client->request('GET', '#');
|
||||
$this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
||||
$client->request('GET', '#');
|
||||
$this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
||||
$client->request('GET', '#foo');
|
||||
$this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo/');
|
||||
$client->request('GET', 'bar');
|
||||
$this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$client->request('GET', 'bar');
|
||||
$this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo/');
|
||||
$client->request('GET', 'http');
|
||||
$this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo');
|
||||
$client->request('GET', 'http/bar');
|
||||
$this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/');
|
||||
$client->request('GET', 'http');
|
||||
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||
}
|
||||
|
||||
public function testRequestURIConversionByServerHost()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
||||
$server = array('HTTP_HOST' => 'www.exampl+e.com:8000');
|
||||
$parameters = array();
|
||||
$files = array();
|
||||
|
||||
$client->request('GET', 'http://exampl+e.com', $parameters, $files, $server);
|
||||
$this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port');
|
||||
|
||||
$client->request('GET', 'http://exampl+e.com:8888', $parameters, $files, $server);
|
||||
$this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port');
|
||||
|
||||
$client->request('GET', 'http://exampl+e.com:8000', $parameters, $files, $server);
|
||||
$this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port');
|
||||
}
|
||||
|
||||
public function testRequestReferer()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$client->request('GET', 'bar');
|
||||
$server = $client->getRequest()->getServer();
|
||||
$this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
|
||||
}
|
||||
|
||||
public function testRequestHistory()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$client->request('GET', 'bar');
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History');
|
||||
$this->assertEquals('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History');
|
||||
}
|
||||
|
||||
public function testRequestCookies()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array('Set-Cookie' => 'foo=bar')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
|
||||
|
||||
$client->request('GET', 'bar');
|
||||
$this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
|
||||
}
|
||||
|
||||
public function testRequestSecureCookies()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array('Set-Cookie' => 'foo=bar; path=/; secure')));
|
||||
$client->request('GET', 'https://www.example.com/foo/foobar');
|
||||
|
||||
$this->assertTrue($client->getCookieJar()->get('foo', '/', 'www.example.com')->isSecure());
|
||||
}
|
||||
|
||||
public function testClick()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>'));
|
||||
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$client->click($crawler->filter('a')->link());
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links');
|
||||
}
|
||||
|
||||
public function testClickForm()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
||||
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$client->click($crawler->filter('input')->form());
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms');
|
||||
}
|
||||
|
||||
public function testSubmit()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
||||
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$client->submit($crawler->filter('input')->form());
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
|
||||
}
|
||||
|
||||
public function testSubmitPreserveAuth()
|
||||
{
|
||||
$client = new TestClient(array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar'));
|
||||
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
||||
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$server = $client->getRequest()->getServer();
|
||||
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
|
||||
$this->assertEquals('foo', $server['PHP_AUTH_USER']);
|
||||
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
|
||||
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
|
||||
|
||||
$client->submit($crawler->filter('input')->form());
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
|
||||
|
||||
$server = $client->getRequest()->getServer();
|
||||
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
|
||||
$this->assertEquals('foo', $server['PHP_AUTH_USER']);
|
||||
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
|
||||
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
|
||||
}
|
||||
|
||||
public function testFollowRedirect()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->followRedirects(false);
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
try {
|
||||
$client->followRedirect();
|
||||
$this->fail('->followRedirect() throws a \LogicException if the request was not redirected');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected');
|
||||
}
|
||||
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$client->followRedirect();
|
||||
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->followRedirects(false);
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
try {
|
||||
$client->followRedirect();
|
||||
$this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
|
||||
}
|
||||
}
|
||||
|
||||
public function testFollowRelativeRedirect()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => '/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => '/redirected:1234')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls');
|
||||
}
|
||||
|
||||
public function testFollowRedirectWithMaxRedirects()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->setMaxRedirects(1);
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
||||
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected2')));
|
||||
try {
|
||||
$client->followRedirect();
|
||||
$this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
|
||||
}
|
||||
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
||||
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => '/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => '//www.example.org/')));
|
||||
$client->request('GET', 'https://www.example.com/');
|
||||
|
||||
$this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar'));
|
||||
|
||||
$this->assertEquals('get', $client->getRequest()->getMethod(), '->followRedirect() uses a get for 302');
|
||||
$this->assertEquals(array(), $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method');
|
||||
}
|
||||
|
||||
public function testFollowRedirectWithCookies()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->followRedirects(false);
|
||||
$client->setNextResponse(new Response('', 302, array(
|
||||
'Location' => 'http://www.example.com/redirected',
|
||||
'Set-Cookie' => 'foo=bar',
|
||||
)));
|
||||
$client->request('GET', 'http://www.example.com/');
|
||||
$this->assertEquals(array(), $client->getRequest()->getCookies());
|
||||
$client->followRedirect();
|
||||
$this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies());
|
||||
}
|
||||
|
||||
public function testFollowRedirectWithHeaders()
|
||||
{
|
||||
$headers = array(
|
||||
'HTTP_HOST' => 'www.example.com',
|
||||
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
|
||||
'CONTENT_TYPE' => 'application/vnd.custom+xml',
|
||||
'HTTPS' => false,
|
||||
);
|
||||
|
||||
$client = new TestClient();
|
||||
$client->followRedirects(false);
|
||||
$client->setNextResponse(new Response('', 302, array(
|
||||
'Location' => 'http://www.example.com/redirected',
|
||||
)));
|
||||
$client->request('GET', 'http://www.example.com/', array(), array(), array(
|
||||
'CONTENT_TYPE' => 'application/vnd.custom+xml',
|
||||
));
|
||||
|
||||
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||
|
||||
$client->followRedirect();
|
||||
|
||||
$headers['HTTP_REFERER'] = 'http://www.example.com/';
|
||||
|
||||
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||
}
|
||||
|
||||
public function testFollowRedirectWithPort()
|
||||
{
|
||||
$headers = array(
|
||||
'HTTP_HOST' => 'www.example.com:8080',
|
||||
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
|
||||
'HTTPS' => false,
|
||||
'HTTP_REFERER' => 'http://www.example.com:8080/',
|
||||
);
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array(
|
||||
'Location' => 'http://www.example.com:8080/redirected',
|
||||
)));
|
||||
$client->request('GET', 'http://www.example.com:8080/');
|
||||
|
||||
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||
}
|
||||
|
||||
public function testBack()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
||||
$parameters = array('foo' => 'bar');
|
||||
$files = array('myfile.foo' => 'baz');
|
||||
$server = array('X_TEST_FOO' => 'bazbar');
|
||||
$content = 'foobarbaz';
|
||||
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
|
||||
$client->request('GET', 'http://www.example.com/foo');
|
||||
$client->back();
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->back() goes back in the history');
|
||||
$this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->back() keeps parameters');
|
||||
$this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->back() keeps files');
|
||||
$this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->back() keeps $_SERVER');
|
||||
$this->assertEquals($content, $client->getRequest()->getContent(), '->back() keeps content');
|
||||
}
|
||||
|
||||
public function testForward()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
||||
$parameters = array('foo' => 'bar');
|
||||
$files = array('myfile.foo' => 'baz');
|
||||
$server = array('X_TEST_FOO' => 'bazbar');
|
||||
$content = 'foobarbaz';
|
||||
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$client->request('GET', 'http://www.example.com/foo', $parameters, $files, $server, $content);
|
||||
$client->back();
|
||||
$client->forward();
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->forward() goes forward in the history');
|
||||
$this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->forward() keeps parameters');
|
||||
$this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->forward() keeps files');
|
||||
$this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->forward() keeps $_SERVER');
|
||||
$this->assertEquals($content, $client->getRequest()->getContent(), '->forward() keeps content');
|
||||
}
|
||||
|
||||
public function testReload()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
||||
$parameters = array('foo' => 'bar');
|
||||
$files = array('myfile.foo' => 'baz');
|
||||
$server = array('X_TEST_FOO' => 'bazbar');
|
||||
$content = 'foobarbaz';
|
||||
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
|
||||
$client->reload();
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page');
|
||||
$this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->reload() keeps parameters');
|
||||
$this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->reload() keeps files');
|
||||
$this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->reload() keeps $_SERVER');
|
||||
$this->assertEquals($content, $client->getRequest()->getContent(), '->reload() keeps content');
|
||||
}
|
||||
|
||||
public function testRestart()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$client->restart();
|
||||
|
||||
$this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history');
|
||||
$this->assertEquals(array(), $client->getCookieJar()->all(), '->restart() clears the cookies');
|
||||
}
|
||||
|
||||
public function testInsulatedRequests()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->insulate();
|
||||
$client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')");
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$this->assertEquals('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process');
|
||||
|
||||
$client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar)");
|
||||
|
||||
try {
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
$this->fail('->request() throws a \RuntimeException if the script has an error');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error');
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetServerParameter()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
|
||||
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
||||
$this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue'));
|
||||
}
|
||||
|
||||
public function testSetServerParameter()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
||||
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
|
||||
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
||||
|
||||
$client->setServerParameter('HTTP_HOST', 'testhost');
|
||||
$this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST'));
|
||||
|
||||
$client->setServerParameter('HTTP_USER_AGENT', 'testua');
|
||||
$this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT'));
|
||||
}
|
||||
|
||||
public function testSetServerParameterInRequest()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
||||
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
|
||||
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
||||
|
||||
$client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array(
|
||||
'HTTP_HOST' => 'testhost',
|
||||
'HTTP_USER_AGENT' => 'testua',
|
||||
'HTTPS' => false,
|
||||
'NEW_SERVER_KEY' => 'new-server-key-value',
|
||||
));
|
||||
|
||||
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
|
||||
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
||||
|
||||
$this->assertEquals('http://testhost/https/www.example.com', $client->getRequest()->getUri());
|
||||
|
||||
$server = $client->getRequest()->getServer();
|
||||
|
||||
$this->assertArrayHasKey('HTTP_USER_AGENT', $server);
|
||||
$this->assertEquals('testua', $server['HTTP_USER_AGENT']);
|
||||
|
||||
$this->assertArrayHasKey('HTTP_HOST', $server);
|
||||
$this->assertEquals('testhost', $server['HTTP_HOST']);
|
||||
|
||||
$this->assertArrayHasKey('NEW_SERVER_KEY', $server);
|
||||
$this->assertEquals('new-server-key-value', $server['NEW_SERVER_KEY']);
|
||||
|
||||
$this->assertArrayHasKey('HTTPS', $server);
|
||||
$this->assertFalse($server['HTTPS']);
|
||||
}
|
||||
}
|
231
vendor/symfony/browser-kit/Tests/CookieJarTest.php
vendored
231
vendor/symfony/browser-kit/Tests/CookieJarTest.php
vendored
|
@ -1,231 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\CookieJar;
|
||||
use Symfony\Component\BrowserKit\Cookie;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
|
||||
class CookieJarTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSetGet()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie = new Cookie('foo', 'bar'));
|
||||
|
||||
$this->assertEquals($cookie, $cookieJar->get('foo'), '->set() sets a cookie');
|
||||
|
||||
$this->assertNull($cookieJar->get('foobar'), '->get() returns null if the cookie does not exist');
|
||||
|
||||
$cookieJar->set($cookie = new Cookie('foo', 'bar', time() - 86400));
|
||||
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
|
||||
}
|
||||
|
||||
public function testExpire()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie = new Cookie('foo', 'bar'));
|
||||
$cookieJar->expire('foo');
|
||||
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar'));
|
||||
$cookieJar->set($cookie2 = new Cookie('bar', 'foo'));
|
||||
|
||||
$this->assertEquals(array($cookie1, $cookie2), $cookieJar->all(), '->all() returns all cookies in the jar');
|
||||
}
|
||||
|
||||
public function testClear()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar'));
|
||||
$cookieJar->set($cookie2 = new Cookie('bar', 'foo'));
|
||||
|
||||
$cookieJar->clear();
|
||||
|
||||
$this->assertEquals(array(), $cookieJar->all(), '->clear() expires all cookies');
|
||||
}
|
||||
|
||||
public function testUpdateFromResponse()
|
||||
{
|
||||
$response = new Response('', 200, array('Set-Cookie' => 'foo=foo'));
|
||||
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->updateFromResponse($response);
|
||||
|
||||
$this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromResponse() updates cookies from a Response objects');
|
||||
}
|
||||
|
||||
public function testUpdateFromSetCookie()
|
||||
{
|
||||
$setCookies = array('foo=foo');
|
||||
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set(new Cookie('bar', 'bar'));
|
||||
$cookieJar->updateFromSetCookie($setCookies);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('foo'));
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('bar'));
|
||||
$this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromSetCookie() updates cookies from a Set-Cookie header');
|
||||
$this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies');
|
||||
}
|
||||
|
||||
public function testUpdateFromEmptySetCookie()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->updateFromSetCookie(array(''));
|
||||
$this->assertEquals(array(), $cookieJar->all());
|
||||
}
|
||||
|
||||
public function testUpdateFromSetCookieWithMultipleCookies()
|
||||
{
|
||||
$timestamp = time() + 3600;
|
||||
$date = gmdate('D, d M Y H:i:s \G\M\T', $timestamp);
|
||||
$setCookies = array(sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%s', $date, $date));
|
||||
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->updateFromSetCookie($setCookies);
|
||||
|
||||
$fooCookie = $cookieJar->get('foo', '/', '.symfony.com');
|
||||
$barCookie = $cookieJar->get('bar', '/', '.blog.symfony.com');
|
||||
$phpCookie = $cookieJar->get('PHPSESSID');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $fooCookie);
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $barCookie);
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $phpCookie);
|
||||
$this->assertEquals('foo', $fooCookie->getValue());
|
||||
$this->assertEquals('bar', $barCookie->getValue());
|
||||
$this->assertEquals('id', $phpCookie->getValue());
|
||||
$this->assertEquals($timestamp, $fooCookie->getExpiresTime());
|
||||
$this->assertNull($barCookie->getExpiresTime());
|
||||
$this->assertEquals($timestamp, $phpCookie->getExpiresTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideAllValuesValues
|
||||
*/
|
||||
public function testAllValues($uri, $values)
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo_nothing', 'foo'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo_expired', 'foo', time() - 86400));
|
||||
$cookieJar->set($cookie3 = new Cookie('foo_path', 'foo', null, '/foo'));
|
||||
$cookieJar->set($cookie4 = new Cookie('foo_domain', 'foo', null, '/', '.example.com'));
|
||||
$cookieJar->set($cookie4 = new Cookie('foo_strict_domain', 'foo', null, '/', '.www4.example.com'));
|
||||
$cookieJar->set($cookie5 = new Cookie('foo_secure', 'foo', null, '/', '', true));
|
||||
|
||||
$this->assertEquals($values, array_keys($cookieJar->allValues($uri)), '->allValues() returns the cookie for a given URI');
|
||||
}
|
||||
|
||||
public function provideAllValuesValues()
|
||||
{
|
||||
return array(
|
||||
array('http://www.example.com', array('foo_nothing', 'foo_domain')),
|
||||
array('http://www.example.com/', array('foo_nothing', 'foo_domain')),
|
||||
array('http://foo.example.com/', array('foo_nothing', 'foo_domain')),
|
||||
array('http://foo.example1.com/', array('foo_nothing')),
|
||||
array('https://foo.example.com/', array('foo_nothing', 'foo_secure', 'foo_domain')),
|
||||
array('http://www.example.com/foo/bar', array('foo_nothing', 'foo_path', 'foo_domain')),
|
||||
array('http://www4.example.com/', array('foo_nothing', 'foo_domain', 'foo_strict_domain')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testEncodedValues()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true));
|
||||
|
||||
$this->assertEquals(array('foo' => 'bar=baz'), $cookieJar->allValues('/'));
|
||||
$this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/'));
|
||||
}
|
||||
|
||||
public function testCookieExpireWithSameNameButDifferentPaths()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar'));
|
||||
$cookieJar->expire('foo', '/foo');
|
||||
|
||||
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
|
||||
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
|
||||
$this->assertEquals(array(), $cookieJar->allValues('http://example.com/foo'));
|
||||
$this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar'));
|
||||
}
|
||||
|
||||
public function testCookieExpireWithNullPaths()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/'));
|
||||
$cookieJar->expire('foo', null);
|
||||
|
||||
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
|
||||
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
|
||||
}
|
||||
|
||||
public function testCookieWithSameNameButDifferentPaths()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar'));
|
||||
|
||||
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
|
||||
$this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://example.com/foo'));
|
||||
$this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar'));
|
||||
}
|
||||
|
||||
public function testCookieWithSameNameButDifferentDomains()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/', 'foo.example.com'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/', 'bar.example.com'));
|
||||
|
||||
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
|
||||
$this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://foo.example.com/'));
|
||||
$this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://bar.example.com/'));
|
||||
}
|
||||
|
||||
public function testCookieGetWithSubdomain()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/', '.example.com'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo1', 'bar', null, '/', 'test.example.com'));
|
||||
|
||||
$this->assertEquals($cookie1, $cookieJar->get('foo', '/', 'foo.example.com'));
|
||||
$this->assertEquals($cookie1, $cookieJar->get('foo', '/', 'example.com'));
|
||||
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'test.example.com'));
|
||||
}
|
||||
|
||||
public function testCookieGetWithSubdirectory()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/test', '.example.com'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo1', 'bar1', null, '/', '.example.com'));
|
||||
|
||||
$this->assertNull($cookieJar->get('foo', '/', '.example.com'));
|
||||
$this->assertNull($cookieJar->get('foo', '/bar', '.example.com'));
|
||||
$this->assertEquals($cookie1, $cookieJar->get('foo', '/test', 'example.com'));
|
||||
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'example.com'));
|
||||
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar', 'example.com'));
|
||||
}
|
||||
|
||||
public function testCookieWithWildcardDomain()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set(new Cookie('foo', 'bar', null, '/', '.example.com'));
|
||||
|
||||
$this->assertEquals(array('foo' => 'bar'), $cookieJar->allValues('http://www.example.com'));
|
||||
$this->assertEmpty($cookieJar->allValues('http://wwwexample.com'));
|
||||
}
|
||||
}
|
179
vendor/symfony/browser-kit/Tests/CookieTest.php
vendored
179
vendor/symfony/browser-kit/Tests/CookieTest.php
vendored
|
@ -1,179 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\Cookie;
|
||||
|
||||
class CookieTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getTestsForToFromString
|
||||
*/
|
||||
public function testToFromString($cookie, $url = null)
|
||||
{
|
||||
$this->assertEquals($cookie, (string) Cookie::fromString($cookie, $url));
|
||||
}
|
||||
|
||||
public function getTestsForToFromString()
|
||||
{
|
||||
return array(
|
||||
array('foo=bar; path=/'),
|
||||
array('foo=bar; path=/foo'),
|
||||
array('foo=bar; domain=google.com; path=/'),
|
||||
array('foo=bar; domain=example.com; path=/; secure', 'https://example.com/'),
|
||||
array('foo=bar; path=/; httponly'),
|
||||
array('foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'),
|
||||
array('foo=bar=baz; path=/'),
|
||||
array('foo=bar%3Dbaz; path=/'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testFromStringIgnoreSecureFlag()
|
||||
{
|
||||
$this->assertFalse(Cookie::fromString('foo=bar; secure')->isSecure());
|
||||
$this->assertFalse(Cookie::fromString('foo=bar; secure', 'http://example.com/')->isSecure());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getExpireCookieStrings
|
||||
*/
|
||||
public function testFromStringAcceptsSeveralExpiresDateFormats($cookie)
|
||||
{
|
||||
$this->assertEquals(1596185377, Cookie::fromString($cookie)->getExpiresTime());
|
||||
}
|
||||
|
||||
public function getExpireCookieStrings()
|
||||
{
|
||||
return array(
|
||||
array('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Fri Jul 31 08:49:37 2020'),
|
||||
array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''),
|
||||
array('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testFromStringWithCapitalization()
|
||||
{
|
||||
$this->assertEquals('Foo=Bar; path=/', (string) Cookie::fromString('Foo=Bar'));
|
||||
$this->assertEquals('foo=bar; expires=Fri, 31 Dec 2010 23:59:59 GMT; path=/', (string) Cookie::fromString('foo=bar; Expires=Fri, 31 Dec 2010 23:59:59 GMT'));
|
||||
$this->assertEquals('foo=bar; domain=www.example.org; path=/; httponly', (string) Cookie::fromString('foo=bar; DOMAIN=www.example.org; HttpOnly'));
|
||||
}
|
||||
|
||||
public function testFromStringWithUrl()
|
||||
{
|
||||
$this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com/'));
|
||||
$this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com'));
|
||||
$this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com?foo'));
|
||||
$this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::fromString('foo=bar', 'http://www.example.com/foo/bar'));
|
||||
$this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar; path=/', 'http://www.example.com/foo/bar'));
|
||||
$this->assertEquals('foo=bar; domain=www.myotherexample.com; path=/', (string) Cookie::fromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/'));
|
||||
}
|
||||
|
||||
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
Cookie::fromString('foo');
|
||||
}
|
||||
|
||||
public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
Cookie::fromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT');
|
||||
}
|
||||
|
||||
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
Cookie::fromString('foo=bar', 'foobar');
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
$this->assertEquals('foo', $cookie->getName(), '->getName() returns the cookie name');
|
||||
}
|
||||
|
||||
public function testGetValue()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
$this->assertEquals('bar', $cookie->getValue(), '->getValue() returns the cookie value');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value
|
||||
$this->assertEquals('bar=baz', $cookie->getValue(), '->getValue() returns the urldecoded cookie value');
|
||||
}
|
||||
|
||||
public function testGetRawValue()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar=baz'); // decoded value
|
||||
$this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the urlencoded cookie value');
|
||||
$cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value
|
||||
$this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the non-urldecoded cookie value');
|
||||
}
|
||||
|
||||
public function testGetPath()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar', 0);
|
||||
$this->assertEquals('/', $cookie->getPath(), '->getPath() returns / is no path is defined');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', 0, '/foo');
|
||||
$this->assertEquals('/foo', $cookie->getPath(), '->getPath() returns the cookie path');
|
||||
}
|
||||
|
||||
public function testGetDomain()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com');
|
||||
$this->assertEquals('foo.com', $cookie->getDomain(), '->getDomain() returns the cookie domain');
|
||||
}
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
$this->assertFalse($cookie->isSecure(), '->isSecure() returns false if not defined');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com', true);
|
||||
$this->assertTrue($cookie->isSecure(), '->isSecure() returns the cookie secure flag');
|
||||
}
|
||||
|
||||
public function testIsHttponly()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
$this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns false if not defined');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com', false, true);
|
||||
$this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns the cookie httponly flag');
|
||||
}
|
||||
|
||||
public function testGetExpiresTime()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
$this->assertNull($cookie->getExpiresTime(), '->getExpiresTime() returns the expires time');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', $time = time() - 86400);
|
||||
$this->assertEquals($time, $cookie->getExpiresTime(), '->getExpiresTime() returns the expires time');
|
||||
}
|
||||
|
||||
public function testIsExpired()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar');
|
||||
$this->assertFalse($cookie->isExpired(), '->isExpired() returns false when the cookie never expires (null as expires time)');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', time() - 86400);
|
||||
$this->assertTrue($cookie->isExpired(), '->isExpired() returns true when the cookie is expired');
|
||||
|
||||
$cookie = new Cookie('foo', 'bar', 0);
|
||||
$this->assertFalse($cookie->isExpired());
|
||||
}
|
||||
}
|
101
vendor/symfony/browser-kit/Tests/HistoryTest.php
vendored
101
vendor/symfony/browser-kit/Tests/HistoryTest.php
vendored
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\Request;
|
||||
|
||||
class HistoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAdd()
|
||||
{
|
||||
$history = new History();
|
||||
$history->add(new Request('http://www.example1.com/', 'get'));
|
||||
$this->assertSame('http://www.example1.com/', $history->current()->getUri(), '->add() adds a request to the history');
|
||||
|
||||
$history->add(new Request('http://www.example2.com/', 'get'));
|
||||
$this->assertSame('http://www.example2.com/', $history->current()->getUri(), '->add() adds a request to the history');
|
||||
|
||||
$history->add(new Request('http://www.example3.com/', 'get'));
|
||||
$history->back();
|
||||
$history->add(new Request('http://www.example4.com/', 'get'));
|
||||
$this->assertSame('http://www.example4.com/', $history->current()->getUri(), '->add() adds a request to the history');
|
||||
|
||||
$history->back();
|
||||
$this->assertSame('http://www.example2.com/', $history->current()->getUri(), '->add() adds a request to the history');
|
||||
}
|
||||
|
||||
public function testClearIsEmpty()
|
||||
{
|
||||
$history = new History();
|
||||
$history->add(new Request('http://www.example.com/', 'get'));
|
||||
|
||||
$this->assertFalse($history->isEmpty(), '->isEmpty() returns false if the history is not empty');
|
||||
|
||||
$history->clear();
|
||||
|
||||
$this->assertTrue($history->isEmpty(), '->isEmpty() true if the history is empty');
|
||||
}
|
||||
|
||||
public function testCurrent()
|
||||
{
|
||||
$history = new History();
|
||||
|
||||
try {
|
||||
$history->current();
|
||||
$this->fail('->current() throws a \LogicException if the history is empty');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is empty');
|
||||
}
|
||||
|
||||
$history->add(new Request('http://www.example.com/', 'get'));
|
||||
|
||||
$this->assertSame('http://www.example.com/', $history->current()->getUri(), '->current() returns the current request in the history');
|
||||
}
|
||||
|
||||
public function testBack()
|
||||
{
|
||||
$history = new History();
|
||||
$history->add(new Request('http://www.example.com/', 'get'));
|
||||
|
||||
try {
|
||||
$history->back();
|
||||
$this->fail('->back() throws a \LogicException if the history is already on the first page');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page');
|
||||
}
|
||||
|
||||
$history->add(new Request('http://www.example1.com/', 'get'));
|
||||
$history->back();
|
||||
|
||||
$this->assertSame('http://www.example.com/', $history->current()->getUri(), '->back() returns the previous request in the history');
|
||||
}
|
||||
|
||||
public function testForward()
|
||||
{
|
||||
$history = new History();
|
||||
$history->add(new Request('http://www.example.com/', 'get'));
|
||||
$history->add(new Request('http://www.example1.com/', 'get'));
|
||||
|
||||
try {
|
||||
$history->forward();
|
||||
$this->fail('->forward() throws a \LogicException if the history is already on the last page');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page');
|
||||
}
|
||||
|
||||
$history->back();
|
||||
$history->forward();
|
||||
|
||||
$this->assertSame('http://www.example1.com/', $history->current()->getUri(), '->forward() returns the next request in the history');
|
||||
}
|
||||
}
|
53
vendor/symfony/browser-kit/Tests/RequestTest.php
vendored
53
vendor/symfony/browser-kit/Tests/RequestTest.php
vendored
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\Request;
|
||||
|
||||
class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetUri()
|
||||
{
|
||||
$request = new Request('http://www.example.com/', 'get');
|
||||
$this->assertEquals('http://www.example.com/', $request->getUri(), '->getUri() returns the URI of the request');
|
||||
}
|
||||
|
||||
public function testGetMethod()
|
||||
{
|
||||
$request = new Request('http://www.example.com/', 'get');
|
||||
$this->assertEquals('get', $request->getMethod(), '->getMethod() returns the method of the request');
|
||||
}
|
||||
|
||||
public function testGetParameters()
|
||||
{
|
||||
$request = new Request('http://www.example.com/', 'get', array('foo' => 'bar'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $request->getParameters(), '->getParameters() returns the parameters of the request');
|
||||
}
|
||||
|
||||
public function testGetFiles()
|
||||
{
|
||||
$request = new Request('http://www.example.com/', 'get', array(), array('foo' => 'bar'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $request->getFiles(), '->getFiles() returns the uploaded files of the request');
|
||||
}
|
||||
|
||||
public function testGetCookies()
|
||||
{
|
||||
$request = new Request('http://www.example.com/', 'get', array(), array(), array('foo' => 'bar'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $request->getCookies(), '->getCookies() returns the cookies of the request');
|
||||
}
|
||||
|
||||
public function testGetServer()
|
||||
{
|
||||
$request = new Request('http://www.example.com/', 'get', array(), array(), array(), array('foo' => 'bar'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $request->getServer(), '->getServer() returns the server parameters of the request');
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
|
||||
class ResponseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetUri()
|
||||
{
|
||||
$response = new Response('foo');
|
||||
$this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response');
|
||||
}
|
||||
|
||||
public function testGetStatus()
|
||||
{
|
||||
$response = new Response('foo', 304);
|
||||
$this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response');
|
||||
}
|
||||
|
||||
public function testGetHeaders()
|
||||
{
|
||||
$response = new Response('foo', 200, array('foo' => 'bar'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $response->getHeaders(), '->getHeaders() returns the headers of the response');
|
||||
}
|
||||
|
||||
public function testGetHeader()
|
||||
{
|
||||
$response = new Response('foo', 200, array(
|
||||
'Content-Type' => 'text/html',
|
||||
'Set-Cookie' => array('foo=bar', 'bar=foo'),
|
||||
));
|
||||
|
||||
$this->assertEquals('text/html', $response->getHeader('Content-Type'), '->getHeader() returns a header of the response');
|
||||
$this->assertEquals('text/html', $response->getHeader('content-type'), '->getHeader() returns a header of the response');
|
||||
$this->assertEquals('text/html', $response->getHeader('content_type'), '->getHeader() returns a header of the response');
|
||||
$this->assertEquals('foo=bar', $response->getHeader('Set-Cookie'), '->getHeader() returns the first header value');
|
||||
$this->assertEquals(array('foo=bar', 'bar=foo'), $response->getHeader('Set-Cookie', false), '->getHeader() returns all header values if first is false');
|
||||
|
||||
$this->assertNull($response->getHeader('foo'), '->getHeader() returns null if the header is not defined');
|
||||
$this->assertEquals(array(), $response->getHeader('foo', false), '->getHeader() returns an empty array if the header is not defined and first is set to false');
|
||||
}
|
||||
|
||||
public function testMagicToString()
|
||||
{
|
||||
$response = new Response('foo', 304, array('foo' => 'bar'));
|
||||
|
||||
$this->assertEquals("foo: bar\n\nfoo", $response->__toString(), '->__toString() returns the headers and the content as a string');
|
||||
}
|
||||
|
||||
public function testMagicToStringWithMultipleSetCookieHeader()
|
||||
{
|
||||
$headers = array(
|
||||
'content-type' => 'text/html; charset=utf-8',
|
||||
'set-cookie' => array('foo=bar', 'bar=foo'),
|
||||
);
|
||||
|
||||
$expected = 'content-type: text/html; charset=utf-8'."\n";
|
||||
$expected .= 'set-cookie: foo=bar'."\n";
|
||||
$expected .= 'set-cookie: bar=foo'."\n\n";
|
||||
$expected .= 'foo';
|
||||
|
||||
$response = new Response('foo', 304, $headers);
|
||||
|
||||
$this->assertEquals($expected, $response->__toString(), '->__toString() returns the headers and the content as a string');
|
||||
}
|
||||
}
|
|
@ -1,292 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/GInterface.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CInterface.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/B.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/A.php';
|
||||
|
||||
class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testTraitDependencies()
|
||||
{
|
||||
if (PHP_VERSION_ID < 50400) {
|
||||
$this->markTestSkipped('Requires PHP > 5.4');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/Fixtures/deps/traits.php';
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', array('CTFoo'));
|
||||
|
||||
$this->assertEquals(
|
||||
array('TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'),
|
||||
array_map(function ($class) { return $class->getName(); }, $ordered)
|
||||
);
|
||||
|
||||
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', array('CTBar'));
|
||||
|
||||
$this->assertEquals(
|
||||
array('TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'),
|
||||
array_map(function ($class) { return $class->getName(); }, $ordered)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDifferentOrders
|
||||
*/
|
||||
public function testClassReordering(array $classes)
|
||||
{
|
||||
$expected = array(
|
||||
'ClassesWithParents\\GInterface',
|
||||
'ClassesWithParents\\CInterface',
|
||||
'ClassesWithParents\\B',
|
||||
'ClassesWithParents\\A',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
public function getDifferentOrders()
|
||||
{
|
||||
return array(
|
||||
array(array(
|
||||
'ClassesWithParents\\A',
|
||||
'ClassesWithParents\\CInterface',
|
||||
'ClassesWithParents\\GInterface',
|
||||
'ClassesWithParents\\B',
|
||||
)),
|
||||
array(array(
|
||||
'ClassesWithParents\\B',
|
||||
'ClassesWithParents\\A',
|
||||
'ClassesWithParents\\CInterface',
|
||||
)),
|
||||
array(array(
|
||||
'ClassesWithParents\\CInterface',
|
||||
'ClassesWithParents\\B',
|
||||
'ClassesWithParents\\A',
|
||||
)),
|
||||
array(array(
|
||||
'ClassesWithParents\\A',
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDifferentOrdersForTraits
|
||||
*/
|
||||
public function testClassWithTraitsReordering(array $classes)
|
||||
{
|
||||
if (PHP_VERSION_ID < 50400) {
|
||||
$this->markTestSkipped('Requires PHP > 5.4');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/D.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/E.php';
|
||||
|
||||
$expected = array(
|
||||
'ClassesWithParents\\GInterface',
|
||||
'ClassesWithParents\\CInterface',
|
||||
'ClassesWithParents\\ATrait',
|
||||
'ClassesWithParents\\BTrait',
|
||||
'ClassesWithParents\\CTrait',
|
||||
'ClassesWithParents\\B',
|
||||
'ClassesWithParents\\A',
|
||||
'ClassesWithParents\\D',
|
||||
'ClassesWithParents\\E',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
public function getDifferentOrdersForTraits()
|
||||
{
|
||||
return array(
|
||||
array(array(
|
||||
'ClassesWithParents\\E',
|
||||
'ClassesWithParents\\ATrait',
|
||||
)),
|
||||
array(array(
|
||||
'ClassesWithParents\\E',
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
public function testFixClassWithTraitsOrdering()
|
||||
{
|
||||
if (PHP_VERSION_ID < 50400) {
|
||||
$this->markTestSkipped('Requires PHP > 5.4');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
|
||||
|
||||
$classes = array(
|
||||
'ClassesWithParents\\F',
|
||||
'ClassesWithParents\\G',
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
'ClassesWithParents\\CTrait',
|
||||
'ClassesWithParents\\F',
|
||||
'ClassesWithParents\\G',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFixNamespaceDeclarationsData
|
||||
*/
|
||||
public function testFixNamespaceDeclarations($source, $expected)
|
||||
{
|
||||
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
|
||||
}
|
||||
|
||||
public function getFixNamespaceDeclarationsData()
|
||||
{
|
||||
return array(
|
||||
array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}"),
|
||||
array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}"),
|
||||
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}"),
|
||||
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}"),
|
||||
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}"),
|
||||
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFixNamespaceDeclarationsDataWithoutTokenizer
|
||||
*/
|
||||
public function testFixNamespaceDeclarationsWithoutTokenizer($source, $expected)
|
||||
{
|
||||
ClassCollectionLoader::enableTokenizer(false);
|
||||
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
|
||||
ClassCollectionLoader::enableTokenizer(true);
|
||||
}
|
||||
|
||||
public function getFixNamespaceDeclarationsDataWithoutTokenizer()
|
||||
{
|
||||
return array(
|
||||
array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"),
|
||||
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}\n"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUnableToLoadClassException()
|
||||
{
|
||||
if (is_file($file = sys_get_temp_dir().'/foo.php')) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
ClassCollectionLoader::load(array('SomeNotExistingClass'), sys_get_temp_dir(), 'foo', false);
|
||||
}
|
||||
|
||||
public function testCommentStripping()
|
||||
{
|
||||
if (is_file($file = sys_get_temp_dir().'/bar.php')) {
|
||||
unlink($file);
|
||||
}
|
||||
spl_autoload_register($r = function ($class) {
|
||||
if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) {
|
||||
require_once __DIR__.'/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.php';
|
||||
}
|
||||
});
|
||||
|
||||
ClassCollectionLoader::load(
|
||||
array('Namespaced\\WithComments', 'Pearlike_WithComments'),
|
||||
sys_get_temp_dir(),
|
||||
'bar',
|
||||
false
|
||||
);
|
||||
|
||||
spl_autoload_unregister($r);
|
||||
|
||||
$this->assertEquals(<<<EOF
|
||||
namespace Namespaced
|
||||
{
|
||||
class WithComments
|
||||
{
|
||||
public static \$loaded = true;
|
||||
}
|
||||
\$string ='string should not be modified {\$string}';
|
||||
\$heredoc = (<<<HD
|
||||
|
||||
|
||||
Heredoc should not be modified {\$string}
|
||||
|
||||
|
||||
HD
|
||||
);
|
||||
\$nowdoc =<<<'ND'
|
||||
|
||||
|
||||
Nowdoc should not be modified {\$string}
|
||||
|
||||
|
||||
ND
|
||||
;
|
||||
}
|
||||
namespace
|
||||
{
|
||||
class Pearlike_WithComments
|
||||
{
|
||||
public static \$loaded = true;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
, str_replace("<?php \n", '', file_get_contents($file)));
|
||||
|
||||
unlink($file);
|
||||
}
|
||||
}
|
|
@ -1,212 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
|
||||
class ClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetPrefixes()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertArrayNotHasKey('Foo1', $prefixes);
|
||||
$this->assertArrayHasKey('Bar', $prefixes);
|
||||
$this->assertArrayHasKey('Bas', $prefixes);
|
||||
}
|
||||
|
||||
public function testGetFallbackDirs()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$fallback_dirs = $loader->getFallbackDirs();
|
||||
$this->assertCount(2, $fallback_dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassTests
|
||||
*/
|
||||
public function testLoadClass($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->loadClass($testClassName);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Namespaced2\\Foo', 'Namespaced2\\Foo', '->loadClass() loads Namespaced2\Foo class'),
|
||||
array('\\Pearlike2_Foo', 'Pearlike2_Foo', '->loadClass() loads Pearlike2_Foo class'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadNonexistentClassTests
|
||||
*/
|
||||
public function testLoadNonexistentClass($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->loadClass($testClassName);
|
||||
$this->assertFalse(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadNonexistentClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testAddPrefix()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertCount(2, $prefixes['Foo']);
|
||||
}
|
||||
|
||||
public function testUseIncludePath()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$this->assertFalse($loader->getUseIncludePath());
|
||||
|
||||
$this->assertNull($loader->findFile('Foo'));
|
||||
|
||||
$includePath = get_include_path();
|
||||
|
||||
$loader->setUseIncludePath(true);
|
||||
$this->assertTrue($loader->getUseIncludePath());
|
||||
|
||||
set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath);
|
||||
|
||||
$this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'includepath'.DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
|
||||
|
||||
set_include_path($includePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassFromFallbackTests
|
||||
*/
|
||||
public function testLoadClassFromFallback($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix('', array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'));
|
||||
$loader->loadClass($testClassName);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassFromFallbackTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Namespaced2\\Baz', 'Namespaced2\\Baz', '->loadClass() loads Namespaced2\Baz class'),
|
||||
array('\\Pearlike2_Baz', 'Pearlike2_Baz', '->loadClass() loads Pearlike2_Baz class'),
|
||||
array('\\Namespaced2\\FooBar', 'Namespaced2\\FooBar', '->loadClass() loads Namespaced2\Baz class from fallback dir'),
|
||||
array('\\Pearlike2_FooBar', 'Pearlike2_FooBar', '->loadClass() loads Pearlike2_Baz class from fallback dir'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassNamespaceCollisionTests
|
||||
*/
|
||||
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefixes($namespaces);
|
||||
|
||||
$loader->loadClass($className);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassNamespaceCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'NamespaceCollision\C\Foo',
|
||||
'->loadClass() loads NamespaceCollision\C\Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'NamespaceCollision\C\Bar',
|
||||
'->loadClass() loads NamespaceCollision\C\Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'NamespaceCollision\C\B\Foo',
|
||||
'->loadClass() loads NamespaceCollision\C\B\Foo from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'NamespaceCollision\C\B\Bar',
|
||||
'->loadClass() loads NamespaceCollision\C\B\Bar from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'PrefixCollision_C_Foo',
|
||||
'->loadClass() loads PrefixCollision_C_Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'PrefixCollision_C_Bar',
|
||||
'->loadClass() loads PrefixCollision_C_Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'PrefixCollision_C_B_Foo',
|
||||
'->loadClass() loads PrefixCollision_C_B_Foo from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'PrefixCollision_C_B_Bar',
|
||||
'->loadClass() loads PrefixCollision_C_B_Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
||||
|
||||
class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $workspace = null;
|
||||
|
||||
public function prepare_workspace()
|
||||
{
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
|
||||
mkdir($this->workspace, 0777, true);
|
||||
$this->workspace = realpath($this->workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
*/
|
||||
private function clean($file)
|
||||
{
|
||||
if (is_dir($file) && !is_link($file)) {
|
||||
$dir = new \FilesystemIterator($file);
|
||||
foreach ($dir as $childFile) {
|
||||
$this->clean($childFile);
|
||||
}
|
||||
|
||||
rmdir($file);
|
||||
} else {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestCreateMapTests
|
||||
*/
|
||||
public function testDump($directory)
|
||||
{
|
||||
$this->prepare_workspace();
|
||||
|
||||
$file = $this->workspace.'/file';
|
||||
|
||||
$generator = new ClassMapGenerator();
|
||||
$generator->dump($directory, $file);
|
||||
$this->assertFileExists($file);
|
||||
|
||||
$this->clean($this->workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestCreateMapTests
|
||||
*/
|
||||
public function testCreateMap($directory, $expected)
|
||||
{
|
||||
$this->assertEqualsNormalized($expected, ClassMapGenerator::createMap($directory));
|
||||
}
|
||||
|
||||
public function getTestCreateMapTests()
|
||||
{
|
||||
$data = array(
|
||||
array(__DIR__.'/Fixtures/Namespaced', array(
|
||||
'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php',
|
||||
'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
|
||||
'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
|
||||
'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php',
|
||||
),
|
||||
),
|
||||
array(__DIR__.'/Fixtures/beta/NamespaceCollision', array(
|
||||
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
|
||||
'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php',
|
||||
'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php',
|
||||
'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php',
|
||||
)),
|
||||
array(__DIR__.'/Fixtures/Pearlike', array(
|
||||
'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php',
|
||||
'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php',
|
||||
'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php',
|
||||
'Pearlike_WithComments' => realpath(__DIR__).'/Fixtures/Pearlike/WithComments.php',
|
||||
)),
|
||||
array(__DIR__.'/Fixtures/classmap', array(
|
||||
'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
|
||||
'Foo\\Bar\\B' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
|
||||
'A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'ClassMap\\SomeInterface' => realpath(__DIR__).'/Fixtures/classmap/SomeInterface.php',
|
||||
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
|
||||
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
|
||||
)),
|
||||
);
|
||||
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
|
||||
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||
));
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$data[] = array(__DIR__.'/Fixtures/php5.5', array(
|
||||
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
|
||||
));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testCreateMapFinderSupport()
|
||||
{
|
||||
$finder = new \Symfony\Component\Finder\Finder();
|
||||
$finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision');
|
||||
|
||||
$this->assertEqualsNormalized(array(
|
||||
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
|
||||
'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php',
|
||||
'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php',
|
||||
'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php',
|
||||
), ClassMapGenerator::createMap($finder));
|
||||
}
|
||||
|
||||
protected function assertEqualsNormalized($expected, $actual, $message = null)
|
||||
{
|
||||
foreach ($expected as $ns => $path) {
|
||||
$expected[$ns] = str_replace('\\', '/', $path);
|
||||
}
|
||||
foreach ($actual as $ns => $path) {
|
||||
$actual[$ns] = str_replace('\\', '/', $path);
|
||||
}
|
||||
$this->assertEquals($expected, $actual, $message);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class A extends B
|
||||
{
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait ATrait
|
||||
{
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class B implements CInterface
|
||||
{
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait BTrait
|
||||
{
|
||||
use ATrait;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
interface CInterface extends GInterface
|
||||
{
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait CTrait
|
||||
{
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class D extends A
|
||||
{
|
||||
use BTrait;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class E extends D
|
||||
{
|
||||
use CTrait;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class F
|
||||
{
|
||||
use CTrait;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class G
|
||||
{
|
||||
use CTrait;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
interface GInterface
|
||||
{
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class WithComments
|
||||
{
|
||||
/** @Boolean */
|
||||
public static $loaded = true;
|
||||
}
|
||||
|
||||
$string = 'string should not be modified {$string}';
|
||||
|
||||
$heredoc = (<<<HD
|
||||
|
||||
|
||||
Heredoc should not be modified {$string}
|
||||
|
||||
|
||||
HD
|
||||
);
|
||||
|
||||
$nowdoc = <<<'ND'
|
||||
|
||||
|
||||
Nowdoc should not be modified {$string}
|
||||
|
||||
|
||||
ND;
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class Pearlike_WithComments
|
||||
{
|
||||
/** @Boolean */
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace ClassMap;
|
||||
|
||||
class SomeClass extends SomeParent implements SomeInterface
|
||||
{
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace ClassMap;
|
||||
|
||||
interface SomeInterface
|
||||
{
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace ClassMap;
|
||||
|
||||
abstract class SomeParent
|
||||
{
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace {
|
||||
class A
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Alpha {
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beta {
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
|
||||
$a = new stdClass();
|
|
@ -1 +0,0 @@
|
|||
This file should be skipped.
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Foo\Bar;
|
||||
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
trait TD
|
||||
{
|
||||
}
|
||||
|
||||
trait TZ
|
||||
{
|
||||
use TD;
|
||||
}
|
||||
|
||||
trait TC
|
||||
{
|
||||
use TD;
|
||||
}
|
||||
|
||||
trait TB
|
||||
{
|
||||
use TC;
|
||||
}
|
||||
|
||||
trait TA
|
||||
{
|
||||
use TB;
|
||||
}
|
||||
|
||||
class CTFoo
|
||||
{
|
||||
use TA;
|
||||
use TZ;
|
||||
}
|
||||
|
||||
class CTBar
|
||||
{
|
||||
use TZ;
|
||||
use TA;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace {
|
||||
trait TFoo
|
||||
{
|
||||
}
|
||||
|
||||
class CFoo
|
||||
{
|
||||
use TFoo;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Foo {
|
||||
trait TBar
|
||||
{
|
||||
}
|
||||
|
||||
interface IBar
|
||||
{
|
||||
}
|
||||
|
||||
trait TFooBar
|
||||
{
|
||||
}
|
||||
|
||||
class CBar implements IBar
|
||||
{
|
||||
use TBar;
|
||||
use TFooBar;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ClassCons;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
\Foo\TBar/* foo */::class;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Acme\DemoLib;
|
||||
|
||||
class Class_With_Underscores
|
||||
{
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Acme\DemoLib;
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Acme\DemoLib\Lets\Go\Deeper;
|
||||
|
||||
class Class_With_Underscores
|
||||
{
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Acme\DemoLib\Lets\Go\Deeper;
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
$this->markTestSkipped('The apc extension is not available.');
|
||||
}
|
||||
|
||||
if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
|
||||
$this->markTestSkipped('The apc extension is available, but not enabled.');
|
||||
} else {
|
||||
apc_clear_cache('user');
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
apc_clear_cache('user');
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.');
|
||||
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
|
||||
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apc_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassTests
|
||||
*/
|
||||
public function testLoadClass($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.');
|
||||
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->loadClass($testClassName);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'),
|
||||
array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassFromFallbackTests
|
||||
*/
|
||||
public function testLoadClassFromFallback($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.fallback');
|
||||
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerNamespaceFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback'));
|
||||
$loader->registerPrefixFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback'));
|
||||
$loader->loadClass($testClassName);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassFromFallbackTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'),
|
||||
array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'),
|
||||
array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'),
|
||||
array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassNamespaceCollisionTests
|
||||
*/
|
||||
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
|
||||
{
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.collision.');
|
||||
$loader->registerNamespaces($namespaces);
|
||||
|
||||
$loader->loadClass($className);
|
||||
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassNamespaceCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
),
|
||||
'Apc\NamespaceCollision\A\Foo',
|
||||
'->loadClass() loads NamespaceCollision\A\Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
),
|
||||
'Apc\NamespaceCollision\A\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
),
|
||||
'Apc\NamespaceCollision\A\B\Foo',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Foo from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
|
||||
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
|
||||
),
|
||||
'Apc\NamespaceCollision\A\B\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassPrefixCollisionTests
|
||||
*/
|
||||
public function testLoadClassPrefixCollision($prefixes, $className, $message)
|
||||
{
|
||||
$loader = new ApcUniversalClassLoader('test.prefix.collision.');
|
||||
$loader->registerPrefixes($prefixes);
|
||||
|
||||
$loader->loadClass($className);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassPrefixCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
|
||||
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
|
||||
),
|
||||
'ApcPrefixCollision_A_Foo',
|
||||
'->loadClass() loads ApcPrefixCollision_A_Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
|
||||
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
|
||||
),
|
||||
'ApcPrefixCollision_A_Bar',
|
||||
'->loadClass() loads ApcPrefixCollision_A_Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
|
||||
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
|
||||
),
|
||||
'ApcPrefixCollision_A_B_Foo',
|
||||
'->loadClass() loads ApcPrefixCollision_A_B_Foo from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
|
||||
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
|
||||
),
|
||||
'ApcPrefixCollision_A_B_Bar',
|
||||
'->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,223 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getLoadClassTests
|
||||
*/
|
||||
public function testLoadClass($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerNamespace('Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerPrefix('Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$this->assertTrue($loader->loadClass($testClassName));
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Namespaced\\Foo', 'Namespaced\\Foo', '->loadClass() loads Namespaced\Foo class'),
|
||||
array('\\Pearlike_Foo', 'Pearlike_Foo', '->loadClass() loads Pearlike_Foo class'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testUseIncludePath()
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$this->assertFalse($loader->getUseIncludePath());
|
||||
|
||||
$this->assertNull($loader->findFile('Foo'));
|
||||
|
||||
$includePath = get_include_path();
|
||||
|
||||
$loader->useIncludePath(true);
|
||||
$this->assertTrue($loader->getUseIncludePath());
|
||||
|
||||
set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath);
|
||||
|
||||
$this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'includepath'.DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
|
||||
|
||||
set_include_path($includePath);
|
||||
}
|
||||
|
||||
public function testGetNamespaces()
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerNamespace('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerNamespace('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerNamespace('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$namespaces = $loader->getNamespaces();
|
||||
$this->assertArrayHasKey('Foo', $namespaces);
|
||||
$this->assertArrayNotHasKey('Foo1', $namespaces);
|
||||
$this->assertArrayHasKey('Bar', $namespaces);
|
||||
$this->assertArrayHasKey('Bas', $namespaces);
|
||||
}
|
||||
|
||||
public function testGetPrefixes()
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerPrefix('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerPrefix('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertArrayNotHasKey('Foo1', $prefixes);
|
||||
$this->assertArrayHasKey('Bar', $prefixes);
|
||||
$this->assertArrayHasKey('Bas', $prefixes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassFromFallbackTests
|
||||
*/
|
||||
public function testLoadClassFromFallback($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerNamespace('Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerPrefix('Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->registerNamespaceFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'));
|
||||
$loader->registerPrefixFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'));
|
||||
$this->assertTrue($loader->loadClass($testClassName));
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassFromFallbackTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Namespaced\\Baz', 'Namespaced\\Baz', '->loadClass() loads Namespaced\Baz class'),
|
||||
array('\\Pearlike_Baz', 'Pearlike_Baz', '->loadClass() loads Pearlike_Baz class'),
|
||||
array('\\Namespaced\\FooBar', 'Namespaced\\FooBar', '->loadClass() loads Namespaced\Baz class from fallback dir'),
|
||||
array('\\Pearlike_FooBar', 'Pearlike_FooBar', '->loadClass() loads Pearlike_Baz class from fallback dir'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testRegisterPrefixFallback()
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerPrefixFallback(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback');
|
||||
$this->assertEquals(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'), $loader->getPrefixFallbacks());
|
||||
}
|
||||
|
||||
public function testRegisterNamespaceFallback()
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerNamespaceFallback(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Namespaced/fallback');
|
||||
$this->assertEquals(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Namespaced/fallback'), $loader->getNamespaceFallbacks());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassNamespaceCollisionTests
|
||||
*/
|
||||
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerNamespaces($namespaces);
|
||||
|
||||
$this->assertTrue($loader->loadClass($className));
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassNamespaceCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'NamespaceCollision\A\Foo',
|
||||
'->loadClass() loads NamespaceCollision\A\Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'NamespaceCollision\A\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'NamespaceCollision\A\B\Foo',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Foo from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'NamespaceCollision\A\B\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassPrefixCollisionTests
|
||||
*/
|
||||
public function testLoadClassPrefixCollision($prefixes, $className, $message)
|
||||
{
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerPrefixes($prefixes);
|
||||
|
||||
$this->assertTrue($loader->loadClass($className));
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassPrefixCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'PrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'PrefixCollision_A_Foo',
|
||||
'->loadClass() loads PrefixCollision_A_Foo from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'PrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'PrefixCollision_A_Bar',
|
||||
'->loadClass() loads PrefixCollision_A_Bar from alpha.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
'PrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
),
|
||||
'PrefixCollision_A_B_Foo',
|
||||
'->loadClass() loads PrefixCollision_A_B_Foo from beta.',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'PrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
|
||||
'PrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
|
||||
),
|
||||
'PrefixCollision_A_B_Bar',
|
||||
'->loadClass() loads PrefixCollision_A_B_Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\Psr4ClassLoader;
|
||||
|
||||
class Psr4ClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $className
|
||||
* @dataProvider getLoadClassTests
|
||||
*/
|
||||
public function testLoadClass($className)
|
||||
{
|
||||
$loader = new Psr4ClassLoader();
|
||||
$loader->addPrefix(
|
||||
'Acme\\DemoLib',
|
||||
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
|
||||
);
|
||||
$loader->loadClass($className);
|
||||
$this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLoadClassTests()
|
||||
{
|
||||
return array(
|
||||
array('Acme\\DemoLib\\Foo'),
|
||||
array('Acme\\DemoLib\\Class_With_Underscores'),
|
||||
array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'),
|
||||
array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @dataProvider getLoadNonexistentClassTests
|
||||
*/
|
||||
public function testLoadNonexistentClass($className)
|
||||
{
|
||||
$loader = new Psr4ClassLoader();
|
||||
$loader->addPrefix(
|
||||
'Acme\\DemoLib',
|
||||
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
|
||||
);
|
||||
$loader->loadClass($className);
|
||||
$this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLoadNonexistentClassTests()
|
||||
{
|
||||
return array(
|
||||
array('Acme\\DemoLib\\I_Do_Not_Exist'),
|
||||
array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'),
|
||||
);
|
||||
}
|
||||
}
|
BIN
vendor/symfony/console/Resources/bin/hiddeninput.exe
vendored
BIN
vendor/symfony/console/Resources/bin/hiddeninput.exe
vendored
Binary file not shown.
1060
vendor/symfony/console/Tests/ApplicationTest.php
vendored
1060
vendor/symfony/console/Tests/ApplicationTest.php
vendored
File diff suppressed because it is too large
Load diff
41
vendor/symfony/console/Tests/ClockMock.php
vendored
41
vendor/symfony/console/Tests/ClockMock.php
vendored
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Tests;
|
||||
|
||||
function time()
|
||||
{
|
||||
return Tests\time();
|
||||
}
|
||||
|
||||
namespace Symfony\Component\Console\Tests;
|
||||
|
||||
function with_clock_mock($enable = null)
|
||||
{
|
||||
static $enabled;
|
||||
|
||||
if (null === $enable) {
|
||||
return $enabled;
|
||||
}
|
||||
|
||||
$enabled = $enable;
|
||||
}
|
||||
|
||||
function time()
|
||||
{
|
||||
if (!with_clock_mock()) {
|
||||
return \time();
|
||||
}
|
||||
|
||||
return $_SERVER['REQUEST_TIME'];
|
||||
}
|
337
vendor/symfony/console/Tests/Command/CommandTest.php
vendored
337
vendor/symfony/console/Tests/Command/CommandTest.php
vendored
|
@ -1,337 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class CommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = __DIR__.'/../Fixtures/';
|
||||
require_once self::$fixturesPath.'/TestCommand.php';
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$command = new Command('foo:bar');
|
||||
$this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.
|
||||
*/
|
||||
public function testCommandNameCannotBeEmpty()
|
||||
{
|
||||
new Command();
|
||||
}
|
||||
|
||||
public function testSetApplication()
|
||||
{
|
||||
$application = new Application();
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication($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($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');
|
||||
$command->setDefinition(new InputDefinition());
|
||||
}
|
||||
|
||||
public function testAddArgument()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->addArgument('foo');
|
||||
$this->assertEquals($command, $ret, '->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($command, $ret, '->addOption() implements a fluent interface');
|
||||
$this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command');
|
||||
}
|
||||
|
||||
public function testGetNamespaceGetNameSetName()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals('namespace:name', $command->getName(), '->getName() returns the command name');
|
||||
$command->setName('foo');
|
||||
$this->assertEquals('foo', $command->getName(), '->setName() sets the command name');
|
||||
|
||||
$ret = $command->setName('foobar:bar');
|
||||
$this->assertEquals($command, $ret, '->setName() implements a fluent interface');
|
||||
$this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidCommandNames
|
||||
*/
|
||||
public function testInvalidCommandNames($name)
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setName($name);
|
||||
}
|
||||
|
||||
public function provideInvalidCommandNames()
|
||||
{
|
||||
return array(
|
||||
array(''),
|
||||
array('foo:'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetSetDescription()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals('description', $command->getDescription(), '->getDescription() returns the description');
|
||||
$ret = $command->setDescription('description1');
|
||||
$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('help', $command->getHelp(), '->getHelp() returns the help');
|
||||
$ret = $command->setHelp('help1');
|
||||
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
|
||||
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
|
||||
$command->setHelp('');
|
||||
$this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description');
|
||||
}
|
||||
|
||||
public function testGetProcessedHelp()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
|
||||
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly');
|
||||
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%');
|
||||
}
|
||||
|
||||
public function testGetSetAliases()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals(array('name'), $command->getAliases(), '->getAliases() returns the aliases');
|
||||
$ret = $command->setAliases(array('name1'));
|
||||
$this->assertEquals($command, $ret, '->setAliases() implements a fluent interface');
|
||||
$this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases');
|
||||
}
|
||||
|
||||
public function testGetSynopsis()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->addOption('foo');
|
||||
$command->addArgument('bar');
|
||||
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
|
||||
}
|
||||
|
||||
public function testGetHelper()
|
||||
{
|
||||
$application = new Application();
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication($application);
|
||||
$formatterHelper = new FormatterHelper();
|
||||
$this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper');
|
||||
}
|
||||
|
||||
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'))));
|
||||
|
||||
$r = new \ReflectionObject($command);
|
||||
$m = $r->getMethod('mergeApplicationDefinition');
|
||||
$m->setAccessible(true);
|
||||
$m->invoke($command);
|
||||
$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');
|
||||
|
||||
$m->invoke($command);
|
||||
$this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options');
|
||||
}
|
||||
|
||||
public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs()
|
||||
{
|
||||
$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()));
|
||||
|
||||
$r = new \ReflectionObject($command);
|
||||
$m = $r->getMethod('mergeApplicationDefinition');
|
||||
$m->setAccessible(true);
|
||||
$m->invoke($command, false);
|
||||
$this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition(false) merges the application and the command options');
|
||||
$this->assertFalse($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(false) does not merge the application arguments');
|
||||
|
||||
$m->invoke($command, true);
|
||||
$this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(true) merges the application arguments and the command arguments');
|
||||
|
||||
$m->invoke($command);
|
||||
$this->assertEquals(2, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments');
|
||||
}
|
||||
|
||||
public function testRunInteractive()
|
||||
{
|
||||
$tester = new CommandTester(new \TestCommand());
|
||||
|
||||
$tester->execute(array(), array('interactive' => true));
|
||||
|
||||
$this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive');
|
||||
}
|
||||
|
||||
public function testRunNonInteractive()
|
||||
{
|
||||
$tester = new CommandTester(new \TestCommand());
|
||||
|
||||
$tester->execute(array(), array('interactive' => false));
|
||||
|
||||
$this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage You must override the execute() method in the concrete command class.
|
||||
*/
|
||||
public function testExecuteMethodNeedsToBeOverridden()
|
||||
{
|
||||
$command = new Command('foo');
|
||||
$command->run(new StringInput(''), new NullOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The "--bar" option does not exist.
|
||||
*/
|
||||
public function testRunWithInvalidOption()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array('--bar' => true));
|
||||
}
|
||||
|
||||
public function testRunReturnsIntegerExitCode()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$exitCode = $command->run(new StringInput(''), new NullOutput());
|
||||
$this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)');
|
||||
|
||||
$command = $this->getMock('TestCommand', array('execute'));
|
||||
$command->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue('2.3'));
|
||||
$exitCode = $command->run(new StringInput(''), new NullOutput());
|
||||
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
|
||||
}
|
||||
|
||||
public function testRunReturnsAlwaysInteger()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
|
||||
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
|
||||
}
|
||||
|
||||
public function testSetCode()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
$output->writeln('from the code...');
|
||||
});
|
||||
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array());
|
||||
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testSetCodeWithNonClosureCallable()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->setCode(array($this, 'callableMethodCommand'));
|
||||
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array());
|
||||
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Invalid callable provided to Command::setCode.
|
||||
*/
|
||||
public function testSetCodeWithNonCallable()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setCode(array($this, 'nonExistentMethod'));
|
||||
}
|
||||
|
||||
public function callableMethodCommand(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('from the code...');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array('command' => $command->getName()));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/command_astext.txt', $command->asText(), '->asText() returns a text representation of the command');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array('command' => $command->getName()));
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command');
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Console\Command\HelpCommand;
|
||||
use Symfony\Component\Console\Command\ListCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
class HelpCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testExecuteForCommandAlias()
|
||||
{
|
||||
$command = new HelpCommand();
|
||||
$command->setApplication(new Application());
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(array('command_name' => 'li'), array('decorated' => false));
|
||||
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||
}
|
||||
|
||||
public function testExecuteForCommand()
|
||||
{
|
||||
$command = new HelpCommand();
|
||||
$commandTester = new CommandTester($command);
|
||||
$command->setCommand(new ListCommand());
|
||||
$commandTester->execute(array(), array('decorated' => false));
|
||||
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
}
|
||||
|
||||
public function testExecuteForCommandWithXmlOption()
|
||||
{
|
||||
$command = new HelpCommand();
|
||||
$commandTester = new CommandTester($command);
|
||||
$command->setCommand(new ListCommand());
|
||||
$commandTester->execute(array('--format' => 'xml'));
|
||||
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
|
||||
}
|
||||
|
||||
public function testExecuteForApplicationCommand()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($application->get('help'));
|
||||
$commandTester->execute(array('command_name' => 'list'));
|
||||
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
}
|
||||
|
||||
public function testExecuteForApplicationCommandWithXmlOption()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($application->get('help'));
|
||||
$commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
|
||||
$this->assertContains('list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
class ListCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testExecuteListsCommands()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
|
||||
|
||||
$this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsWithXmlOption()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(array('command' => $command->getName(), '--format' => 'xml'));
|
||||
$this->assertRegExp('/<command id="list" name="list">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsWithRawOption()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(array('command' => $command->getName(), '--raw' => true));
|
||||
$output = <<<EOF
|
||||
help Displays help for a command
|
||||
list Lists commands
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($output, $commandTester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsWithNamespaceArgument()
|
||||
{
|
||||
require_once realpath(__DIR__.'/../Fixtures/FooCommand.php');
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true));
|
||||
$output = <<<EOF
|
||||
foo:bar The foo:bar command
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($output, $commandTester->getDisplay(true));
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @dataProvider getDescribeInputArgumentTestData */
|
||||
public function testDescribeInputArgument(InputArgument $argument, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $argument);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeInputOptionTestData */
|
||||
public function testDescribeInputOption(InputOption $option, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $option);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeInputDefinitionTestData */
|
||||
public function testDescribeInputDefinition(InputDefinition $definition, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $definition);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeCommandTestData */
|
||||
public function testDescribeCommand(Command $command, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $command);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeApplicationTestData */
|
||||
public function testDescribeApplication(Application $application, $expectedDescription)
|
||||
{
|
||||
// Replaces the dynamic placeholders of the command help text with a static version.
|
||||
// The placeholder %command.full_name% includes the script path that is not predictable
|
||||
// and can not be tested against.
|
||||
foreach ($application->all() as $command) {
|
||||
$command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
|
||||
}
|
||||
|
||||
$this->assertDescription($expectedDescription, $application);
|
||||
}
|
||||
|
||||
public function getDescribeInputArgumentTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputArguments());
|
||||
}
|
||||
|
||||
public function getDescribeInputOptionTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputOptions());
|
||||
}
|
||||
|
||||
public function getDescribeInputDefinitionTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions());
|
||||
}
|
||||
|
||||
public function getDescribeCommandTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getCommands());
|
||||
}
|
||||
|
||||
public function getDescribeApplicationTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getApplications());
|
||||
}
|
||||
|
||||
abstract protected function getDescriptor();
|
||||
abstract protected function getFormat();
|
||||
|
||||
private function getDescriptionTestData(array $objects)
|
||||
{
|
||||
$data = array();
|
||||
foreach ($objects as $name => $object) {
|
||||
$description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this->getFormat()));
|
||||
$data[] = array($object, $description);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function assertDescription($expectedDescription, $describedObject)
|
||||
{
|
||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));
|
||||
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\JsonDescriptor;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class JsonDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new JsonDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'json';
|
||||
}
|
||||
|
||||
protected function assertDescription($expectedDescription, $describedObject)
|
||||
{
|
||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));
|
||||
$this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true));
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
|
||||
|
||||
class MarkdownDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new MarkdownDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'md';
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication1;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication2;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand1;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand2;
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
class ObjectsProvider
|
||||
{
|
||||
public static function getInputArguments()
|
||||
{
|
||||
return array(
|
||||
'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED),
|
||||
'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'),
|
||||
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
|
||||
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getInputOptions()
|
||||
{
|
||||
return array(
|
||||
'input_option_1' => new InputOption('option_name', 'o', InputOption::VALUE_NONE),
|
||||
'input_option_2' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', 'default_value'),
|
||||
'input_option_3' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description'),
|
||||
'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', array()),
|
||||
'input_option_5' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, "multiline\noption description"),
|
||||
'input_option_6' => new InputOption('option_name', array('o', 'O'), InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getInputDefinitions()
|
||||
{
|
||||
return array(
|
||||
'input_definition_1' => new InputDefinition(),
|
||||
'input_definition_2' => new InputDefinition(array(new InputArgument('argument_name', InputArgument::REQUIRED))),
|
||||
'input_definition_3' => new InputDefinition(array(new InputOption('option_name', 'o', InputOption::VALUE_NONE))),
|
||||
'input_definition_4' => new InputDefinition(array(
|
||||
new InputArgument('argument_name', InputArgument::REQUIRED),
|
||||
new InputOption('option_name', 'o', InputOption::VALUE_NONE),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getCommands()
|
||||
{
|
||||
return array(
|
||||
'command_1' => new DescriptorCommand1(),
|
||||
'command_2' => new DescriptorCommand2(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getApplications()
|
||||
{
|
||||
return array(
|
||||
'application_1' => new DescriptorApplication1(),
|
||||
'application_2' => new DescriptorApplication2(),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor;
|
||||
|
||||
class TextDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new TextDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'txt';
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue