Completed
Push — master ( 2b4610...a5af43 )
by Robbie
02:08
created

BlogControllerFunctionalTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 46.67 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testGetCategoriesWithMultibyteUrl() 7 7 1
A testGetTagsWithMultibyteUrl() 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 SilverStripe\Blog\Tests\Model;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Dev\FunctionalTest;
7
use SilverStripe\i18n\i18n;
8
use SilverStripe\View\Parsers\URLSegmentFilter;
9
10
class BlogControllerFunctionalTest extends FunctionalTest
11
{
12
    protected static $fixture_file = 'BlogControllerFunctionalTest.yml';
13
14
    protected static $use_draft_site = true;
15
16
    protected function setUp()
17
    {
18
        Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true);
19
        i18n::set_locale('fa_IR');
20
21
        parent::setUp();
22
    }
23
24 View Code Duplication
    public function testGetCategoriesWithMultibyteUrl()
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...
25
    {
26
        $result = $this->get('my-blog/category/' . rawurlencode('آبید'));
27
28
        $this->assertEquals(200, $result->getStatusCode());
29
        $this->assertContains('آبید', $result->getBody());
30
    }
31
32 View Code Duplication
    public function testGetTagsWithMultibyteUrl()
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...
33
    {
34
        $result = $this->get('my-blog/tag/' . rawurlencode('برتراند'));
35
36
        $this->assertEquals(200, $result->getStatusCode());
37
        $this->assertContains('برتراند', $result->getBody());
38
    }
39
}
40