Passed
Push — master ( 0aa43e...eaba1f )
by Jean Paul
06:20
created

ApiReaderTest::testGetExceptionFromNoResourceURL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php declare( strict_types = 1 );
2
3
namespace Coco\SourceWatcher\Tests\Core\Api;
4
5
use Coco\SourceWatcher\Core\Api\ApiReader;
6
use Coco\SourceWatcher\Core\SourceWatcherException;
7
use Coco\SourceWatcher\Utils\i18n;
8
use PHPUnit\Framework\TestCase;
9
10
class ApiReaderTest extends TestCase
11
{
12
    public function testSetGetResourceURL () : void
13
    {
14
        $apiReader = new ApiReader();
15
16
        $givenResourceURL = "https://api.github.com/emojis";
17
        $expectedResourceURL = "https://api.github.com/emojis";
18
19
        $apiReader->setResourceURL( $givenResourceURL );
20
21
        $this->assertEquals( $expectedResourceURL, $apiReader->getResourceURL() );
22
    }
23
24
    public function testSetGetTimeout () : void
25
    {
26
        $apiReader = new ApiReader();
27
28
        $givenTimeout = 10;
29
        $expectedTimeout = 10;
30
31
        $apiReader->setTimeout( $givenTimeout );
32
33
        $this->assertEquals( $expectedTimeout, $apiReader->getTimeout() );
34
    }
35
36
    /**
37
     * @throws SourceWatcherException
38
     */
39
    public function testGetExceptionFromNoResourceURL () : void
40
    {
41
        $apiReader = new ApiReader();
42
43
        $this->expectException( SourceWatcherException::class );
44
        $this->expectExceptionMessage( i18n::getInstance()->getText( "en_US", ApiReader::class, "No_Resource_URL_Found" ) );
45
46
        $apiReader->read();
47
    }
48
}
49