|
1
|
|
|
<?php declare( strict_types = 1 ); |
|
2
|
|
|
|
|
3
|
|
|
namespace Coco\SourceWatcher\Tests\Watcher\Source; |
|
4
|
|
|
|
|
5
|
|
|
use Coco\SourceWatcher\Watcher\Handler\WebPageHandler; |
|
6
|
|
|
use Coco\SourceWatcher\Watcher\Source\WebPageSource; |
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class WebPageSourceTest |
|
11
|
|
|
* @package Coco\SourceWatcher\Tests\Watcher\Source |
|
12
|
|
|
*/ |
|
13
|
|
|
class WebPageSourceTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* |
|
17
|
|
|
*/ |
|
18
|
|
|
public function testSetGetUrl () : void |
|
19
|
|
|
{ |
|
20
|
|
|
$givenURL = "http://localhost/"; |
|
21
|
|
|
$expectedURL = "http://localhost/"; |
|
22
|
|
|
|
|
23
|
|
|
$webPageSource = new WebPageSource( $givenURL ); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertNotNull( $webPageSource->getUrl() ); |
|
26
|
|
|
$this->assertNotEmpty( $webPageSource->getUrl() ); |
|
27
|
|
|
$this->assertEquals( $expectedURL, $webPageSource->getUrl() ); |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$webPageSource->setUrl( $givenURL ); |
|
31
|
|
|
|
|
32
|
|
|
$this->assertNotNull( $webPageSource->getUrl() ); |
|
33
|
|
|
$this->assertNotEmpty( $webPageSource->getUrl() ); |
|
34
|
|
|
$this->assertEquals( $expectedURL, $webPageSource->getUrl() ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testSetGetHandler () : void |
|
41
|
|
|
{ |
|
42
|
|
|
$webPageSource = new WebPageSource( "http://localhost/" ); |
|
43
|
|
|
|
|
44
|
|
|
$givenHandler = $this->createMock( WebPageHandler::class ); |
|
45
|
|
|
$expectedHandler = $this->createMock( WebPageHandler::class ); |
|
46
|
|
|
|
|
47
|
|
|
$webPageSource->setHandler( $givenHandler ); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertNotNull( $webPageSource->getHandler() ); |
|
50
|
|
|
$this->assertEquals( $expectedHandler, $webPageSource->getHandler() ); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|