-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathHandlerBaseTest.php
More file actions
71 lines (57 loc) · 1.72 KB
/
HandlerBaseTest.php
File metadata and controls
71 lines (57 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
use phpWhois\Handler\HandlerBase;
use phpWhois\Provider\ProviderAbstract;
use phpWhois\Query;
class HandlerBaseMock extends HandlerBase {
public $server = 'whois.server.test';
}
class HandlerBaseTest extends \PHPUnit_Framework_TestCase
{
protected $query;
protected $handler;
public function setUp()
{
$this->query = new Query('www.goOgle.com');
$this->handler = new HandlerBaseMock($this->query);
}
public function testConstructorWithoutServer()
{
$handler = new HandlerBaseMock($this->query);
$this->assertEquals('whois.server.test', $handler->server);
$this->assertInstanceOf(ProviderAbstract::class, $handler->getProvider());
}
/**
* Test constructor with all possible parameters
*/
public function testConstructorWithServer()
{
$server = 'special.whois.server.test';
$handler = new HandlerBaseMock($this->query, $server);
$this->assertEquals($server, $handler->server);
$this->assertInstanceOf(ProviderAbstract::class, $handler->getProvider());
}
/**
* TODO: Test Provider setting by class name
*/
/**
* Test splitting raw data by newline
*
* @param $raw Raw data
* @param $count Number of rows
* @dataProvider rawProvider
*/
public function testSplitRows($raw, $count)
{
$this->assertCount($count, $this->handler->splitRows($raw));
}
public function rawProvider()
{
return [
["line1\nline2\nline3", 3],
["line1\r\nline2\r\nline3", 3],
["line1\r\nline2\r\nline3", 3],
["line1\r\n\r\nline2\r\nline3", 4],
["line1\r\n\n\r\nline2\r\nline3", 5],
];
}
}