Completed
Branch erdiko2 (40e193)
by John
04:03
created

HomepageTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 61.11 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 22
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetHomepageWithoutName() 8 8 1
A testGetHomepageWithGreeting() 7 7 1
A testPostHomepageNotAllowed() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Tests\Functional;
4
5
class HomepageTest extends BaseTestCase
6
{
7
    /**
8
     * Test that the index route returns a rendered response containing the text 'SlimFramework' but not a greeting
9
     */
10 View Code Duplication
    public function testGetHomepageWithoutName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
    {
12
        $response = $this->runApp('GET', '/');
13
14
        $this->assertEquals(200, $response->getStatusCode());
15
        $this->assertContains('SlimFramework', (string)$response->getBody());
16
        $this->assertNotContains('Hello', (string)$response->getBody());
17
    }
18
19
    /**
20
     * Test that the index route with optional name argument returns a rendered greeting
21
     */
22 View Code Duplication
    public function testGetHomepageWithGreeting()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        $response = $this->runApp('GET', '/name');
25
26
        $this->assertEquals(200, $response->getStatusCode());
27
        $this->assertContains('Hello name!', (string)$response->getBody());
28
    }
29
30
    /**
31
     * Test that the index route won't accept a post request
32
     */
33 View Code Duplication
    public function testPostHomepageNotAllowed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $response = $this->runApp('POST', '/', ['test']);
36
37
        $this->assertEquals(405, $response->getStatusCode());
38
        $this->assertContains('Method not allowed', (string)$response->getBody());
39
    }
40
}