UrlTest4GetBaseUrl   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 162
Duplicated Lines 54.32 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 10
c 4
b 2
f 1
lcom 0
cbo 1
dl 88
loc 162
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A test_GetBaseUrl_WithoutArg() 0 6 1
A test_GetBaseUrl_WithNormalPart1() 11 11 1
A test_GetBaseUrl_WithNormalPart2() 11 11 1
A test_GetBaseUrl_WithNormalPart3() 11 11 1
A test_GetBaseUrl_WithSslPart1() 11 11 1
A test_GetBaseUrl_WithSslPart2() 11 11 1
A test_GetBaseUrl_WithNotStdPortPart1() 11 11 1
A test_GetBaseUrl_WithNotStdPortPart2() 11 11 1
A test_GetBaseUrl_WithNotStdPortPart3() 11 11 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
 * UrlTest4GetBaseUrl
4
 *
5
 * Url::GetBaseUrl用テストケース
6
 *
7
 * @package           risoluto
8
 * @author            Risoluto Developers
9
 * @license           http://opensource.org/licenses/bsd-license.php new BSD license
10
 * @copyright     (C) 2008-2015 Risoluto Developers / All Rights Reserved.
11
 */
12
13
//------------------------------------------------------//
14
// 名前空間の定義
15
//------------------------------------------------------//
16
namespace Risoluto;
17
18
//------------------------------------------------------//
19
// テストクラス定義
20
//------------------------------------------------------//
21
class UrlTest4GetBaseUrl extends \PHPUnit_Framework_TestCase
22
{
23
    //------------------------------------------------------//
24
    // テストメソッド定義
25
    //------------------------------------------------------//
26
    /**
27
     * setUp()
28
     *
29
     * テストに必要な準備を実施
30
     */
31
    protected function setUp()
32
    {
33
    }
34
35
    /**
36
     * test_GetBaseUrl_WithoutArg()
37
     *
38
     * getBaseUrl()の動作をテストする(引数なし)
39
     */
40
    public function test_GetBaseUrl_WithoutArg()
41
    {
42
        $want = 'http://localhost/';
43
44
        $this->assertEquals( Url::getBaseUrl(), $want );
45
    }
46
47
    /**
48
     * test_GetBaseUrl_WithNormalPart1()
49
     *
50
     * getBaseUrl()の動作をテストする(ノーマルな指定その1)
51
     */
52 View Code Duplication
    public function test_GetBaseUrl_WithNormalPart1()
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...
53
    {
54
        $test = [
55
            'HTTP_HOST' => 'example.com',
56
            'SERVER_PORT' => '80',
57
            'PHP_SELF' => '/index.html',
58
        ];
59
        $want = 'http://example.com/index.html';
60
61
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
62
    }
63
64
    /**
65
     * test_GetBaseUrl_WithNormalPart2()
66
     *
67
     * getBaseUrl()の動作をテストする(ノーマルな指定その2)
68
     */
69 View Code Duplication
    public function test_GetBaseUrl_WithNormalPart2()
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...
70
    {
71
        $test = [
72
            'HTTP_HOST' => 'example.com',
73
            'SERVER_PORT' => '80',
74
            'PHP_SELF' => '/test.php',
75
        ];
76
        $want = 'http://example.com/test.php';
77
78
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
79
    }
80
81
    /**
82
     * test_GetBaseUrl_WithNormalPart3()
83
     *
84
     * getBaseUrl()の動作をテストする(ノーマルな指定その3)
85
     */
86 View Code Duplication
    public function test_GetBaseUrl_WithNormalPart3()
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...
87
    {
88
        $test = [
89
            'HTTP_HOST' => 'example.com',
90
            'SERVER_PORT' => '80',
91
            'PHP_SELF' => '/index.php',
92
        ];
93
        $want = 'http://example.com/';
94
95
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
96
    }
97
98
    /**
99
     * test_GetBaseUrl_WithSslPart1()
100
     *
101
     * getBaseUrl()の動作をテストする(SSLな指定その1)
102
     */
103 View Code Duplication
    public function test_GetBaseUrl_WithSslPart1()
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...
104
    {
105
        $test = [
106
            'HTTP_HOST' => 'example.com',
107
            'SERVER_PORT' => '443',
108
            'PHP_SELF' => '/index.html',
109
        ];
110
        $want = 'https://example.com/index.html';
111
112
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
113
    }
114
115
    /**
116
     * test_GetBaseUrl_WithSslPart2()
117
     *
118
     * getBaseUrl()の動作をテストする(SSLな指定その2)
119
     */
120 View Code Duplication
    public function test_GetBaseUrl_WithSslPart2()
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...
121
    {
122
        $test = [
123
            'HTTP_HOST' => 'example.com',
124
            'SERVER_PORT' => '443',
125
            'PHP_SELF' => '/test.php',
126
        ];
127
        $want = 'https://example.com/test.php';
128
129
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
130
    }
131
132
    /**
133
     * test_GetBaseUrl_WithNotStdPortPart1()
134
     *
135
     * getBaseUrl()の動作をテストする(8000ポートを指定)
136
     */
137 View Code Duplication
    public function test_GetBaseUrl_WithNotStdPortPart1()
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...
138
    {
139
        $test = [
140
            'HTTP_HOST' => 'example.com',
141
            'SERVER_PORT' => '8080',
142
            'PHP_SELF' => '/index.html',
143
        ];
144
        $want = 'http://example.com:8080/index.html';
145
146
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
147
    }
148
149
    /**
150
     * test_GetBaseUrl_WithNotStdPortPart2()
151
     *
152
     * getBaseUrl()の動作をテストする(8443ポートを指定)
153
     */
154 View Code Duplication
    public function test_GetBaseUrl_WithNotStdPortPart2()
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...
155
    {
156
        $test = [
157
            'HTTP_HOST' => 'example.com',
158
            'SERVER_PORT' => '8443',
159
            'PHP_SELF' => '/index.html',
160
        ];
161
        $want = 'https://example.com:8443/index.html';
162
163
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
164
    }
165
166
    /**
167
     * test_GetBaseUrl_WithNotStdPortPart3()
168
     *
169
     * getBaseUrl()の動作をテストする(8888ポートを指定)
170
     */
171 View Code Duplication
    public function test_GetBaseUrl_WithNotStdPortPart3()
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...
172
    {
173
        $test = [
174
            'HTTP_HOST' => 'example.com',
175
            'SERVER_PORT' => '8888',
176
            'PHP_SELF' => '/index.html',
177
        ];
178
        $want = 'http://example.com:8888/index.html';
179
180
        $this->assertEquals( Url::getBaseUrl( $test ), $want );
181
    }
182
}