Passed
Push — master ( 448b7a...b9bdf6 )
by Jean Paul
07:33
created

StackOverflowWebPageSourceTest::testGetResults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Coco\SourceWatcher\Tests\Vendors\StackOverflow;
4
5
use Coco\SourceWatcher\Core\SourceWatcherException;
6
use Coco\SourceWatcher\Vendors\StackOverflow\StackOverflowWebPageSource;
7
use PHPUnit\Framework\TestCase;
8
9
class StackOverflowWebPageSourceTest extends TestCase
10
{
11
    public function testGetResults () : void
12
    {
13
        $url = "https://stackoverflow.com/jobs?q=PHP&l=Florida+USA&d=100&u=Miles";
14
15
        $webPageSource = new StackOverflowWebPageSource( $url );
16
17
        $results = $webPageSource->getResults();
18
        $this->assertNotNull( $results );
19
        $this->assertNotEmpty( $results );
20
    }
21
22
    public function testGetResultsChangeUrlAfterInstance () : void
23
    {
24
        $url = "https://stackoverflow.com/jobs?q=PHP&l=Florida+USA&d=100&u=Miles";
25
        $webPageSource = new StackOverflowWebPageSource( $url );
26
27
        $url = "https://stackoverflow.com/jobs?q=Java&l=Florida+USA&d=100&u=Miles";
28
        $webPageSource->setUrl( $url );
29
30
        $results = $webPageSource->getResults();
31
        $this->assertNotNull( $results );
32
        $this->assertNotEmpty( $results );
33
    }
34
35
    public function testGetResultsOnEmptyUrl () : void
36
    {
37
        $this->expectException( SourceWatcherException::class );
38
39
        $webPageSource = new StackOverflowWebPageSource( "" );
40
        $webPageSource->getResults();
41
    }
42
}
43