Passed
Push — master ( abed16...744134 )
by Ax
01:19
created

SleeperExceptionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSleeperHttpException() 0 10 1
A testBadMethodException() 0 6 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use SchoppAx\Sleeper\Sleeper;
5
use GuzzleHttp\Handler\MockHandler;
6
use GuzzleHttp\Psr7\Response;
7
use GuzzleHttp\Psr7\Request;
8
use GuzzleHttp\Exception\RequestException;
9
use GuzzleHttp\Exception\ClientException;
10
11
class SleeperExceptionTest extends TestCase
12
{
13
14
  public function testBadMethodException() {
15
    $client = new Sleeper();
16
17
    $this->expectException(BadMethodCallException::class);
18
19
    $testCls = $client->TestClass();
0 ignored issues
show
Bug introduced by
The method TestClass() does not exist on SchoppAx\Sleeper\Sleeper. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
    /** @scrutinizer ignore-call */ 
20
    $testCls = $client->TestClass();
Loading history...
Unused Code introduced by
The assignment to $testCls is dead and can be removed.
Loading history...
20
  }
21
22
  public function testSleeperHttpException() {
23
    $response = new GuzzleHttp\Psr7\Response(429, [], null);
24
    $mock = new GuzzleHttp\Handler\MockHandler([ $response, $response ]);
25
26
    $client = new Sleeper($mock);
27
28
    $this->expectException(ClientException::class);
29
    $this->expectExceptionMessage('Client error: `GET league/289646328504385536` resulted in a `429 Too Many Requests` response');
30
31
    $league = $client->leagues()->find('289646328504385536');
0 ignored issues
show
Unused Code introduced by
The assignment to $league is dead and can be removed.
Loading history...
Bug introduced by
The method leagues() does not exist on SchoppAx\Sleeper\Sleeper. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
    $league = $client->/** @scrutinizer ignore-call */ leagues()->find('289646328504385536');
Loading history...
32
  }
33
34
}
35