Completed
Push — add/magic-link-for-mobile ( a67c5b...4ebb52 )
by
unknown
13:24 queued 06:01
created

ManagerTest::test_is_active_when_connected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Connection;
4
5
use PHPUnit\Framework\TestCase;
6
7
class ManagerTest extends TestCase {
8
	public function setUp() {
9
		$this->manager = $this->getMockBuilder( 'Automattic\Jetpack\Connection\Manager' )
10
		                      ->setMethods( [ 'get_access_token' ] )
11
		                      ->getMock();
12
	}
13
14
	public function tearDown() {
15
		unset( $this->manager );
16
	}
17
18
	function test_class_implements_interface() {
19
		$manager = new Manager();
20
		$this->assertInstanceOf( 'Automattic\Jetpack\Connection\Manager_Interface', $manager );
21
	}
22
23
	/**
24
	 * @covers Automattic\Jetpack\Connection\Manager::is_active
25
	 */
26
	public function test_is_active_when_connected() {
27
		$access_token = (object) [
28
			'secret'           => 'abcd1234',
29
			'external_user_id' => 1,
30
		];
31
		$this->manager->expects( $this->once() )
32
		              ->method( 'get_access_token' )
33
		              ->will( $this->returnValue( $access_token ) );
34
35
		$this->assertTrue( $this->manager->is_active() );
36
	}
37
38
	/**
39
	 * @covers Automattic\Jetpack\Connection\Manager::is_active
40
	 */
41
	public function test_is_active_when_not_connected() {
42
		$this->manager->expects( $this->once() )
43
		              ->method( 'get_access_token' )
44
		              ->will( $this->returnValue( false ) );
45
46
		$this->assertFalse( $this->manager->is_active() );
47
	}
48
}
49