HttpJsonApiTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testHttpJsonApiExercise() 0 25 1
1
<?php
2
3
4
namespace PhpSchool\LearnYouPhpTest\Exercise;
5
6
use PhpSchool\LearnYouPhp\Exercise\HttpJsonApi;
7
use PhpSchool\PhpWorkshop\Exercise\ExerciseType;
8
use PhpSchool\PhpWorkshop\Solution\SolutionInterface;
9
use PHPUnit\Framework\TestCase;
10
use Psr\Http\Message\RequestInterface;
11
12
/**
13
 * @author Aydin Hassan <[email protected]>
14
 */
15
class HttpJsonApiTest extends TestCase
16
{
17
    public function testHttpJsonApiExercise()
18
    {
19
        $e = new HttpJsonApi;
20
        $this->assertEquals('HTTP JSON API', $e->getName());
21
        $this->assertEquals('HTTP JSON API - Servers JSON when it receives a GET request', $e->getDescription());
22
        $this->assertEquals(ExerciseType::CGI, $e->getType());
23
24
        $requests = $e->getRequests();
25
        $request1 = $requests[0];
26
        $request2 = $requests[1];
27
        
28
        $this->assertInstanceOf(RequestInterface::class, $request1);
29
        $this->assertInstanceOf(RequestInterface::class, $request2);
30
        
31
        $this->assertSame('GET', $request1->getMethod());
32
        $this->assertSame('GET', $request2->getMethod());
33
        $this->assertSame('www.time.com', $request1->getUri()->getHost());
34
        $this->assertSame('www.time.com', $request2->getUri()->getHost());
35
        $this->assertSame('/api/parsetime', $request1->getUri()->getPath());
36
        $this->assertSame('/api/unixtime', $request2->getUri()->getPath());
37
38
        $this->assertInstanceOf(SolutionInterface::class, $e->getSolution());
39
        $this->assertFileExists(realpath($e->getProblem()));
40
        $this->assertNull($e->tearDown());
41
    }
42
}
43