Completed
Pull Request — master (#513)
by Helpful
04:05
created

DeploynautTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
abstract class DeploynautTest extends SapphireTest {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	/**
6
	 * @var string
7
	 */
8
	protected $envPath = '';
9
10
	/**
11
	 * Setup the environment to point to a temporary location
12
	 *
13
	 * @param string $path
14
	 */
15
	protected function setTemporaryPath($path) {
16
		$this->envPath = $path;
17
		Filesystem::makeFolder($this->envPath);
18
		$this->envPath = realpath($this->envPath);
19
		Injector::inst()->load(array(
20
			'DNData' => array(
21
				'properties' => array(
22
					'EnvironmentDir' => $this->envPath,
23
					'KeyDir' => TEMP_FOLDER .'/deploynaut_test/gitkeys',
24
					'DataTransferDir' => Director::baseFolder() . '/assets/transfers',
25
					'GitUser' => ''
26
				)
27
			)
28
		));
29
	}
30
31
	public function setUp() {
32
		parent::setUp();
33
		SS_Datetime::clear_mock_now();
34
		Injector::nest();
35
		Injector::inst()->load(array(
36
			'DNProject' => 'DeploynautTest_Project',
37
		));
38
39
		// Set temp location
40
		$this->setTemporaryPath(TEMP_FOLDER . '/deploynaut_test/envs');
41
	}
42
43
	public function tearDown() {
44
		Injector::unnest();
45
		SS_Datetime::clear_mock_now();
46
47
		if($this->envPath) {
48
			Filesystem::removeFolder($this->envPath);
49
			$this->envPath = null;
50
		}
51
52
		parent::tearDown();
53
	}
54
}
55
56
class DeploynautTest_Project extends DNProject implements TestOnly {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
57
58
	protected function checkCVSPath() {
59
		// Don't initialise resque task to query git during tests
60
	}
61
}
62