Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
3
vendor/symfony/browser-kit/.gitignore
vendored
Normal file
3
vendor/symfony/browser-kit/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
18
vendor/symfony/browser-kit/CHANGELOG.md
vendored
Normal file
18
vendor/symfony/browser-kit/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* [BC BREAK] `Client::followRedirect()` won't redirect responses with
|
||||
a non-3xx Status Code and `Location` header anymore, as per
|
||||
http://tools.ietf.org/html/rfc2616#section-14.30
|
||||
|
||||
* added `Client::getInternalRequest()` and `Client::getInternalResponse()` to
|
||||
have access to the BrowserKit internal request and response objects
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* [BC BREAK] The CookieJar internals have changed to allow cookies with the
|
||||
same name on different sub-domains/sub-paths
|
619
vendor/symfony/browser-kit/Client.php
vendored
Normal file
619
vendor/symfony/browser-kit/Client.php
vendored
Normal file
|
@ -0,0 +1,619 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Component\DomCrawler\Link;
|
||||
use Symfony\Component\DomCrawler\Form;
|
||||
use Symfony\Component\Process\PhpProcess;
|
||||
|
||||
/**
|
||||
* Client simulates a browser.
|
||||
*
|
||||
* To make the actual request, you need to implement the doRequest() method.
|
||||
*
|
||||
* If you want to be able to run requests in their own process (insulated flag),
|
||||
* you need to also implement the getScript() method.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
abstract class Client
|
||||
{
|
||||
protected $history;
|
||||
protected $cookieJar;
|
||||
protected $server = array();
|
||||
protected $internalRequest;
|
||||
protected $request;
|
||||
protected $internalResponse;
|
||||
protected $response;
|
||||
protected $crawler;
|
||||
protected $insulated = false;
|
||||
protected $redirect;
|
||||
protected $followRedirects = true;
|
||||
|
||||
private $maxRedirects = -1;
|
||||
private $redirectCount = 0;
|
||||
private $isMainRequest = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $server The server parameters (equivalent of $_SERVER)
|
||||
* @param History $history A History instance to store the browser history
|
||||
* @param CookieJar $cookieJar A CookieJar instance to store the cookies
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null)
|
||||
{
|
||||
$this->setServerParameters($server);
|
||||
$this->history = $history ?: new History();
|
||||
$this->cookieJar = $cookieJar ?: new CookieJar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to automatically follow redirects or not.
|
||||
*
|
||||
* @param bool $followRedirect Whether to follow redirects
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function followRedirects($followRedirect = true)
|
||||
{
|
||||
$this->followRedirects = (bool) $followRedirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of requests that crawler can follow.
|
||||
*
|
||||
* @param int $maxRedirects
|
||||
*/
|
||||
public function setMaxRedirects($maxRedirects)
|
||||
{
|
||||
$this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects;
|
||||
$this->followRedirects = -1 != $this->maxRedirects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the insulated flag.
|
||||
*
|
||||
* @param bool $insulated Whether to insulate the requests or not
|
||||
*
|
||||
* @throws \RuntimeException When Symfony Process Component is not installed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function insulate($insulated = true)
|
||||
{
|
||||
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) {
|
||||
throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.');
|
||||
}
|
||||
|
||||
$this->insulated = (bool) $insulated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets server parameters.
|
||||
*
|
||||
* @param array $server An array of server parameters
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setServerParameters(array $server)
|
||||
{
|
||||
$this->server = array_merge(array(
|
||||
'HTTP_HOST' => 'localhost',
|
||||
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
|
||||
), $server);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets single server parameter.
|
||||
*
|
||||
* @param string $key A key of the parameter
|
||||
* @param string $value A value of the parameter
|
||||
*/
|
||||
public function setServerParameter($key, $value)
|
||||
{
|
||||
$this->server[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets single server parameter for specified key.
|
||||
*
|
||||
* @param string $key A key of the parameter to get
|
||||
* @param string $default A default value when key is undefined
|
||||
*
|
||||
* @return string A value of the parameter
|
||||
*/
|
||||
public function getServerParameter($key, $default = '')
|
||||
{
|
||||
return (isset($this->server[$key])) ? $this->server[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the History instance.
|
||||
*
|
||||
* @return History A History instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getHistory()
|
||||
{
|
||||
return $this->history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CookieJar instance.
|
||||
*
|
||||
* @return CookieJar A CookieJar instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCookieJar()
|
||||
{
|
||||
return $this->cookieJar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current Crawler instance.
|
||||
*
|
||||
* @return Crawler|null A Crawler instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCrawler()
|
||||
{
|
||||
return $this->crawler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current BrowserKit Response instance.
|
||||
*
|
||||
* @return Response|null A BrowserKit Response instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getInternalResponse()
|
||||
{
|
||||
return $this->internalResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current origin response instance.
|
||||
*
|
||||
* The origin response is the response instance that is returned
|
||||
* by the code that handles requests.
|
||||
*
|
||||
* @return object|null A response instance
|
||||
*
|
||||
* @see doRequest()
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current BrowserKit Request instance.
|
||||
*
|
||||
* @return Request|null A BrowserKit Request instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getInternalRequest()
|
||||
{
|
||||
return $this->internalRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current origin Request instance.
|
||||
*
|
||||
* The origin request is the request instance that is sent
|
||||
* to the code that handles requests.
|
||||
*
|
||||
* @return object|null A Request instance
|
||||
*
|
||||
* @see doRequest()
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks on a given link.
|
||||
*
|
||||
* @param Link $link A Link instance
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function click(Link $link)
|
||||
{
|
||||
if ($link instanceof Form) {
|
||||
return $this->submit($link);
|
||||
}
|
||||
|
||||
return $this->request($link->getMethod(), $link->getUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits a form.
|
||||
*
|
||||
* @param Form $form A Form instance
|
||||
* @param array $values An array of form field values
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function submit(Form $form, array $values = array())
|
||||
{
|
||||
$form->setValues($values);
|
||||
|
||||
return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a URI.
|
||||
*
|
||||
* @param string $method The request method
|
||||
* @param string $uri The URI to fetch
|
||||
* @param array $parameters The Request parameters
|
||||
* @param array $files The files
|
||||
* @param array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does)
|
||||
* @param string $content The raw body data
|
||||
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true)
|
||||
{
|
||||
if ($this->isMainRequest) {
|
||||
$this->redirectCount = 0;
|
||||
} else {
|
||||
++$this->redirectCount;
|
||||
}
|
||||
|
||||
$uri = $this->getAbsoluteUri($uri);
|
||||
|
||||
if (!empty($server['HTTP_HOST'])) {
|
||||
$uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri);
|
||||
}
|
||||
|
||||
if (isset($server['HTTPS'])) {
|
||||
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
|
||||
}
|
||||
|
||||
$server = array_merge($this->server, $server);
|
||||
|
||||
if (!$this->history->isEmpty()) {
|
||||
$server['HTTP_REFERER'] = $this->history->current()->getUri();
|
||||
}
|
||||
|
||||
$server['HTTP_HOST'] = $this->extractHost($uri);
|
||||
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
|
||||
|
||||
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);
|
||||
|
||||
$this->request = $this->filterRequest($this->internalRequest);
|
||||
|
||||
if (true === $changeHistory) {
|
||||
$this->history->add($this->internalRequest);
|
||||
}
|
||||
|
||||
if ($this->insulated) {
|
||||
$this->response = $this->doRequestInProcess($this->request);
|
||||
} else {
|
||||
$this->response = $this->doRequest($this->request);
|
||||
}
|
||||
|
||||
$this->internalResponse = $this->filterResponse($this->response);
|
||||
|
||||
$this->cookieJar->updateFromResponse($this->internalResponse, $uri);
|
||||
|
||||
$status = $this->internalResponse->getStatus();
|
||||
|
||||
if ($status >= 300 && $status < 400) {
|
||||
$this->redirect = $this->internalResponse->getHeader('Location');
|
||||
} else {
|
||||
$this->redirect = null;
|
||||
}
|
||||
|
||||
if ($this->followRedirects && $this->redirect) {
|
||||
return $this->crawler = $this->followRedirect();
|
||||
}
|
||||
|
||||
return $this->crawler = $this->createCrawlerFromContent($this->internalRequest->getUri(), $this->internalResponse->getContent(), $this->internalResponse->getHeader('Content-Type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a request in another process.
|
||||
*
|
||||
* @param object $request An origin request instance
|
||||
*
|
||||
* @return object An origin response instance
|
||||
*
|
||||
* @throws \RuntimeException When processing returns exit code
|
||||
*/
|
||||
protected function doRequestInProcess($request)
|
||||
{
|
||||
// We set the TMPDIR (for Macs) and TEMP (for Windows), because on these platforms the temp directory changes based on the user.
|
||||
$process = new PhpProcess($this->getScript($request), null, array('TMPDIR' => sys_get_temp_dir(), 'TEMP' => sys_get_temp_dir()));
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
|
||||
throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput()));
|
||||
}
|
||||
|
||||
return unserialize($process->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a request.
|
||||
*
|
||||
* @param object $request An origin request instance
|
||||
*
|
||||
* @return object An origin response instance
|
||||
*/
|
||||
abstract protected function doRequest($request);
|
||||
|
||||
/**
|
||||
* Returns the script to execute when the request must be insulated.
|
||||
*
|
||||
* @param object $request An origin request instance
|
||||
*
|
||||
* @throws \LogicException When this abstract class is not implemented
|
||||
*/
|
||||
protected function getScript($request)
|
||||
{
|
||||
throw new \LogicException('To insulate requests, you need to override the getScript() method.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the BrowserKit request to the origin one.
|
||||
*
|
||||
* @param Request $request The BrowserKit Request to filter
|
||||
*
|
||||
* @return object An origin request instance
|
||||
*/
|
||||
protected function filterRequest(Request $request)
|
||||
{
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the origin response to the BrowserKit one.
|
||||
*
|
||||
* @param object $response The origin response to filter
|
||||
*
|
||||
* @return Response An BrowserKit Response instance
|
||||
*/
|
||||
protected function filterResponse($response)
|
||||
{
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a crawler.
|
||||
*
|
||||
* This method returns null if the DomCrawler component is not available.
|
||||
*
|
||||
* @param string $uri A URI
|
||||
* @param string $content Content for the crawler to use
|
||||
* @param string $type Content type
|
||||
*
|
||||
* @return Crawler|null
|
||||
*/
|
||||
protected function createCrawlerFromContent($uri, $content, $type)
|
||||
{
|
||||
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$crawler = new Crawler(null, $uri);
|
||||
$crawler->addContent($content, $type);
|
||||
|
||||
return $crawler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes back in the browser history.
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function back()
|
||||
{
|
||||
return $this->requestFromRequest($this->history->back(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes forward in the browser history.
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function forward()
|
||||
{
|
||||
return $this->requestFromRequest($this->history->forward(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the current browser.
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function reload()
|
||||
{
|
||||
return $this->requestFromRequest($this->history->current(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow redirects?
|
||||
*
|
||||
* @return Crawler
|
||||
*
|
||||
* @throws \LogicException If request was not a redirect
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function followRedirect()
|
||||
{
|
||||
if (empty($this->redirect)) {
|
||||
throw new \LogicException('The request was not redirected.');
|
||||
}
|
||||
|
||||
if (-1 !== $this->maxRedirects) {
|
||||
if ($this->redirectCount > $this->maxRedirects) {
|
||||
throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects));
|
||||
}
|
||||
}
|
||||
|
||||
$request = $this->internalRequest;
|
||||
|
||||
if (in_array($this->internalResponse->getStatus(), array(302, 303))) {
|
||||
$method = 'get';
|
||||
$files = array();
|
||||
$content = null;
|
||||
} else {
|
||||
$method = $request->getMethod();
|
||||
$files = $request->getFiles();
|
||||
$content = $request->getContent();
|
||||
}
|
||||
|
||||
if ('get' === strtolower($method)) {
|
||||
// Don't forward parameters for GET request as it should reach the redirection URI
|
||||
$parameters = array();
|
||||
} else {
|
||||
$parameters = $request->getParameters();
|
||||
}
|
||||
|
||||
$server = $request->getServer();
|
||||
$server = $this->updateServerFromUri($server, $this->redirect);
|
||||
|
||||
$this->isMainRequest = false;
|
||||
|
||||
$response = $this->request($method, $this->redirect, $parameters, $files, $server, $content);
|
||||
|
||||
$this->isMainRequest = true;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the client.
|
||||
*
|
||||
* It flushes history and all cookies.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function restart()
|
||||
{
|
||||
$this->cookieJar->clear();
|
||||
$this->history->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a URI and converts it to absolute if it is not already absolute.
|
||||
*
|
||||
* @param string $uri A URI
|
||||
*
|
||||
* @return string An absolute URI
|
||||
*/
|
||||
protected function getAbsoluteUri($uri)
|
||||
{
|
||||
// already absolute?
|
||||
if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
if (!$this->history->isEmpty()) {
|
||||
$currentUri = $this->history->current()->getUri();
|
||||
} else {
|
||||
$currentUri = sprintf('http%s://%s/',
|
||||
isset($this->server['HTTPS']) ? 's' : '',
|
||||
isset($this->server['HTTP_HOST']) ? $this->server['HTTP_HOST'] : 'localhost'
|
||||
);
|
||||
}
|
||||
|
||||
// protocol relative URL
|
||||
if (0 === strpos($uri, '//')) {
|
||||
return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri;
|
||||
}
|
||||
|
||||
// anchor?
|
||||
if (!$uri || '#' == $uri[0]) {
|
||||
return preg_replace('/#.*?$/', '', $currentUri).$uri;
|
||||
}
|
||||
|
||||
if ('/' !== $uri[0]) {
|
||||
$path = parse_url($currentUri, PHP_URL_PATH);
|
||||
|
||||
if ('/' !== substr($path, -1)) {
|
||||
$path = substr($path, 0, strrpos($path, '/') + 1);
|
||||
}
|
||||
|
||||
$uri = $path.$uri;
|
||||
}
|
||||
|
||||
return preg_replace('#^(.*?//[^/]+)\/.*$#', '$1', $currentUri).$uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a request from a Request object directly.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
|
||||
*
|
||||
* @return Crawler
|
||||
*/
|
||||
protected function requestFromRequest(Request $request, $changeHistory = true)
|
||||
{
|
||||
return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory);
|
||||
}
|
||||
|
||||
private function updateServerFromUri($server, $uri)
|
||||
{
|
||||
$server['HTTP_HOST'] = $this->extractHost($uri);
|
||||
$scheme = parse_url($uri, PHP_URL_SCHEME);
|
||||
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
|
||||
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);
|
||||
|
||||
return $server;
|
||||
}
|
||||
|
||||
private function extractHost($uri)
|
||||
{
|
||||
$host = parse_url($uri, PHP_URL_HOST);
|
||||
|
||||
if ($port = parse_url($uri, PHP_URL_PORT)) {
|
||||
return $host.':'.$port;
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
}
|
335
vendor/symfony/browser-kit/Cookie.php
vendored
Normal file
335
vendor/symfony/browser-kit/Cookie.php
vendored
Normal file
|
@ -0,0 +1,335 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* Cookie represents an HTTP cookie.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class Cookie
|
||||
{
|
||||
/**
|
||||
* Handles dates as defined by RFC 2616 section 3.3.1, and also some other
|
||||
* non-standard, but common formats.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $dateFormats = array(
|
||||
'D, d M Y H:i:s T',
|
||||
'D, d-M-y H:i:s T',
|
||||
'D, d-M-Y H:i:s T',
|
||||
'D, d-m-y H:i:s T',
|
||||
'D, d-m-Y H:i:s T',
|
||||
'D M j G:i:s Y',
|
||||
'D M d H:i:s Y T',
|
||||
);
|
||||
|
||||
protected $name;
|
||||
protected $value;
|
||||
protected $expires;
|
||||
protected $path;
|
||||
protected $domain;
|
||||
protected $secure;
|
||||
protected $httponly;
|
||||
protected $rawValue;
|
||||
|
||||
/**
|
||||
* Sets a cookie.
|
||||
*
|
||||
* @param string $name The cookie name
|
||||
* @param string $value The value of the cookie
|
||||
* @param string $expires The time the cookie expires
|
||||
* @param string $path The path on the server in which the cookie will be available on
|
||||
* @param string $domain The domain that the cookie is available
|
||||
* @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
|
||||
* @param bool $httponly The cookie httponly flag
|
||||
* @param bool $encodedValue Whether the value is encoded or not
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false)
|
||||
{
|
||||
if ($encodedValue) {
|
||||
$this->value = urldecode($value);
|
||||
$this->rawValue = $value;
|
||||
} else {
|
||||
$this->value = $value;
|
||||
$this->rawValue = urlencode($value);
|
||||
}
|
||||
$this->name = $name;
|
||||
$this->path = empty($path) ? '/' : $path;
|
||||
$this->domain = $domain;
|
||||
$this->secure = (bool) $secure;
|
||||
$this->httponly = (bool) $httponly;
|
||||
|
||||
if (null !== $expires) {
|
||||
$timestampAsDateTime = \DateTime::createFromFormat('U', $expires);
|
||||
if (false === $timestampAsDateTime) {
|
||||
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires));
|
||||
}
|
||||
|
||||
$this->expires = $timestampAsDateTime->getTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP representation of the Cookie.
|
||||
*
|
||||
* @return string The HTTP representation of the Cookie
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$cookie = sprintf('%s=%s', $this->name, $this->rawValue);
|
||||
|
||||
if (null !== $this->expires) {
|
||||
$dateTime = \DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT'));
|
||||
$cookie .= '; expires='.str_replace('+0000', '', $dateTime->format(self::$dateFormats[0]));
|
||||
}
|
||||
|
||||
if ('' !== $this->domain) {
|
||||
$cookie .= '; domain='.$this->domain;
|
||||
}
|
||||
|
||||
if ($this->path) {
|
||||
$cookie .= '; path='.$this->path;
|
||||
}
|
||||
|
||||
if ($this->secure) {
|
||||
$cookie .= '; secure';
|
||||
}
|
||||
|
||||
if ($this->httponly) {
|
||||
$cookie .= '; httponly';
|
||||
}
|
||||
|
||||
return $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Cookie instance from a Set-Cookie header value.
|
||||
*
|
||||
* @param string $cookie A Set-Cookie header value
|
||||
* @param string $url The base URL
|
||||
*
|
||||
* @return Cookie A Cookie instance
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function fromString($cookie, $url = null)
|
||||
{
|
||||
$parts = explode(';', $cookie);
|
||||
|
||||
if (false === strpos($parts[0], '=')) {
|
||||
throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0]));
|
||||
}
|
||||
|
||||
list($name, $value) = explode('=', array_shift($parts), 2);
|
||||
|
||||
$values = array(
|
||||
'name' => trim($name),
|
||||
'value' => trim($value),
|
||||
'expires' => null,
|
||||
'path' => '/',
|
||||
'domain' => '',
|
||||
'secure' => false,
|
||||
'httponly' => false,
|
||||
'passedRawValue' => true,
|
||||
);
|
||||
|
||||
if (null !== $url) {
|
||||
if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) {
|
||||
throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url));
|
||||
}
|
||||
|
||||
$values['domain'] = $urlParts['host'];
|
||||
$values['path'] = isset($urlParts['path']) ? substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')) : '';
|
||||
}
|
||||
|
||||
foreach ($parts as $part) {
|
||||
$part = trim($part);
|
||||
|
||||
if ('secure' === strtolower($part)) {
|
||||
// Ignore the secure flag if the original URI is not given or is not HTTPS
|
||||
if (!$url || !isset($urlParts['scheme']) || 'https' != $urlParts['scheme']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values['secure'] = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('httponly' === strtolower($part)) {
|
||||
$values['httponly'] = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (2 === count($elements = explode('=', $part, 2))) {
|
||||
if ('expires' === strtolower($elements[0])) {
|
||||
$elements[1] = self::parseDate($elements[1]);
|
||||
}
|
||||
|
||||
$values[strtolower($elements[0])] = $elements[1];
|
||||
}
|
||||
}
|
||||
|
||||
return new static(
|
||||
$values['name'],
|
||||
$values['value'],
|
||||
$values['expires'],
|
||||
$values['path'],
|
||||
$values['domain'],
|
||||
$values['secure'],
|
||||
$values['httponly'],
|
||||
$values['passedRawValue']
|
||||
);
|
||||
}
|
||||
|
||||
private static function parseDate($dateValue)
|
||||
{
|
||||
// trim single quotes around date if present
|
||||
if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
|
||||
$dateValue = substr($dateValue, 1, -1);
|
||||
}
|
||||
|
||||
foreach (self::$dateFormats as $dateFormat) {
|
||||
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
// attempt a fallback for unusual formatting
|
||||
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the cookie.
|
||||
*
|
||||
* @return string The cookie name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the cookie.
|
||||
*
|
||||
* @return string The cookie value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the raw value of the cookie.
|
||||
*
|
||||
* @return string The cookie value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getRawValue()
|
||||
{
|
||||
return $this->rawValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the expires time of the cookie.
|
||||
*
|
||||
* @return string The cookie expires time
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getExpiresTime()
|
||||
{
|
||||
return $this->expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path of the cookie.
|
||||
*
|
||||
* @return string The cookie path
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the domain of the cookie.
|
||||
*
|
||||
* @return string The cookie domain
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getDomain()
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the secure flag of the cookie.
|
||||
*
|
||||
* @return bool The cookie secure flag
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isSecure()
|
||||
{
|
||||
return $this->secure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the httponly flag of the cookie.
|
||||
*
|
||||
* @return bool The cookie httponly flag
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isHttpOnly()
|
||||
{
|
||||
return $this->httponly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the cookie has expired.
|
||||
*
|
||||
* @return bool true if the cookie has expired, false otherwise
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isExpired()
|
||||
{
|
||||
return null !== $this->expires && 0 !== $this->expires && $this->expires < time();
|
||||
}
|
||||
}
|
265
vendor/symfony/browser-kit/CookieJar.php
vendored
Normal file
265
vendor/symfony/browser-kit/CookieJar.php
vendored
Normal file
|
@ -0,0 +1,265 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* CookieJar.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class CookieJar
|
||||
{
|
||||
protected $cookieJar = array();
|
||||
|
||||
/**
|
||||
* Sets a cookie.
|
||||
*
|
||||
* @param Cookie $cookie A Cookie instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function set(Cookie $cookie)
|
||||
{
|
||||
$this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cookie by name.
|
||||
*
|
||||
* You should never use an empty domain, but if you do so,
|
||||
* this method returns the first cookie for the given name/path
|
||||
* (this behavior ensures a BC behavior with previous versions of
|
||||
* Symfony).
|
||||
*
|
||||
* @param string $name The cookie name
|
||||
* @param string $path The cookie path
|
||||
* @param string $domain The cookie domain
|
||||
*
|
||||
* @return Cookie|null A Cookie instance or null if the cookie does not exist
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function get($name, $path = '/', $domain = null)
|
||||
{
|
||||
$this->flushExpiredCookies();
|
||||
|
||||
if (!empty($domain)) {
|
||||
foreach ($this->cookieJar as $cookieDomain => $pathCookies) {
|
||||
if ($cookieDomain) {
|
||||
$cookieDomain = '.'.ltrim($cookieDomain, '.');
|
||||
if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($pathCookies as $cookiePath => $namedCookies) {
|
||||
if ($cookiePath != substr($path, 0, strlen($cookiePath))) {
|
||||
continue;
|
||||
}
|
||||
if (isset($namedCookies[$name])) {
|
||||
return $namedCookies[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// avoid relying on this behavior that is mainly here for BC reasons
|
||||
foreach ($this->cookieJar as $cookies) {
|
||||
if (isset($cookies[$path][$name])) {
|
||||
return $cookies[$path][$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a cookie by name.
|
||||
*
|
||||
* You should never use an empty domain, but if you do so,
|
||||
* all cookies for the given name/path expire (this behavior
|
||||
* ensures a BC behavior with previous versions of Symfony).
|
||||
*
|
||||
* @param string $name The cookie name
|
||||
* @param string $path The cookie path
|
||||
* @param string $domain The cookie domain
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function expire($name, $path = '/', $domain = null)
|
||||
{
|
||||
if (null === $path) {
|
||||
$path = '/';
|
||||
}
|
||||
|
||||
if (empty($domain)) {
|
||||
// an empty domain means any domain
|
||||
// this should never happen but it allows for a better BC
|
||||
$domains = array_keys($this->cookieJar);
|
||||
} else {
|
||||
$domains = array($domain);
|
||||
}
|
||||
|
||||
foreach ($domains as $domain) {
|
||||
unset($this->cookieJar[$domain][$path][$name]);
|
||||
|
||||
if (empty($this->cookieJar[$domain][$path])) {
|
||||
unset($this->cookieJar[$domain][$path]);
|
||||
|
||||
if (empty($this->cookieJar[$domain])) {
|
||||
unset($this->cookieJar[$domain]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the cookies from the jar.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->cookieJar = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the cookie jar from a response Set-Cookie headers.
|
||||
*
|
||||
* @param array $setCookies Set-Cookie headers from an HTTP response
|
||||
* @param string $uri The base URL
|
||||
*/
|
||||
public function updateFromSetCookie(array $setCookies, $uri = null)
|
||||
{
|
||||
$cookies = array();
|
||||
|
||||
foreach ($setCookies as $cookie) {
|
||||
foreach (explode(',', $cookie) as $i => $part) {
|
||||
if (0 === $i || preg_match('/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) {
|
||||
$cookies[] = ltrim($part);
|
||||
} else {
|
||||
$cookies[count($cookies) - 1] .= ','.$part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($cookies as $cookie) {
|
||||
try {
|
||||
$this->set(Cookie::fromString($cookie, $uri));
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// invalid cookies are just ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the cookie jar from a Response object.
|
||||
*
|
||||
* @param Response $response A Response object
|
||||
* @param string $uri The base URL
|
||||
*/
|
||||
public function updateFromResponse(Response $response, $uri = null)
|
||||
{
|
||||
$this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns not yet expired cookies.
|
||||
*
|
||||
* @return Cookie[] An array of cookies
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$this->flushExpiredCookies();
|
||||
|
||||
$flattenedCookies = array();
|
||||
foreach ($this->cookieJar as $path) {
|
||||
foreach ($path as $cookies) {
|
||||
foreach ($cookies as $cookie) {
|
||||
$flattenedCookies[] = $cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $flattenedCookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns not yet expired cookie values for the given URI.
|
||||
*
|
||||
* @param string $uri A URI
|
||||
* @param bool $returnsRawValue Returns raw value or urldecoded value
|
||||
*
|
||||
* @return array An array of cookie values
|
||||
*/
|
||||
public function allValues($uri, $returnsRawValue = false)
|
||||
{
|
||||
$this->flushExpiredCookies();
|
||||
|
||||
$parts = array_replace(array('path' => '/'), parse_url($uri));
|
||||
$cookies = array();
|
||||
foreach ($this->cookieJar as $domain => $pathCookies) {
|
||||
if ($domain) {
|
||||
$domain = '.'.ltrim($domain, '.');
|
||||
if ($domain != substr('.'.$parts['host'], -strlen($domain))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($pathCookies as $path => $namedCookies) {
|
||||
if ($path != substr($parts['path'], 0, strlen($path))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($namedCookies as $cookie) {
|
||||
if ($cookie->isSecure() && 'https' != $parts['scheme']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cookies[$cookie->getName()] = $returnsRawValue ? $cookie->getRawValue() : $cookie->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns not yet expired raw cookie values for the given URI.
|
||||
*
|
||||
* @param string $uri A URI
|
||||
*
|
||||
* @return array An array of cookie values
|
||||
*/
|
||||
public function allRawValues($uri)
|
||||
{
|
||||
return $this->allValues($uri, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all expired cookies.
|
||||
*/
|
||||
public function flushExpiredCookies()
|
||||
{
|
||||
foreach ($this->cookieJar as $domain => $pathCookies) {
|
||||
foreach ($pathCookies as $path => $namedCookies) {
|
||||
foreach ($namedCookies as $name => $cookie) {
|
||||
if ($cookie->isExpired()) {
|
||||
unset($this->cookieJar[$domain][$path][$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
102
vendor/symfony/browser-kit/History.php
vendored
Normal file
102
vendor/symfony/browser-kit/History.php
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* History.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class History
|
||||
{
|
||||
protected $stack = array();
|
||||
protected $position = -1;
|
||||
|
||||
/**
|
||||
* Clears the history.
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->stack = array();
|
||||
$this->position = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Request to the history.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$this->stack = array_slice($this->stack, 0, $this->position + 1);
|
||||
$this->stack[] = clone $request;
|
||||
$this->position = count($this->stack) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the history is empty.
|
||||
*
|
||||
* @return bool true if the history is empty, false otherwise
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return count($this->stack) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes back in the history.
|
||||
*
|
||||
* @return Request A Request instance
|
||||
*
|
||||
* @throws \LogicException if the stack is already on the first page
|
||||
*/
|
||||
public function back()
|
||||
{
|
||||
if ($this->position < 1) {
|
||||
throw new \LogicException('You are already on the first page.');
|
||||
}
|
||||
|
||||
return clone $this->stack[--$this->position];
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes forward in the history.
|
||||
*
|
||||
* @return Request A Request instance
|
||||
*
|
||||
* @throws \LogicException if the stack is already on the last page
|
||||
*/
|
||||
public function forward()
|
||||
{
|
||||
if ($this->position > count($this->stack) - 2) {
|
||||
throw new \LogicException('You are already on the last page.');
|
||||
}
|
||||
|
||||
return clone $this->stack[++$this->position];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current element in the history.
|
||||
*
|
||||
* @return Request A Request instance
|
||||
*
|
||||
* @throws \LogicException if the stack is empty
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
if (-1 == $this->position) {
|
||||
throw new \LogicException('The page history is empty.');
|
||||
}
|
||||
|
||||
return clone $this->stack[$this->position];
|
||||
}
|
||||
}
|
19
vendor/symfony/browser-kit/LICENSE
vendored
Normal file
19
vendor/symfony/browser-kit/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
23
vendor/symfony/browser-kit/README.md
vendored
Normal file
23
vendor/symfony/browser-kit/README.md
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
BrowserKit Component
|
||||
====================
|
||||
|
||||
BrowserKit simulates the behavior of a web browser.
|
||||
|
||||
The component only provide an abstract client and does not provide any
|
||||
"default" backend for the HTTP layer.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
For a simple implementation of a browser based on an HTTP layer, have a look
|
||||
at [Goutte](https://github.com/FriendsOfPHP/Goutte).
|
||||
|
||||
For an implementation based on HttpKernelInterface, have a look at the
|
||||
[Client](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php)
|
||||
provided by the HttpKernel component.
|
||||
|
||||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/BrowserKit/
|
||||
$ composer install
|
||||
$ phpunit
|
138
vendor/symfony/browser-kit/Request.php
vendored
Normal file
138
vendor/symfony/browser-kit/Request.php
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* Request object.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class Request
|
||||
{
|
||||
protected $uri;
|
||||
protected $method;
|
||||
protected $parameters;
|
||||
protected $files;
|
||||
protected $cookies;
|
||||
protected $server;
|
||||
protected $content;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $uri The request URI
|
||||
* @param string $method The HTTP method request
|
||||
* @param array $parameters The request parameters
|
||||
* @param array $files An array of uploaded files
|
||||
* @param array $cookies An array of cookies
|
||||
* @param array $server An array of server parameters
|
||||
* @param string $content The raw body data
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($uri, $method, array $parameters = array(), array $files = array(), array $cookies = array(), array $server = array(), $content = null)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
$this->method = $method;
|
||||
$this->parameters = $parameters;
|
||||
$this->files = $files;
|
||||
$this->cookies = $cookies;
|
||||
$this->server = $server;
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request URI.
|
||||
*
|
||||
* @return string The request URI
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request HTTP method.
|
||||
*
|
||||
* @return string The request HTTP method
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request parameters.
|
||||
*
|
||||
* @return array The request parameters
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request server files.
|
||||
*
|
||||
* @return array The request files
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request cookies.
|
||||
*
|
||||
* @return array The request cookies
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCookies()
|
||||
{
|
||||
return $this->cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request server parameters.
|
||||
*
|
||||
* @return array The request server parameters
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request raw body data.
|
||||
*
|
||||
* @return string The request raw body data.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
}
|
139
vendor/symfony/browser-kit/Response.php
vendored
Normal file
139
vendor/symfony/browser-kit/Response.php
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* Response object.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class Response
|
||||
{
|
||||
protected $content;
|
||||
protected $status;
|
||||
protected $headers;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The headers array is a set of key/value pairs. If a header is present multiple times
|
||||
* then the value is an array of all the values.
|
||||
*
|
||||
* @param string $content The content of the response
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of headers
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($content = '', $status = 200, array $headers = array())
|
||||
{
|
||||
$this->content = $content;
|
||||
$this->status = $status;
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the response object to string containing all headers and the response content.
|
||||
*
|
||||
* @return string The response with headers and content
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$headers = '';
|
||||
foreach ($this->headers as $name => $value) {
|
||||
if (is_string($value)) {
|
||||
$headers .= $this->buildHeader($name, $value);
|
||||
} else {
|
||||
foreach ($value as $headerValue) {
|
||||
$headers .= $this->buildHeader($name, $headerValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $headers."\n".$this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build header line.
|
||||
*
|
||||
* @param string $name The header name
|
||||
* @param string $value The header value
|
||||
*
|
||||
* @return string The built header line
|
||||
*/
|
||||
protected function buildHeader($name, $value)
|
||||
{
|
||||
return sprintf("%s: %s\n", $name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response content.
|
||||
*
|
||||
* @return string The response content
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response status code.
|
||||
*
|
||||
* @return int The response status code
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response headers.
|
||||
*
|
||||
* @return array The response headers
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a response header.
|
||||
*
|
||||
* @param string $header The header name
|
||||
* @param bool $first Whether to return the first value or all header values
|
||||
*
|
||||
* @return string|array The first header value if $first is true, an array of values otherwise
|
||||
*/
|
||||
public function getHeader($header, $first = true)
|
||||
{
|
||||
$normalizedHeader = str_replace('-', '_', strtolower($header));
|
||||
foreach ($this->headers as $key => $value) {
|
||||
if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
|
||||
if ($first) {
|
||||
return is_array($value) ? (count($value) ? $value[0] : '') : $value;
|
||||
}
|
||||
|
||||
return is_array($value) ? $value : array($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $first ? null : array();
|
||||
}
|
||||
}
|
639
vendor/symfony/browser-kit/Tests/ClientTest.php
vendored
Normal file
639
vendor/symfony/browser-kit/Tests/ClientTest.php
vendored
Normal file
|
@ -0,0 +1,639 @@
|
|||
<?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
Normal file
231
vendor/symfony/browser-kit/Tests/CookieJarTest.php
vendored
Normal file
|
@ -0,0 +1,231 @@
|
|||
<?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
Normal file
179
vendor/symfony/browser-kit/Tests/CookieTest.php
vendored
Normal file
|
@ -0,0 +1,179 @@
|
|||
<?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
Normal file
101
vendor/symfony/browser-kit/Tests/HistoryTest.php
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?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
Normal file
53
vendor/symfony/browser-kit/Tests/RequestTest.php
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?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');
|
||||
}
|
||||
}
|
76
vendor/symfony/browser-kit/Tests/ResponseTest.php
vendored
Normal file
76
vendor/symfony/browser-kit/Tests/ResponseTest.php
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?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');
|
||||
}
|
||||
}
|
39
vendor/symfony/browser-kit/composer.json
vendored
Normal file
39
vendor/symfony/browser-kit/composer.json
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "symfony/browser-kit",
|
||||
"type": "library",
|
||||
"description": "Symfony BrowserKit Component",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.9",
|
||||
"symfony/dom-crawler": "~2.0,>=2.0.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7",
|
||||
"symfony/process": "~2.0,>=2.0.5",
|
||||
"symfony/css-selector": "~2.0,>=2.0.5"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/process": ""
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\BrowserKit\\": "" }
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
}
|
||||
}
|
29
vendor/symfony/browser-kit/phpunit.xml.dist
vendored
Normal file
29
vendor/symfony/browser-kit/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony BrowserKit Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
3
vendor/symfony/class-loader/.gitignore
vendored
Normal file
3
vendor/symfony/class-loader/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
143
vendor/symfony/class-loader/ApcClassLoader.php
vendored
Normal file
143
vendor/symfony/class-loader/ApcClassLoader.php
vendored
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.
|
||||
*
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allows using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader and the UniversalClassLoader for instance) but also around any
|
||||
* other autoloaders following this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* $cachedLoader = new ApcClassLoader('my_prefix', $loader);
|
||||
*
|
||||
* // activate the cached autoloader
|
||||
* $cachedLoader->register();
|
||||
*
|
||||
* // eventually deactivate the non-cached loader if it was registered previously
|
||||
* // to be sure to use the cached one.
|
||||
* $loader->unregister();
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class ApcClassLoader
|
||||
{
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $decorated;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix The APC namespace prefix to use.
|
||||
* @param object $decorated A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix, $decorated)
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.');
|
||||
}
|
||||
|
||||
if (!method_exists($decorated, 'findFile')) {
|
||||
throw new \InvalidArgumentException('The class finder must implement a "findFile" method.');
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
$this->decorated = $decorated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = apc_fetch($this->prefix.$class)) {
|
||||
apc_store($this->prefix.$class, $file = $this->decorated->findFile($class));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes through all unknown calls onto the decorated object.
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array(array($this->decorated, $method), $args);
|
||||
}
|
||||
}
|
105
vendor/symfony/class-loader/ApcUniversalClassLoader.php
vendored
Normal file
105
vendor/symfony/class-loader/ApcUniversalClassLoader.php
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ApcUniversalClassLoader class is deprecated since version 2.7 and will be removed in 3.0. Use the Symfony\Component\ClassLoader\ApcClassLoader class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ApcUniversalClassLoader implements a "universal" autoloader cached in APC for PHP 5.3.
|
||||
*
|
||||
* It is able to load classes that use either:
|
||||
*
|
||||
* * The technical interoperability standards for PHP 5.3 namespaces and
|
||||
* class names (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md);
|
||||
*
|
||||
* * The PEAR naming convention for classes (http://pear.php.net/).
|
||||
*
|
||||
* Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
|
||||
* looked for in a list of locations to ease the vendoring of a sub-set of
|
||||
* classes for large projects.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
|
||||
*
|
||||
* use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
||||
*
|
||||
* $loader = new ApcUniversalClassLoader('apc.prefix.');
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->registerNamespaces(array(
|
||||
* 'Symfony\Component' => __DIR__.'/component',
|
||||
* 'Symfony' => __DIR__.'/framework',
|
||||
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
|
||||
* ));
|
||||
*
|
||||
* // register a library using the PEAR naming convention
|
||||
* $loader->registerPrefixes(array(
|
||||
* 'Swift_' => __DIR__.'/Swift',
|
||||
* ));
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
* Use the {@link ClassLoader} class instead.
|
||||
*/
|
||||
class ApcUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix A prefix to create a namespace in APC
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix)
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = apc_fetch($this->prefix.$class)) {
|
||||
apc_store($this->prefix.$class, $file = parent::findFile($class));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
}
|
28
vendor/symfony/class-loader/CHANGELOG.md
vendored
Normal file
28
vendor/symfony/class-loader/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* deprecated the UniversalClassLoader in favor of the ClassLoader class instead
|
||||
* deprecated the ApcUniversalClassLoader in favor of the ApcClassLoader class instead
|
||||
* deprecated the DebugUniversalClassLoader in favor of the DebugClassLoader class from the Debug component
|
||||
* deprecated the DebugClassLoader as it has been moved to the Debug component instead
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added a WinCacheClassLoader for WinCache
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added a DebugClassLoader able to wrap any autoloader providing a findFile
|
||||
method
|
||||
* added a new ApcClassLoader and XcacheClassLoader using composition to wrap
|
||||
other loaders
|
||||
* added a new ClassLoader which does not distinguish between namespaced and
|
||||
pear-like classes (as the PEAR convention is a subset of PSR-0) and
|
||||
supports using Composer's namespace maps
|
||||
* added a class map generator
|
||||
* added support for loading globally-installed PEAR packages
|
370
vendor/symfony/class-loader/ClassCollectionLoader.php
vendored
Normal file
370
vendor/symfony/class-loader/ClassCollectionLoader.php
vendored
Normal file
|
@ -0,0 +1,370 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* ClassCollectionLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ClassCollectionLoader
|
||||
{
|
||||
private static $loaded;
|
||||
private static $seen;
|
||||
private static $useTokenizer = true;
|
||||
|
||||
/**
|
||||
* Loads a list of classes and caches them in one big file.
|
||||
*
|
||||
* @param array $classes An array of classes to load
|
||||
* @param string $cacheDir A cache directory
|
||||
* @param string $name The cache name prefix
|
||||
* @param bool $autoReload Whether to flush the cache when the cache is stale or not
|
||||
* @param bool $adaptive Whether to remove already declared classes or not
|
||||
* @param string $extension File extension of the resulting file
|
||||
*
|
||||
* @throws \InvalidArgumentException When class can't be loaded
|
||||
*/
|
||||
public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
|
||||
{
|
||||
// each $name can only be loaded once per PHP process
|
||||
if (isset(self::$loaded[$name])) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$loaded[$name] = true;
|
||||
|
||||
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
|
||||
if (function_exists('get_declared_traits')) {
|
||||
$declared = array_merge($declared, get_declared_traits());
|
||||
}
|
||||
|
||||
if ($adaptive) {
|
||||
// don't include already declared classes
|
||||
$classes = array_diff($classes, $declared);
|
||||
|
||||
// the cache is different depending on which classes are already declared
|
||||
$name = $name.'-'.substr(hash('sha256', implode('|', $classes)), 0, 5);
|
||||
}
|
||||
|
||||
$classes = array_unique($classes);
|
||||
|
||||
$cache = $cacheDir.'/'.$name.$extension;
|
||||
|
||||
// auto-reload
|
||||
$reload = false;
|
||||
if ($autoReload) {
|
||||
$metadata = $cache.'.meta';
|
||||
if (!is_file($metadata) || !is_file($cache)) {
|
||||
$reload = true;
|
||||
} else {
|
||||
$time = filemtime($cache);
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
|
||||
sort($meta[1]);
|
||||
sort($classes);
|
||||
|
||||
if ($meta[1] != $classes) {
|
||||
$reload = true;
|
||||
} else {
|
||||
foreach ($meta[0] as $resource) {
|
||||
if (!is_file($resource) || filemtime($resource) > $time) {
|
||||
$reload = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reload && is_file($cache)) {
|
||||
require_once $cache;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$files = array();
|
||||
$content = '';
|
||||
foreach (self::getOrderedClasses($classes) as $class) {
|
||||
if (in_array($class->getName(), $declared)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = $class->getFileName();
|
||||
|
||||
$c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($class->getFileName()));
|
||||
|
||||
// fakes namespace declaration for global code
|
||||
if (!$class->inNamespace()) {
|
||||
$c = "\nnamespace\n{\n".$c."\n}\n";
|
||||
}
|
||||
|
||||
$c = self::fixNamespaceDeclarations('<?php '.$c);
|
||||
$c = preg_replace('/^\s*<\?php/', '', $c);
|
||||
|
||||
$content .= $c;
|
||||
}
|
||||
|
||||
// cache the core classes
|
||||
if (!is_dir(dirname($cache))) {
|
||||
mkdir(dirname($cache), 0777, true);
|
||||
}
|
||||
self::writeCacheFile($cache, '<?php '.$content);
|
||||
|
||||
if ($autoReload) {
|
||||
// save the resources
|
||||
self::writeCacheFile($metadata, serialize(array($files, $classes)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds brackets around each namespace if it's not already the case.
|
||||
*
|
||||
* @param string $source Namespace string
|
||||
*
|
||||
* @return string Namespaces with brackets
|
||||
*/
|
||||
public static function fixNamespaceDeclarations($source)
|
||||
{
|
||||
if (!function_exists('token_get_all') || !self::$useTokenizer) {
|
||||
if (preg_match('/namespace(.*?)\s*;/', $source)) {
|
||||
$source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n";
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
$rawChunk = '';
|
||||
$output = '';
|
||||
$inNamespace = false;
|
||||
$tokens = token_get_all($source);
|
||||
|
||||
for (reset($tokens); false !== $token = current($tokens); next($tokens)) {
|
||||
if (is_string($token)) {
|
||||
$rawChunk .= $token;
|
||||
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
// strip comments
|
||||
continue;
|
||||
} elseif (T_NAMESPACE === $token[0]) {
|
||||
if ($inNamespace) {
|
||||
$rawChunk .= "}\n";
|
||||
}
|
||||
$rawChunk .= $token[1];
|
||||
|
||||
// namespace name and whitespaces
|
||||
while (($t = next($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
|
||||
$rawChunk .= $t[1];
|
||||
}
|
||||
if ('{' === $t) {
|
||||
$inNamespace = false;
|
||||
prev($tokens);
|
||||
} else {
|
||||
$rawChunk = rtrim($rawChunk)."\n{";
|
||||
$inNamespace = true;
|
||||
}
|
||||
} elseif (T_START_HEREDOC === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
do {
|
||||
$token = next($tokens);
|
||||
$output .= is_string($token) ? $token : $token[1];
|
||||
} while ($token[0] !== T_END_HEREDOC);
|
||||
$output .= "\n";
|
||||
$rawChunk = '';
|
||||
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
$rawChunk = '';
|
||||
} else {
|
||||
$rawChunk .= $token[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($inNamespace) {
|
||||
$rawChunk .= "}\n";
|
||||
}
|
||||
|
||||
return $output.self::compressCode($rawChunk);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is only useful for testing.
|
||||
*/
|
||||
public static function enableTokenizer($bool)
|
||||
{
|
||||
self::$useTokenizer = (bool) $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips leading & trailing ws, multiple EOL, multiple ws.
|
||||
*
|
||||
* @param string $code Original PHP code
|
||||
*
|
||||
* @return string compressed code
|
||||
*/
|
||||
private static function compressCode($code)
|
||||
{
|
||||
return preg_replace(
|
||||
array('/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'),
|
||||
array('', '', "\n", ' '),
|
||||
$code
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a cache file.
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param string $content Temporary file content
|
||||
*
|
||||
* @throws \RuntimeException when a cache file cannot be written
|
||||
*/
|
||||
private static function writeCacheFile($file, $content)
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
@chmod($file, 0666 & ~umask());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an ordered array of passed classes including all their dependencies.
|
||||
*
|
||||
* @param array $classes
|
||||
*
|
||||
* @return \ReflectionClass[] An array of sorted \ReflectionClass instances (dependencies added if needed)
|
||||
*
|
||||
* @throws \InvalidArgumentException When a class can't be loaded
|
||||
*/
|
||||
private static function getOrderedClasses(array $classes)
|
||||
{
|
||||
$map = array();
|
||||
self::$seen = array();
|
||||
foreach ($classes as $class) {
|
||||
try {
|
||||
$reflectionClass = new \ReflectionClass($class);
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
}
|
||||
|
||||
$map = array_merge($map, self::getClassHierarchy($reflectionClass));
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
private static function getClassHierarchy(\ReflectionClass $class)
|
||||
{
|
||||
if (isset(self::$seen[$class->getName()])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
self::$seen[$class->getName()] = true;
|
||||
|
||||
$classes = array($class);
|
||||
$parent = $class;
|
||||
while (($parent = $parent->getParentClass()) && $parent->isUserDefined() && !isset(self::$seen[$parent->getName()])) {
|
||||
self::$seen[$parent->getName()] = true;
|
||||
|
||||
array_unshift($classes, $parent);
|
||||
}
|
||||
|
||||
$traits = array();
|
||||
|
||||
if (function_exists('get_declared_traits')) {
|
||||
foreach ($classes as $c) {
|
||||
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
||||
if ($trait !== $c) {
|
||||
$traits[] = $trait;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge(self::getInterfaces($class), $traits, $classes);
|
||||
}
|
||||
|
||||
private static function getInterfaces(\ReflectionClass $class)
|
||||
{
|
||||
$classes = array();
|
||||
|
||||
foreach ($class->getInterfaces() as $interface) {
|
||||
$classes = array_merge($classes, self::getInterfaces($interface));
|
||||
}
|
||||
|
||||
if ($class->isUserDefined() && $class->isInterface() && !isset(self::$seen[$class->getName()])) {
|
||||
self::$seen[$class->getName()] = true;
|
||||
|
||||
$classes[] = $class;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
private static function computeTraitDeps(\ReflectionClass $class)
|
||||
{
|
||||
$traits = $class->getTraits();
|
||||
$deps = array($class->getName() => $traits);
|
||||
while ($trait = array_pop($traits)) {
|
||||
if ($trait->isUserDefined() && !isset(self::$seen[$trait->getName()])) {
|
||||
self::$seen[$trait->getName()] = true;
|
||||
$traitDeps = $trait->getTraits();
|
||||
$deps[$trait->getName()] = $traitDeps;
|
||||
$traits = array_merge($traits, $traitDeps);
|
||||
}
|
||||
}
|
||||
|
||||
return $deps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dependencies resolution.
|
||||
*
|
||||
* This function does not check for circular dependencies as it should never
|
||||
* occur with PHP traits.
|
||||
*
|
||||
* @param array $tree The dependency tree
|
||||
* @param \ReflectionClass $node The node
|
||||
* @param \ArrayObject $resolved An array of already resolved dependencies
|
||||
* @param \ArrayObject $unresolved An array of dependencies to be resolved
|
||||
*
|
||||
* @return \ArrayObject The dependencies for the given node
|
||||
*
|
||||
* @throws \RuntimeException if a circular dependency is detected
|
||||
*/
|
||||
private static function resolveDependencies(array $tree, $node, \ArrayObject $resolved = null, \ArrayObject $unresolved = null)
|
||||
{
|
||||
if (null === $resolved) {
|
||||
$resolved = new \ArrayObject();
|
||||
}
|
||||
if (null === $unresolved) {
|
||||
$unresolved = new \ArrayObject();
|
||||
}
|
||||
$nodeName = $node->getName();
|
||||
|
||||
if (isset($tree[$nodeName])) {
|
||||
$unresolved[$nodeName] = $node;
|
||||
foreach ($tree[$nodeName] as $dependency) {
|
||||
if (!$resolved->offsetExists($dependency->getName())) {
|
||||
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
|
||||
}
|
||||
}
|
||||
$resolved[$nodeName] = $node;
|
||||
unset($unresolved[$nodeName]);
|
||||
}
|
||||
|
||||
return $resolved;
|
||||
}
|
||||
}
|
199
vendor/symfony/class-loader/ClassLoader.php
vendored
Normal file
199
vendor/symfony/class-loader/ClassLoader.php
vendored
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* ClassLoader implements an PSR-0 class loader.
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (e.g. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
private $prefixes = array();
|
||||
private $fallbackDirs = array();
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* Returns prefixes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
return $this->prefixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fallback directories.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds prefixes.
|
||||
*
|
||||
* @param array $prefixes Prefixes to add
|
||||
*/
|
||||
public function addPrefixes(array $prefixes)
|
||||
{
|
||||
foreach ($prefixes as $prefix => $path) {
|
||||
$this->addPrefix($prefix, $path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
*/
|
||||
public function addPrefix($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
foreach ((array) $paths as $path) {
|
||||
$this->fallbackDirs[] = $path;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (isset($this->prefixes[$prefix])) {
|
||||
$this->prefixes[$prefix] = array_merge(
|
||||
$this->prefixes[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
} else {
|
||||
$this->prefixes[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = (bool) $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;
|
||||
$className = substr($class, $pos + 1);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$classPath = null;
|
||||
$className = $class;
|
||||
}
|
||||
|
||||
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
|
||||
|
||||
foreach ($this->prefixes as $prefix => $dirs) {
|
||||
if ($class === strstr($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
||||
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->fallbackDirs as $dir) {
|
||||
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
||||
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
158
vendor/symfony/class-loader/ClassMapGenerator.php
vendored
Normal file
158
vendor/symfony/class-loader/ClassMapGenerator.php
vendored
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?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;
|
||||
|
||||
if (!defined('SYMFONY_TRAIT')) {
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
define('SYMFONY_TRAIT', T_TRAIT);
|
||||
} else {
|
||||
define('SYMFONY_TRAIT', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ClassMapGenerator.
|
||||
*
|
||||
* @author Gyula Sallai <salla016@gmail.com>
|
||||
*/
|
||||
class ClassMapGenerator
|
||||
{
|
||||
/**
|
||||
* Generate a class map file.
|
||||
*
|
||||
* @param array|string $dirs Directories or a single path to search in
|
||||
* @param string $file The name of the class map file
|
||||
*/
|
||||
public static function dump($dirs, $file)
|
||||
{
|
||||
$dirs = (array) $dirs;
|
||||
$maps = array();
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
$maps = array_merge($maps, static::createMap($dir));
|
||||
}
|
||||
|
||||
file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over all files in the given directory searching for classes.
|
||||
*
|
||||
* @param \Iterator|string $dir The directory to search in or an iterator
|
||||
*
|
||||
* @return array A class map array
|
||||
*/
|
||||
public static function createMap($dir)
|
||||
{
|
||||
if (is_string($dir)) {
|
||||
$dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
|
||||
}
|
||||
|
||||
$map = array();
|
||||
|
||||
foreach ($dir as $file) {
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $file->getRealPath();
|
||||
|
||||
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classes = self::findClasses($path);
|
||||
|
||||
foreach ($classes as $class) {
|
||||
$map[$class] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the classes in the given file.
|
||||
*
|
||||
* @param string $path The file to check
|
||||
*
|
||||
* @return array The found classes
|
||||
*/
|
||||
private static function findClasses($path)
|
||||
{
|
||||
$contents = file_get_contents($path);
|
||||
$tokens = token_get_all($contents);
|
||||
|
||||
$classes = array();
|
||||
|
||||
$namespace = '';
|
||||
for ($i = 0, $max = count($tokens); $i < $max; ++$i) {
|
||||
$token = $tokens[$i];
|
||||
|
||||
if (is_string($token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = '';
|
||||
|
||||
switch ($token[0]) {
|
||||
case T_NAMESPACE:
|
||||
$namespace = '';
|
||||
// If there is a namespace, extract it
|
||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||
if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) {
|
||||
$namespace .= $t[1];
|
||||
}
|
||||
}
|
||||
$namespace .= '\\';
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_INTERFACE:
|
||||
case SYMFONY_TRAIT:
|
||||
// Skip usage of ::class constant
|
||||
$isClassConstant = false;
|
||||
for ($j = $i - 1; $j > 0; --$j) {
|
||||
if (is_string($tokens[$j])) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
$isClassConstant = true;
|
||||
break;
|
||||
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isClassConstant) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find the classname
|
||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||
if (T_STRING === $t[0]) {
|
||||
$class .= $t[1];
|
||||
} elseif ($class !== '' && T_WHITESPACE == $t[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$classes[] = ltrim($namespace.$class, '\\');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
124
vendor/symfony/class-loader/DebugClassLoader.php
vendored
Normal file
124
vendor/symfony/class-loader/DebugClassLoader.php
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\DebugClassLoader class is deprecated since version 2.4 and will be removed in 3.0. Use the Symfony\Component\Debug\DebugClassLoader class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Autoloader checking if the class is really defined in the file found.
|
||||
*
|
||||
* The DebugClassLoader will wrap all registered autoloaders providing a
|
||||
* findFile method and will throw an exception if a file is found but does
|
||||
* not declare the class.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
* Use {@link \Symfony\Component\Debug\DebugClassLoader} instead.
|
||||
*/
|
||||
class DebugClassLoader
|
||||
{
|
||||
private $classFinder;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $classFinder
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($classFinder)
|
||||
{
|
||||
$this->classFinder = $classFinder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the wrapped class loader.
|
||||
*
|
||||
* @return object a class loader instance
|
||||
*/
|
||||
public function getClassLoader()
|
||||
{
|
||||
return $this->classFinder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all autoloaders implementing a findFile method by a DebugClassLoader wrapper.
|
||||
*/
|
||||
public static function enable()
|
||||
{
|
||||
if (!is_array($functions = spl_autoload_functions())) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
spl_autoload_unregister($function);
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (is_array($function) && !$function[0] instanceof self && method_exists($function[0], 'findFile')) {
|
||||
$function = array(new static($function[0]), 'loadClass');
|
||||
}
|
||||
|
||||
spl_autoload_register($function);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
return $this->classFinder->findFile($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return bool|null True, if loaded
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->classFinder->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
|
||||
if (false !== strpos($class, '/')) {
|
||||
throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
68
vendor/symfony/class-loader/DebugUniversalClassLoader.php
vendored
Normal file
68
vendor/symfony/class-loader/DebugUniversalClassLoader.php
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\DebugUniversalClassLoader class is deprecated since version 2.4 and will be removed in 3.0. Use the Symfony\Component\Debug\DebugClassLoader class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Checks that the class is actually declared in the included file.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
* Use the {@link \Symfony\Component\Debug\DebugClassLoader} class instead.
|
||||
*/
|
||||
class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
/**
|
||||
* Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
|
||||
*/
|
||||
public static function enable()
|
||||
{
|
||||
if (!is_array($functions = spl_autoload_functions())) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
spl_autoload_unregister($function);
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
|
||||
$loader = new static();
|
||||
$loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
|
||||
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
|
||||
$loader->registerNamespaces($function[0]->getNamespaces());
|
||||
$loader->registerPrefixes($function[0]->getPrefixes());
|
||||
$loader->useIncludePath($function[0]->getUseIncludePath());
|
||||
|
||||
$function[0] = $loader;
|
||||
}
|
||||
|
||||
spl_autoload_register($function);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
|
||||
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
vendor/symfony/class-loader/LICENSE
vendored
Normal file
19
vendor/symfony/class-loader/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
68
vendor/symfony/class-loader/MapClassLoader.php
vendored
Normal file
68
vendor/symfony/class-loader/MapClassLoader.php
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* A class loader that uses a mapping file to look up paths.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class MapClassLoader
|
||||
{
|
||||
private $map = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $map A map where keys are classes and values the absolute file path
|
||||
*/
|
||||
public function __construct(array $map)
|
||||
{
|
||||
$this->map = $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if (isset($this->map[$class])) {
|
||||
require $this->map[$class];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (isset($this->map[$class])) {
|
||||
return $this->map[$class];
|
||||
}
|
||||
}
|
||||
}
|
94
vendor/symfony/class-loader/Psr4ClassLoader.php
vendored
Normal file
94
vendor/symfony/class-loader/Psr4ClassLoader.php
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* A PSR-4 compatible class loader.
|
||||
*
|
||||
* See http://www.php-fig.org/psr/psr-4/
|
||||
*
|
||||
* @author Alexander M. Turek <me@derrabus.de>
|
||||
*/
|
||||
class Psr4ClassLoader
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $prefixes = array();
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
* @param string $baseDir
|
||||
*/
|
||||
public function addPrefix($prefix, $baseDir)
|
||||
{
|
||||
$prefix = trim($prefix, '\\').'\\';
|
||||
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||
$this->prefixes[] = array($prefix, $baseDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
$class = ltrim($class, '\\');
|
||||
|
||||
foreach ($this->prefixes as $current) {
|
||||
list($currentPrefix, $currentBaseDir) = $current;
|
||||
if (0 === strpos($class, $currentPrefix)) {
|
||||
$classWithoutPrefix = substr($class, strlen($currentPrefix));
|
||||
$file = $currentBaseDir.str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php';
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
$file = $this->findFile($class);
|
||||
if (null !== $file) {
|
||||
require $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this instance from the registered autoloaders.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
}
|
85
vendor/symfony/class-loader/README.md
vendored
Normal file
85
vendor/symfony/class-loader/README.md
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
ClassLoader Component
|
||||
=====================
|
||||
|
||||
ClassLoader loads your project classes automatically if they follow some
|
||||
standard PHP conventions.
|
||||
|
||||
The ClassLoader object is able to autoload classes that implement the PSR-0
|
||||
standard or the PEAR naming convention.
|
||||
|
||||
First, register the autoloader:
|
||||
|
||||
```php
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
|
||||
$loader = new ClassLoader();
|
||||
$loader->register();
|
||||
```
|
||||
|
||||
Then, register some namespaces with the `addPrefix()` method:
|
||||
|
||||
```php
|
||||
$loader->addPrefix('Symfony', __DIR__.'/src');
|
||||
$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src');
|
||||
```
|
||||
|
||||
The `addPrefix()` method takes a namespace prefix and a path where to
|
||||
look for the classes as arguments.
|
||||
|
||||
You can also register a sub-namespaces:
|
||||
|
||||
```php
|
||||
$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
|
||||
```
|
||||
|
||||
The order of registration is significant and the first registered namespace
|
||||
takes precedence over later registered one.
|
||||
|
||||
You can also register more than one path for a given namespace:
|
||||
|
||||
```php
|
||||
$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
|
||||
```
|
||||
|
||||
Alternatively, you can use the `addPrefixes()` method to register more
|
||||
than one namespace at once:
|
||||
|
||||
```php
|
||||
$loader->addPrefixes(array(
|
||||
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'),
|
||||
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
|
||||
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
|
||||
'Monolog' => __DIR__.'/vendor/monolog/src',
|
||||
));
|
||||
```
|
||||
|
||||
For better performance, you can use the APC class loader:
|
||||
|
||||
```php
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
|
||||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
use Symfony\Component\ClassLoader\ApcClassLoader;
|
||||
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Symfony', __DIR__.'/src');
|
||||
|
||||
$loader = new ApcClassLoader('apc.prefix.', $loader);
|
||||
$loader->register();
|
||||
```
|
||||
|
||||
Furthermore, the component provides tools to aggregate classes into a single
|
||||
file, which is especially useful to improve performance on servers that do not
|
||||
provide byte caches.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/ClassLoader/
|
||||
$ composer install
|
||||
$ phpunit
|
292
vendor/symfony/class-loader/Tests/ClassCollectionLoaderTest.php
vendored
Normal file
292
vendor/symfony/class-loader/Tests/ClassCollectionLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,292 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
212
vendor/symfony/class-loader/Tests/ClassLoaderTest.php
vendored
Normal file
212
vendor/symfony/class-loader/Tests/ClassLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,212 @@
|
|||
<?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.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
150
vendor/symfony/class-loader/Tests/ClassMapGeneratorTest.php
vendored
Normal file
150
vendor/symfony/class-loader/Tests/ClassMapGeneratorTest.php
vendored
Normal file
|
@ -0,0 +1,150 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Bar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Bar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Baz.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Baz.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Foo.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Foo.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/FooBar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/FooBar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Baz.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Baz.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/ApcPrefixCollision/A/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/ApcPrefixCollision/A/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/ApcPrefixCollision/A/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/ApcPrefixCollision/A/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Bar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Bar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Foo.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Foo.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Bar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Bar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Foo.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Foo.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Apc_Pearlike_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/fallback/Namespaced/FooBar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Apc/fallback/Namespaced/FooBar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/A.php
vendored
Normal file
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/A.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class A extends B
|
||||
{
|
||||
}
|
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/ATrait.php
vendored
Normal file
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/ATrait.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait ATrait
|
||||
{
|
||||
}
|
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/B.php
vendored
Normal file
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/B.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class B implements CInterface
|
||||
{
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/BTrait.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/BTrait.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait BTrait
|
||||
{
|
||||
use ATrait;
|
||||
}
|
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/CInterface.php
vendored
Normal file
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/CInterface.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
interface CInterface extends GInterface
|
||||
{
|
||||
}
|
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/CTrait.php
vendored
Normal file
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/CTrait.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait CTrait
|
||||
{
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/D.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/D.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class D extends A
|
||||
{
|
||||
use BTrait;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/E.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/E.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class E extends D
|
||||
{
|
||||
use CTrait;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/F.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/F.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class F
|
||||
{
|
||||
use CTrait;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/G.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/G.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class G
|
||||
{
|
||||
use CTrait;
|
||||
}
|
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/GInterface.php
vendored
Normal file
7
vendor/symfony/class-loader/Tests/Fixtures/ClassesWithParents/GInterface.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
interface GInterface
|
||||
{
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/Bar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/Bar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/Baz.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/Baz.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/Foo.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/Foo.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
37
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/WithComments.php
vendored
Normal file
37
vendor/symfony/class-loader/Tests/Fixtures/Namespaced/WithComments.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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;
|
8
vendor/symfony/class-loader/Tests/Fixtures/Namespaced2/Bar.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/Namespaced2/Bar.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/Namespaced2/Baz.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/Namespaced2/Baz.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/Namespaced2/Foo.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/Namespaced2/Foo.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/Baz.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/Baz.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Pearlike_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
16
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/WithComments.php
vendored
Normal file
16
vendor/symfony/class-loader/Tests/Fixtures/Pearlike/WithComments.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?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;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike2/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike2/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike2/Baz.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike2/Baz.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike2/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/Pearlike2/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Pearlike2_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Bar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Bar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Foo.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Foo.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/A/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/A/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/A/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/A/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/C/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/C/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/C/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/C/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Bar.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Bar.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
17
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php
vendored
Normal file
17
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
8
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Foo.php
vendored
Normal file
8
vendor/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Foo.php
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace NamespaceCollision\C\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/A/B/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/A/B/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/A/B/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/A/B/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_A_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/C/B/Bar.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/C/B/Bar.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/C/B/Foo.php
vendored
Normal file
6
vendor/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/C/B/Foo.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class PrefixCollision_C_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
16
vendor/symfony/class-loader/Tests/Fixtures/classmap/SomeClass.php
vendored
Normal file
16
vendor/symfony/class-loader/Tests/Fixtures/classmap/SomeClass.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?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
|
||||
{
|
||||
}
|
16
vendor/symfony/class-loader/Tests/Fixtures/classmap/SomeInterface.php
vendored
Normal file
16
vendor/symfony/class-loader/Tests/Fixtures/classmap/SomeInterface.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?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
|
||||
{
|
||||
}
|
16
vendor/symfony/class-loader/Tests/Fixtures/classmap/SomeParent.php
vendored
Normal file
16
vendor/symfony/class-loader/Tests/Fixtures/classmap/SomeParent.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?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
|
||||
{
|
||||
}
|
25
vendor/symfony/class-loader/Tests/Fixtures/classmap/multipleNs.php
vendored
Normal file
25
vendor/symfony/class-loader/Tests/Fixtures/classmap/multipleNs.php
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace {
|
||||
class A
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Alpha {
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beta {
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
3
vendor/symfony/class-loader/Tests/Fixtures/classmap/notAClass.php
vendored
Normal file
3
vendor/symfony/class-loader/Tests/Fixtures/classmap/notAClass.php
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
$a = new stdClass();
|
1
vendor/symfony/class-loader/Tests/Fixtures/classmap/notPhpFile.md
vendored
Normal file
1
vendor/symfony/class-loader/Tests/Fixtures/classmap/notPhpFile.md
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
This file should be skipped.
|
19
vendor/symfony/class-loader/Tests/Fixtures/classmap/sameNsMultipleClasses.php
vendored
Normal file
19
vendor/symfony/class-loader/Tests/Fixtures/classmap/sameNsMultipleClasses.php
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?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
|
||||
{
|
||||
}
|
37
vendor/symfony/class-loader/Tests/Fixtures/deps/traits.php
vendored
Normal file
37
vendor/symfony/class-loader/Tests/Fixtures/deps/traits.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue