Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -0,0 +1,67 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Reader;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\TokenStream;
/**
* @author Jean-François Simon <contact@jfsimon.fr>
*/
abstract class AbstractHandlerTest extends \PHPUnit_Framework_TestCase
{
/** @dataProvider getHandleValueTestData */
public function testHandleValue($value, Token $expectedToken, $remainingContent)
{
$reader = new Reader($value);
$stream = new TokenStream();
$this->assertTrue($this->generateHandler()->handle($reader, $stream));
$this->assertEquals($expectedToken, $stream->getNext());
$this->assertRemainingContent($reader, $remainingContent);
}
/** @dataProvider getDontHandleValueTestData */
public function testDontHandleValue($value)
{
$reader = new Reader($value);
$stream = new TokenStream();
$this->assertFalse($this->generateHandler()->handle($reader, $stream));
$this->assertStreamEmpty($stream);
$this->assertRemainingContent($reader, $value);
}
abstract public function getHandleValueTestData();
abstract public function getDontHandleValueTestData();
abstract protected function generateHandler();
protected function assertStreamEmpty(TokenStream $stream)
{
$property = new \ReflectionProperty($stream, 'tokens');
$property->setAccessible(true);
$this->assertEquals(array(), $property->getValue($stream));
}
protected function assertRemainingContent(Reader $reader, $remainingContent)
{
if ('' === $remainingContent) {
$this->assertEquals(0, $reader->getRemainingLength());
$this->assertTrue($reader->isEOF());
} else {
$this->assertEquals(strlen($remainingContent), $reader->getRemainingLength());
$this->assertEquals(0, $reader->getOffset($remainingContent));
}
}
}

View file

@ -0,0 +1,55 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\CommentHandler;
use Symfony\Component\CssSelector\Parser\Reader;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\TokenStream;
class CommentHandlerTest extends AbstractHandlerTest
{
/** @dataProvider getHandleValueTestData */
public function testHandleValue($value, Token $unusedArgument, $remainingContent)
{
$reader = new Reader($value);
$stream = new TokenStream();
$this->assertTrue($this->generateHandler()->handle($reader, $stream));
// comments are ignored (not pushed as token in stream)
$this->assertStreamEmpty($stream);
$this->assertRemainingContent($reader, $remainingContent);
}
public function getHandleValueTestData()
{
return array(
// 2nd argument only exists for inherited method compatibility
array('/* comment */', new Token(null, null, null), ''),
array('/* comment */foo', new Token(null, null, null), 'foo'),
);
}
public function getDontHandleValueTestData()
{
return array(
array('>'),
array('+'),
array(' '),
);
}
protected function generateHandler()
{
return new CommentHandler();
}
}

View file

@ -0,0 +1,49 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\HashHandler;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
class HashHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('#id', new Token(Token::TYPE_HASH, 'id', 0), ''),
array('#123', new Token(Token::TYPE_HASH, '123', 0), ''),
array('#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'),
array('#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'),
);
}
public function getDontHandleValueTestData()
{
return array(
array('id'),
array('123'),
array('<'),
array('<'),
array('#'),
);
}
protected function generateHandler()
{
$patterns = new TokenizerPatterns();
return new HashHandler($patterns, new TokenizerEscaping($patterns));
}
}

View file

@ -0,0 +1,49 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
class IdentifierHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''),
array('foo|bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '|bar'),
array('foo.class', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '.class'),
array('foo[attr]', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '[attr]'),
array('foo bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ' bar'),
);
}
public function getDontHandleValueTestData()
{
return array(
array('>'),
array('+'),
array(' '),
array('*|foo'),
array('/* comment */'),
);
}
protected function generateHandler()
{
$patterns = new TokenizerPatterns();
return new IdentifierHandler($patterns, new TokenizerEscaping($patterns));
}
}

View file

@ -0,0 +1,50 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\NumberHandler;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
class NumberHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('12', new Token(Token::TYPE_NUMBER, '12', 0), ''),
array('12.34', new Token(Token::TYPE_NUMBER, '12.34', 0), ''),
array('+12.34', new Token(Token::TYPE_NUMBER, '+12.34', 0), ''),
array('-12.34', new Token(Token::TYPE_NUMBER, '-12.34', 0), ''),
array('12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'),
array('12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'),
);
}
public function getDontHandleValueTestData()
{
return array(
array('hello'),
array('>'),
array('+'),
array(' '),
array('/* comment */'),
);
}
protected function generateHandler()
{
$patterns = new TokenizerPatterns();
return new NumberHandler($patterns);
}
}

View file

@ -0,0 +1,50 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\StringHandler;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
class StringHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''),
array('"1"', new Token(Token::TYPE_STRING, '1', 1), ''),
array('" "', new Token(Token::TYPE_STRING, ' ', 1), ''),
array('""', new Token(Token::TYPE_STRING, '', 1), ''),
array("'hello'", new Token(Token::TYPE_STRING, 'hello', 1), ''),
array("'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'),
);
}
public function getDontHandleValueTestData()
{
return array(
array('hello'),
array('>'),
array('1'),
array(' '),
);
}
protected function generateHandler()
{
$patterns = new TokenizerPatterns();
return new StringHandler($patterns, new TokenizerEscaping($patterns));
}
}

View file

@ -0,0 +1,44 @@
<?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\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler;
use Symfony\Component\CssSelector\Parser\Token;
class WhitespaceHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array(' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''),
array("\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''),
array("\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''),
array(' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'),
array(' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'),
);
}
public function getDontHandleValueTestData()
{
return array(
array('>'),
array('1'),
array('a'),
);
}
protected function generateHandler()
{
return new WhitespaceHandler();
}
}