forked from drupalsocialinitiative/social_api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginTest.php
More file actions
107 lines (98 loc) · 3.18 KB
/
PluginTest.php
File metadata and controls
107 lines (98 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
use Drupal\social_api\Plugin\NetworkManager;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\social_api\Plugin\NetworkInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Tests\UnitTestCase;
/**
* Defines Social Network.
*
* @Annotation
*/
class PluginTest extends UnitTestCase {
/**
* Define __construct function.
*/
public function __construct() {
parent::__construct();
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
}
/**
* Tests for class NetworkManager.
*/
public function testNetworkManager() {
$namespaces = $this->createMock(Traversable::class);
$cache_backend = $this->createMock(CacheBackendInterface::class);
$module_handler = $this->createMock(ModuleHandlerInterface::class);
$networkManager = $this->getMockBuilder(NetworkManager::class)
->setConstructorArgs(array($namespaces, $cache_backend, $module_handler))
->getMock();
parent::__construct();
$this->assertTrue($networkManager instanceof NetworkManager);
$this->assertTrue(
method_exists($networkManager, 'setCacheBackend'),
'NetworkManager does not implements setCacheBackend function/method'
);
$this->assertTrue(
method_exists($networkManager, 'alterInfo'),
'NetworkManager does not implements alterInfo function/method'
);
}
/**
* Tests for class NetworkInterface.
*/
public function testNetworkInterface() {
$networkInterface = $this->createMock(NetworkInterface::class);
$this->assertTrue(
method_exists($networkInterface, 'authenticate'),
'NetworkManager does not implements authenticate function/method'
);
$this->assertTrue(
method_exists($networkInterface, 'getSdk'),
'NetworkManager does not implements getSdk function/method'
);
}
/**
* Tests for class NetworkBase.
*/
public function testNetworkBase() {
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$config_factory = $this->createMock(ConfigFactoryInterface::class);
$container = $this->createMock(ContainerInterface::class);
$configuration = array();
$plugin_definition = array();
$networkBase = $this->getMockBuilder('Drupal\social_api\Plugin\NetworkBase')
->setConstructorArgs(array($configuration,
'drupal123',
$plugin_definition,
$entity_type_manager,
$config_factory,
))
->setMethods(['getSdk', 'create'])
->getMockForAbstractClass();
$this->assertTrue(
method_exists($networkBase, 'init'),
'NetworkBase does not implements init function/method'
);
$this->assertTrue(
method_exists($networkBase, 'create'),
'NetworkBase does not implements create function/method'
);
$this->assertTrue(
method_exists($networkBase, 'authenticate'),
'NetworkBase does not implements authenticate function/method'
);
$this->assertTrue(
method_exists($networkBase, 'getSdk'),
'NetworkBase does not implements getSdk function/method'
);
}
}