mageekguy\atoum\scripts\builder\vcs\svn: lines coverage

83% of 232

OPs

93% of 41

Lines

68% of 41

Branches

36% of 22

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\scripts\builder\vcs\svn::__construct() 11 100% 2 100% 1 0% 1 100%
mageekguy\atoum\scripts\builder\vcs\svn::getNextRevisions() 93 80% 15 93% 21 71% 12 17%
mageekguy\atoum\scripts\builder\vcs\svn::exportRepository() 128 84% 24 92% 19 68% 9 56%
#
1
<?php
2

                    
3
namespace mageekguy\atoum\scripts\builder\vcs;
4

                    
5
use
6
	mageekguy\atoum,
7
	mageekguy\atoum\exceptions,
8
	mageekguy\atoum\scripts\builder
9
;
10

                    
11
class svn extends builder\vcs
12
{
13
	public function __construct(atoum\adapter $adapter = null)100%
14
	{
15
		parent::__construct($adapter);
16
	}
17

                    
18
	public function getNextRevisions()93%
19
	{
20
		if ($this->repositoryUrl === null)
21
		{
22
			throw new exceptions\runtime('Unable to get logs, repository url is undefined');
23
		}
24

                    
25
		if ($this->adapter->extension_loaded('svn') === false)
26
		{
27
			throw new exceptions\runtime('PHP extension svn is not available, please install it');
28
		}
29

                    
30
		$this->adapter->svn_auth_set_parameter(PHP_SVN_AUTH_PARAM_IGNORE_SSL_VERIFY_ERRORS, true);
31

                    
32
		$nextRevisions = array();
33

                    
34
		foreach ($this->adapter->svn_log($this->repositoryUrl, $this->revision ?: 1, \SVN_REVISION_HEAD) as $log)
35
		{
36
			if (is_array($log) && isset($log['rev']) === true && $log['rev'] != $this->revision)
37
			{
38
				$nextRevisions[] = $log['rev'];
39
			}
40
		}
41

                    
42
		return $nextRevisions;
43
	}
44

                    
45
	public function exportRepository()92%
46
	{
47
		if ($this->repositoryUrl === null)
48
		{
49
			throw new exceptions\runtime('Unable to export repository, repository url is undefined');
50
		}
51

                    
52
		if ($this->workingDirectory === null)
53
		{
54
			throw new exceptions\runtime('Unable to export repository, working directory is undefined');
55
		}
56

                    
57
		if ($this->adapter->extension_loaded('svn') === false)
58
		{
59
			throw new exceptions\runtime('PHP extension svn is not available, please install it');
60
		}
61

                    
62
		$this
63
			->cleanWorkingDirectory()
64
			->adapter->svn_auth_set_parameter(PHP_SVN_AUTH_PARAM_IGNORE_SSL_VERIFY_ERRORS, true)
65
		;
66

                    
67
		if ($this->username !== null)
68
		{
69
			$this->adapter->svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, $this->username);
70

                    
71
			if ($this->password !== null)
72
			{
73
				$this->adapter->svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, $this->password);
74
			}
75
		}
76

                    
77
		if ($this->adapter->svn_checkout($this->repositoryUrl, $this->workingDirectory, $this->revision) === false)
78
		{
79
			throw new exceptions\runtime('Unable to checkout repository \'' . $this->repositoryUrl . '\' in directory \'' . $this->workingDirectory . '\'');
80
		}
81

                    
82
		return $this;
83
	}
84
}