Completed
Push — master ( 280e7c...a946e7 )
by litefeel
48:45 queued 23:46
created

Writing_On_GitHub_TestCase::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 68
Code Lines 63

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 63
nc 1
nop 0
dl 0
loc 68
rs 9.2447
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
abstract class Writing_On_GitHub_TestCase extends WP_HTTP_TestCase {
4
5
	/**
6
	 * @var string
7
	 */
8
	protected $data_dir;
9
10
	/**
11
	 * @var Writing_On_GitHub|Mockery\Mock
12
	 */
13
	protected $app;
14
15
	/**
16
	 * @var Writing_On_GitHub_Controller|Mockery\Mock
17
	 */
18
	protected $controller;
19
20
	/**
21
	 * @var Writing_On_GitHub_Request|Mockery\Mock
22
	 */
23
	protected $request;
24
25
	/**
26
	 * @var Writing_On_GitHub_Import|Mockery\Mock
27
	 */
28
	protected $import;
29
30
	/**
31
	 * @var Writing_On_GitHub_Export|Mockery\Mock
32
	 */
33
	protected $export;
34
35
	/**
36
	 * @var Writing_On_GitHub_Response|Mockery\Mock
37
	 */
38
	protected $response;
39
40
	/**
41
	 * @var Writing_On_GitHub_Payload|Mockery\Mock
42
	 */
43
	protected $payload;
44
45
	/**
46
	 * @var Writing_On_GitHub_Api|Mockery\Mock
47
	 */
48
	protected $api;
49
50
	/**
51
	 * @var Writing_On_GitHub_Semaphore|Mockery\Mock
52
	 */
53
	protected $semaphore;
54
55
	/**
56
	 * @var Writing_On_GitHub_Database|Mockery\Mock
57
	 */
58
	protected $database;
59
60
	/**
61
	 * @var Writing_On_GitHub_Post|Mockery\Mock
62
	 */
63
	protected $post;
64
65
	/**
66
	 * @var Writing_On_GitHub_Blob|Mockery\Mock
67
	 */
68
	protected $blob;
69
70
	/**
71
	 * @var Writing_On_GitHub_Cache|Mockery\Mock
72
	 */
73
	protected $api_cache;
74
75
	/**
76
	 * @var Writing_On_GitHub_Fetch_Client|Mockery\Mock
77
	 */
78
	protected $fetch;
79
80
	/**
81
	 * @var Writing_On_GitHub_Persist_Client|Mockery\Mock
82
	 */
83
	protected $persist;
84
85
	public function setUp() {
86
		parent::setUp();
87
88
		$this->data_dir = dirname( __DIR__ ) . '/data/';
89
90
		$this->app        = Mockery::mock( 'Writing_On_GitHub' );
91
		$this->controller = Mockery::mock( 'Writing_On_GitHub_Controller' );
92
		$this->request    = Mockery::mock( 'Writing_On_GitHub_Request' );
93
		$this->import     = Mockery::mock( 'Writing_On_GitHub_Import' );
94
		$this->export     = Mockery::mock( 'Writing_On_GitHub_Export' );
95
		$this->response   = Mockery::mock( 'Writing_On_GitHub_Response' );
96
		$this->payload    = Mockery::mock( 'Writing_On_GitHub_Payload' );
97
		$this->api        = Mockery::mock( 'Writing_On_GitHub_Api' );
98
		$this->semaphore  = Mockery::mock( 'Writing_On_GitHub_Semaphore' );
99
		$this->database   = Mockery::mock( 'Writing_On_GitHub_Database' );
100
		$this->post       = Mockery::mock( 'Writing_On_GitHub_Post' );
101
		$this->blob       = Mockery::mock( 'Writing_On_GitHub_Blob' );
102
		$this->api_cache  = Mockery::mock( 'Writing_On_GitHub_Cache' );
103
		$this->fetch      = Mockery::mock( 'Writing_On_GitHub_Fetch_Client' );
104
		$this->persist    = Mockery::mock( 'Writing_On_GitHub_Persist_Client' );
105
106
		Writing_On_GitHub::$instance = $this->app;
107
108
		$this->app
109
			->shouldReceive( 'request' )
110
			->andReturn( $this->request )
111
			->byDefault();
112
		$this->app
113
			->shouldReceive( 'import' )
114
			->andReturn( $this->import )
115
			->byDefault();
116
		$this->app
117
			->shouldReceive( 'export' )
118
			->andReturn( $this->export )
119
			->byDefault();
120
		$this->app
121
			->shouldReceive( 'response' )
122
			->andReturn( $this->response )
123
			->byDefault();
124
		$this->app
125
			->shouldReceive( 'api' )
126
			->andReturn( $this->api )
127
			->byDefault();
128
		$this->app
129
			->shouldReceive( 'semaphore' )
130
			->andReturn( $this->semaphore )
131
			->byDefault();
132
		$this->app
133
			->shouldReceive( 'database' )
134
			->andReturn( $this->database )
135
			->byDefault();
136
		$this->app
137
			->shouldReceive( 'blob' )
138
			->andReturn( $this->blob )
139
			->byDefault();
140
		$this->app
141
			->shouldReceive( 'cache' )
142
			->andReturn( $this->api_cache )
143
			->byDefault();
144
		$this->api
145
			->shouldReceive( 'fetch' )
146
			->andReturn( $this->fetch )
147
			->byDefault();
148
		$this->api
149
			->shouldReceive( 'persist' )
150
			->andReturn( $this->persist )
151
			->byDefault();
152
	}
153
154
	public function tearDown() {
155
		Mockery::close();
156
	}
157
}
158