the whole shebang
This commit is contained in:
68
vendor/symfony/finder/Symfony/Component/Finder/Tests/Expression/ExpressionTest.php
vendored
Normal file
68
vendor/symfony/finder/Symfony/Component/Finder/Tests/Expression/ExpressionTest.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\Finder\Tests;
|
||||
|
||||
use Symfony\Component\Finder\Expression\Expression;
|
||||
|
||||
class ExpressionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getTypeGuesserData
|
||||
*/
|
||||
public function testTypeGuesser($expr, $type)
|
||||
{
|
||||
$this->assertEquals($type, Expression::create($expr)->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCaseSensitiveData
|
||||
*/
|
||||
public function testCaseSensitive($expr, $isCaseSensitive)
|
||||
{
|
||||
$this->assertEquals($isCaseSensitive, Expression::create($expr)->isCaseSensitive());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getRegexRenderingData
|
||||
*/
|
||||
public function testRegexRendering($expr, $body)
|
||||
{
|
||||
$this->assertEquals($body, Expression::create($expr)->renderPattern());
|
||||
}
|
||||
|
||||
public function getTypeGuesserData()
|
||||
{
|
||||
return array(
|
||||
array('{foo}', Expression::TYPE_REGEX),
|
||||
array('/foo/', Expression::TYPE_REGEX),
|
||||
array('foo', Expression::TYPE_GLOB),
|
||||
array('foo*', Expression::TYPE_GLOB),
|
||||
);
|
||||
}
|
||||
|
||||
public function getCaseSensitiveData()
|
||||
{
|
||||
return array(
|
||||
array('{foo}m', true),
|
||||
array('/foo/i', false),
|
||||
array('foo*', true),
|
||||
);
|
||||
}
|
||||
|
||||
public function getRegexRenderingData()
|
||||
{
|
||||
return array(
|
||||
array('{foo}m', 'foo'),
|
||||
array('/foo/i', 'foo'),
|
||||
);
|
||||
}
|
||||
}
|
47
vendor/symfony/finder/Symfony/Component/Finder/Tests/Expression/GlobTest.php
vendored
Normal file
47
vendor/symfony/finder/Symfony/Component/Finder/Tests/Expression/GlobTest.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\Finder\Tests;
|
||||
|
||||
use Symfony\Component\Finder\Expression\Expression;
|
||||
|
||||
class GlobTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getToRegexData
|
||||
*/
|
||||
public function testGlobToRegex($glob, $match, $noMatch)
|
||||
{
|
||||
foreach ($match as $m) {
|
||||
$this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
|
||||
}
|
||||
|
||||
foreach ($noMatch as $m) {
|
||||
$this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
|
||||
}
|
||||
}
|
||||
|
||||
public function getToRegexData()
|
||||
{
|
||||
return array(
|
||||
array('', array(''), array('f', '/')),
|
||||
array('*', array('foo'), array('foo/', '/foo')),
|
||||
array('foo.*', array('foo.php', 'foo.a', 'foo.'), array('fooo.php', 'foo.php/foo')),
|
||||
array('fo?', array('foo', 'fot'), array('fooo', 'ffoo', 'fo/')),
|
||||
array('fo{o,t}', array('foo', 'fot'), array('fob', 'fo/')),
|
||||
array('foo(bar|foo)', array('foo(bar|foo)'), array('foobar', 'foofoo')),
|
||||
array('foo,bar', array('foo,bar'), array('foo', 'bar')),
|
||||
array('fo{o,\\,}', array('foo', 'fo,'), array()),
|
||||
array('fo{o,\\\\}', array('foo', 'fo\\'), array()),
|
||||
array('/foo', array('/foo'), array('foo')),
|
||||
);
|
||||
}
|
||||
}
|
143
vendor/symfony/finder/Symfony/Component/Finder/Tests/Expression/RegexTest.php
vendored
Normal file
143
vendor/symfony/finder/Symfony/Component/Finder/Tests/Expression/RegexTest.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\Finder\Tests;
|
||||
|
||||
use Symfony\Component\Finder\Expression\Expression;
|
||||
|
||||
class RegexTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getHasFlagsData
|
||||
*/
|
||||
public function testHasFlags($regex, $start, $end)
|
||||
{
|
||||
$expr = new Expression($regex);
|
||||
|
||||
$this->assertEquals($start, $expr->getRegex()->hasStartFlag());
|
||||
$this->assertEquals($end, $expr->getRegex()->hasEndFlag());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getHasJokersData
|
||||
*/
|
||||
public function testHasJokers($regex, $start, $end)
|
||||
{
|
||||
$expr = new Expression($regex);
|
||||
|
||||
$this->assertEquals($start, $expr->getRegex()->hasStartJoker());
|
||||
$this->assertEquals($end, $expr->getRegex()->hasEndJoker());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSetFlagsData
|
||||
*/
|
||||
public function testSetFlags($regex, $start, $end, $expected)
|
||||
{
|
||||
$expr = new Expression($regex);
|
||||
$expr->getRegex()->setStartFlag($start)->setEndFlag($end);
|
||||
|
||||
$this->assertEquals($expected, $expr->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSetJokersData
|
||||
*/
|
||||
public function testSetJokers($regex, $start, $end, $expected)
|
||||
{
|
||||
$expr = new Expression($regex);
|
||||
$expr->getRegex()->setStartJoker($start)->setEndJoker($end);
|
||||
|
||||
$this->assertEquals($expected, $expr->render());
|
||||
}
|
||||
|
||||
public function testOptions()
|
||||
{
|
||||
$expr = new Expression('~abc~is');
|
||||
$expr->getRegex()->removeOption('i')->addOption('m');
|
||||
|
||||
$this->assertEquals('~abc~sm', $expr->render());
|
||||
}
|
||||
|
||||
public function testMixFlagsAndJokers()
|
||||
{
|
||||
$expr = new Expression('~^.*abc.*$~is');
|
||||
|
||||
$expr->getRegex()->setStartFlag(false)->setEndFlag(false)->setStartJoker(false)->setEndJoker(false);
|
||||
$this->assertEquals('~abc~is', $expr->render());
|
||||
|
||||
$expr->getRegex()->setStartFlag(true)->setEndFlag(true)->setStartJoker(true)->setEndJoker(true);
|
||||
$this->assertEquals('~^.*abc.*$~is', $expr->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReplaceJokersTestData
|
||||
*/
|
||||
public function testReplaceJokers($regex, $expected)
|
||||
{
|
||||
$expr = new Expression($regex);
|
||||
$expr = $expr->getRegex()->replaceJokers('@');
|
||||
|
||||
$this->assertEquals($expected, $expr->renderPattern());
|
||||
}
|
||||
|
||||
public function getHasFlagsData()
|
||||
{
|
||||
return array(
|
||||
array('~^abc~', true, false),
|
||||
array('~abc$~', false, true),
|
||||
array('~abc~', false, false),
|
||||
array('~^abc$~', true, true),
|
||||
array('~^abc\\$~', true, false),
|
||||
);
|
||||
}
|
||||
|
||||
public function getHasJokersData()
|
||||
{
|
||||
return array(
|
||||
array('~.*abc~', true, false),
|
||||
array('~abc.*~', false, true),
|
||||
array('~abc~', false, false),
|
||||
array('~.*abc.*~', true, true),
|
||||
array('~.*abc\\.*~', true, false),
|
||||
);
|
||||
}
|
||||
|
||||
public function getSetFlagsData()
|
||||
{
|
||||
return array(
|
||||
array('~abc~', true, false, '~^abc~'),
|
||||
array('~abc~', false, true, '~abc$~'),
|
||||
array('~abc~', false, false, '~abc~'),
|
||||
array('~abc~', true, true, '~^abc$~'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getSetJokersData()
|
||||
{
|
||||
return array(
|
||||
array('~abc~', true, false, '~.*abc~'),
|
||||
array('~abc~', false, true, '~abc.*~'),
|
||||
array('~abc~', false, false, '~abc~'),
|
||||
array('~abc~', true, true, '~.*abc.*~'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getReplaceJokersTestData()
|
||||
{
|
||||
return array(
|
||||
array('~.abc~', '@abc'),
|
||||
array('~\\.abc~', '\\.abc'),
|
||||
array('~\\\\.abc~', '\\\\@abc'),
|
||||
array('~\\\\\\.abc~', '\\\\\\.abc'),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user