forked from drupalsocialinitiative/social_api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocialApiDataHandlerTest.php
More file actions
61 lines (48 loc) · 1.46 KB
/
SocialApiDataHandlerTest.php
File metadata and controls
61 lines (48 loc) · 1.46 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
<?php
use Drupal\social_api\SocialApiDataHandler;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Drupal\Tests\UnitTestCase;
/**
* Defines SocialApiDataHandler class.
*
* @Annotation
*/
class SocialApiDataHandlerTest extends UnitTestCase {
/**
* Interface for the session.
*
* @var \Symfony\Component\HttpFoundation\Session\SessionInterface
*/
protected $session;
/**
* Variables are written to and read from session via this class.
*
* @var \Drupal\social_api\SocialApiDataHandler
*/
protected $socialApiDataHandler;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->session = $this->getMock(SessionInterface::class);
$this->socialApiDataHandler = $this->getMockBuilder(SocialApiDataHandler::class)
->setConstructorArgs([$this->session])
->setMethods(NULL)
->getMockForAbstractClass();
}
/**
* Tests for class SocialApiDataHandler.
*/
public function testSocialApiDataHandler() {
$key = "drupal";
$value = "drupal123";
$this->socialApiDataHandler->set($key, $value);
$this->socialApiDataHandler->setSessionPrefix('1234');
$this->session->expects($this->any())
->method('get')
->willReturn($this->socialApiDataHandler->getSessionPrefix() . $key);
$this->assertEquals('1234_', $this->socialApiDataHandler->getSessionPrefix());
$this->assertEquals('1234_drupal', $this->socialApiDataHandler->get($key));
}
}