1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Sergey Nehaenko <[email protected]> |
4
|
|
|
* @license GPL |
5
|
|
|
* @copyright Sergey Nehaenko © 2016 |
6
|
|
|
* @version 1.0 |
7
|
|
|
* @project browser-detector |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace EndorphinStudio\Tests; |
11
|
|
|
|
12
|
|
|
class DeviceTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
public function testIPhone() |
16
|
|
|
{ |
17
|
|
|
$ualist = array( |
18
|
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257', |
19
|
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4', |
20
|
|
|
'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3', |
21
|
|
|
'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3' |
22
|
|
|
); |
23
|
|
|
|
24
|
|
|
testUaList($this,'Device','Name',$ualist,'iPhone'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
View Code Duplication |
public function testIPad() |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$ualist = array( |
30
|
|
|
'Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25', |
31
|
|
|
'Mozilla/5.0 (iPad; CPU OS 6_1_2 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/25.0.1364.124 Mobile/10B146 Safari/8536.25', |
32
|
|
|
'Mozilla/5.0 (iPad; CPU OS 6_1_2 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B147 Safari/8536.25', |
33
|
|
|
'Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206' |
34
|
|
|
); |
35
|
|
|
|
36
|
|
|
testUaList($this,'Device','Name',$ualist,'iPad'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
View Code Duplication |
public function testLumia() |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
$ualist = array( |
42
|
|
|
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 625)', |
43
|
|
|
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 625H)', |
44
|
|
|
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 1520)', |
45
|
|
|
'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 900)' |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
testUaList($this,'Device','Name',$ualist,'Lumia'); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
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.