Completed
Pull Request — master (#78)
by Christophe
03:11
created

SauceLabsAPIClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 42.86%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 46
ccs 3
cts 7
cp 0.4286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getInfo() 0 4 1
A updateStatus() 0 4 1
1
<?php
2
/**
3
 * This file is part of the phpunit-mink library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/aik099/phpunit-mink
9
 */
10
11
namespace aik099\PHPUnit\APIClient;
12
13
14
use WebDriver\SauceLabs\SauceRest;
15
16
class SauceLabsAPIClient implements IAPIClient
17
{
18
19
	/**
20
	 * API client for SauceLabs service.
21
	 *
22
	 * @var SauceRest
23
	 */
24
	private $_sauceRest;
25
26
	/**
27
	 * Creates instance of API client.
28
	 *
29
	 * @param SauceRest $sauce_rest SauceRest client.
30
	 */
31 1
	public function __construct(SauceRest $sauce_rest)
32
	{
33 1
		$this->_sauceRest = $sauce_rest;
34 1
	}
35
36
	/**
37
	 * Returns information about session.
38
	 *
39
	 * @param string $session_id Session ID.
40
	 *
41
	 * @return array
42
	 */
43
	public function getInfo($session_id)
44
	{
45
		return $this->_sauceRest->getJob($session_id);
46
	}
47
48
	/**
49
	 * Update status of the test, that was executed in the given session.
50
	 *
51
	 * @param string  $session_id  Session ID.
52
	 * @param boolean $test_status Test status.
53
	 *
54
	 * @return array
55
	 */
56
	public function updateStatus($session_id, $test_status)
57
	{
58
		return $this->_sauceRest->updateJob($session_id, array('passed' => $test_status));
59
	}
60
61
}
62