IPv4AddressTest::testMatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * Tests for IPv4Address
5
 *
6
 * @author Sam Stenvall <[email protected]>
7
 * @copyright Copyright &copy; Sam Stenvall 2014-
8
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
9
 */
10
class IPv4AddressTest extends DefinitionTest
11
{
12
13
	/**
14
	 * @expectedException InvalidArgumentException
15
	 */
16
	public function testEmptyDefinition()
17
	{
18
		$this->_definition = new \Whitelist\Definition\IPv4Address('');
19
	}
20
21
	/**
22
	 * @expectedException InvalidArgumentException
23
	 */
24
	public function testValidate()
25
	{
26
		$this->_definition = new \Whitelist\Definition\IPv4Address('not.an.ipv4.address');
27
	}
28
29
	/**
30
	 * @dataProvider provider
31
	 */
32
	public function testMatch($expected, $address)
33
	{
34
		$this->_definition = new \Whitelist\Definition\IPv4Address('192.168.1.1');
35
		$this->assertEquals($expected, $this->_definition->match($address));
36
	}
37
38
	public function provider()
39
	{
40
		return array(
41
			array(true, '192.168.1.1'),
42
			array(false, '192.168.1.2'),
43
		);
44
	}
45
46
}
47