for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DkplusTest\CsrfApiUnprotectionBundle\UnprotectionRule;
use Dkplus\CsrfApiUnprotectionBundle\UnprotectionRule\UnprotectionRule;
use Dkplus\CsrfApiUnprotectionBundle\UnprotectionRule\UriPatterns;
use PHPUnit_Framework_TestCase as TestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* @covers Dkplus\CsrfApiUnprotectionBundle\UnprotectionRule\UriPatterns
*/
class UriPatternsTest extends TestCase
{
public function testItShouldBeARequestMatcher()
$this->assertInstanceOf(UnprotectionRule::class, new UriPatterns([]));
}
* @dataProvider provideMatchingUris
*
* @param string $uri
public function testItShouldAllowUrisThatPassesOneOfTheExpressions($uri)
$rule = new UriPatterns(['/^\/api\/.*$/', '/^\/app_dev.php\/api\/.*$/']);
$this->assertTrue($rule->matches(Request::create($uri)));
public static function provideMatchingUris()
return [
['/api/'],
['/app_dev.php/api/'],
['/api/foo/bar'],
];
* @dataProvider provideNonMatchingUris
public function testItShouldDenyUrisThatPassesNoneOfTheExpressions($uri)
$this->assertFalse($rule->matches(Request::create($uri)));
public static function provideNonMatchingUris()
['/app_test.php\/api/'],
['/apis/foo/bar'],