65 lines
2 KiB
Plaintext
65 lines
2 KiB
Plaintext
<?php
|
|
|
|
namespace Trinity\Bundle\ContentManagerBundle\Tests\Page;
|
|
|
|
use \Trinity\Bundle\ContentManagerBundle\Page\DecoratorStrategy;
|
|
use \Symfony\Component\HttpFoundation\Request;
|
|
|
|
class DecoratorStrategyTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function provideInvalidRequests()
|
|
{
|
|
return array(
|
|
array(new Request()),
|
|
array(Request::create('/admin/book')),
|
|
array(Request::create('/library','GET',array('_route' => 'test')))
|
|
);
|
|
}
|
|
|
|
public function provideValidRequests()
|
|
{
|
|
return array(
|
|
array(Request::create('/book','GET',array('_route' => 'book'))),
|
|
array(Request::create('/page','GET',array('_route' => 'cms_route_9')))
|
|
);
|
|
}
|
|
|
|
public function testIsRouteNameDecorable()
|
|
{
|
|
$strategy = new DecoratorStrategy(array('test'), array('test[0-2]{1}'), array());
|
|
|
|
$this->assertFalse($strategy->isRouteNameDecorable(null));
|
|
$this->assertFalse($strategy->isRouteNameDecorable('test'));
|
|
$this->assertFalse($strategy->isRouteNameDecorable('test2'));
|
|
$this->assertTrue($strategy->isRouteNameDecorable('test3'));
|
|
}
|
|
|
|
public function testIsRouteUriDecorable()
|
|
{
|
|
$strategy = new DecoratorStrategy(array(), array(), array('/admin/(.)*'));
|
|
|
|
$this->assertFalse($strategy->isRouteUriDecorable('/admin/book'));
|
|
$this->assertTrue($strategy->isRouteUriDecorable('/book'));
|
|
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideInvalidRequests
|
|
*/
|
|
public function testIsRequestDecorableNoMatch($request)
|
|
{
|
|
$strategy = new DecoratorStrategy(array('test'), array('test[0-2]{1}'), array('/admin/(.)*'));
|
|
|
|
$this->assertFalse($strategy->isRequestDecorable($request));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideValidRequests
|
|
*/
|
|
public function testIsRequestDecorableMatch($request)
|
|
{
|
|
$strategy = new DecoratorStrategy(array('test'), array('test[0-2]{1}'), array('/admin/(.)*'));
|
|
|
|
$this->assertTrue($strategy->isRequestDecorable($request));
|
|
}
|
|
} |