-
Notifications
You must be signed in to change notification settings - Fork 2
/
SiteTest.php
70 lines (59 loc) · 2.11 KB
/
SiteTest.php
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
<?php
/**
* @package Outpost
* @author Pixo <[email protected]>
* @copyright 2015, Pixo
* @license http://opensource.org/licenses/NCSA NCSA
*/
namespace Outpost;
use Monolog\Handler\TestHandler;
use Outpost\Mocks\Environments\Environment;
use Stash\Driver\Ephemeral;
class SiteTest extends \PHPUnit_Framework_TestCase {
public function testGetSiteCache() {
$environment = $this->makeEnvironment();
$site = new TestSite($environment);
$this->assertInstanceOf("Outpost\\Cache\\Cache", $site->getCache());
}
public function testGetSiteCacheCache() {
$environment = $this->makeEnvironment();
$site = new TestSite($environment);
$this->assertInstanceOf("Stash\\Pool", $site->getCache()->getCache());
}
public function testGetSiteCacheDriver() {
$environment = $this->makeEnvironment();
$site = new TestSite($environment);
$this->assertSame($environment->cacheDriver, $site->getCache()->getCache()->getDriver());
}
public function testGetSiteClient() {
$environment = $this->makeEnvironment();
$site = new TestSite($environment);
$this->assertInstanceOf("Outpost\\Web\\Client", $site->getClient());
}
public function testGetSiteLog() {
$environment = $this->makeEnvironment();
$site = new TestSite($environment);
$this->assertInstanceOf("Monolog\\Logger", $site->getLog());
/** @var \Monolog\Logger $log */
$log = $site->getLog();
$this->assertEquals($environment->logHandlers, $log->getHandlers());
}
public function testGetResource() {
$environment = $this->makeEnvironment();
$site = new TestSite($environment);
$resourceSite = null;
$result = "This is the resource result";
$resource = function ($site) use ($result, &$resourceSite) { $resourceSite = $site; return $result; };
$this->assertEquals($result, $site->get($resource));
$this->assertEquals($site, $resourceSite);
}
/**
* @return Environment
*/
protected function makeEnvironment() {
$environment = new Environment();
$environment->cacheDriver = new Ephemeral();
$environment->logHandlers = [new TestHandler()];
return $environment;
}
}