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

StackOverflowWebPageSourceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 32
rs 10
c 3
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetResultsChangeUrlAfterInstance() 0 11 1
A testGetResults() 0 9 1
A testGetResultsOnEmptyUrl() 0 6 1
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