Completed
Push — master ( 3aaa57...3b1bb7 )
by Aimeos
02:24
created

FlyCopyTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 81
Duplicated Lines 30.86 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 8
c 2
b 0
f 1
lcom 1
cbo 1
dl 25
loc 81
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 2
A testGetProvider() 0 8 1
A testGetProviderKey() 0 11 1
A testGetProviderSecret() 12 12 1
A testGetProviderToken() 13 13 1
A testGetProviderAccess() 0 18 2

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 Aimeos\MW\Filesystem;
4
5
6
class FlyCopyTest extends \PHPUnit_Framework_TestCase
7
{
8
	protected function setUp()
9
	{
10
		if( !interface_exists( '\\League\\Flysystem\\FilesystemInterface' ) ) {
11
			$this->markTestSkipped( 'Install Flysystem first' );
12
		}
13
	}
14
15
16
	public function testGetProvider()
17
	{
18
		$object = new FlyCopy( array() );
19
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
20
21
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
22
		$object->has( 'test' );
23
	}
24
25
26
	public function testGetProviderKey()
27
	{
28
		$config = array(
29
			'consumerkey' => 'test'
30
		);
31
		$object = new FlyCopy( $config );
32
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
33
34
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
35
		$object->has( 'test' );
36
	}
37
38
39 View Code Duplication
	public function testGetProviderSecret()
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...
40
	{
41
		$config = array(
42
			'consumerkey' => 'test',
43
			'consumersecret' => 'test',
44
		);
45
		$object = new FlyCopy( $config );
46
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
47
48
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
49
		$object->has( 'test' );
50
	}
51
52
53 View Code Duplication
	public function testGetProviderToken()
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...
54
	{
55
		$config = array(
56
			'consumerkey' => 'test',
57
			'consumersecret' => 'test',
58
			'accesstoken' => 'test',
59
		);
60
		$object = new FlyCopy( $config );
61
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
62
63
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
64
		$object->has( 'test' );
65
	}
66
67
68
	public function testGetProviderAccess()
69
	{
70
		if( !class_exists( '\League\Flysystem\Copy\CopyAdapter' ) ) {
71
			$this->markTestSkipped( 'Install Flysystem Copy adapter' );
72
		}
73
74
		$config = array(
75
			'consumerkey' => 'test',
76
			'consumersecret' => 'test',
77
			'accesstoken' => 'test',
78
			'tokensecret' => 'test',
79
		);
80
		$object = new FlyCopy( $config );
81
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
82
83
		$this->setExpectedException( 'Exception' );
84
		$object->has( 'test' );
85
	}
86
}
87