[HttpFoundation] refactor RequestMatcherTest to use dataProvider
This commit is contained in:
parent
e5b923a0ec
commit
5a80c2ff17
@ -16,19 +16,26 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class RequestMatcherTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIp()
|
||||
/**
|
||||
* @dataProvider testIpProvider
|
||||
*/
|
||||
public function testIp($matches, $remoteAddr, $cidr)
|
||||
{
|
||||
$request = Request::create('', 'get', array(), array(), array(), array('REMOTE_ADDR' => $remoteAddr));
|
||||
|
||||
$matcher = new RequestMatcher();
|
||||
$matcher->matchIp($cidr);
|
||||
|
||||
$matcher->matchIp('192.168.1.1/1');
|
||||
$request = Request::create('', 'get', array(), array(), array(), array('REMOTE_ADDR' => '192.168.1.1'));
|
||||
$this->assertTrue($matcher->matches($request));
|
||||
$this->assertEquals($matches, $matcher->matches($request));
|
||||
}
|
||||
|
||||
$matcher->matchIp('192.168.1.0/24');
|
||||
$this->assertTrue($matcher->matches($request));
|
||||
|
||||
$matcher->matchIp('1.2.3.4/1');
|
||||
$this->assertFalse($matcher->matches($request));
|
||||
public function testIpProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, '192.168.1.1', '192.168.1.1/1'),
|
||||
array(true, '192.168.1.1', '192.168.1.0/24'),
|
||||
array(false, '192.168.1.1', '1.2.3.4/1'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testMethod()
|
||||
|
Reference in New Issue
Block a user