-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryCacheBuilderTest.php
More file actions
69 lines (56 loc) · 1.77 KB
/
QueryCacheBuilderTest.php
File metadata and controls
69 lines (56 loc) · 1.77 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
<?php
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
use SimpleSoftwareIO\Cache\QueryCache;
use SimpleSoftwareIO\Cache\QueryCacheBuilder;
class QueryCacheBuilderTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
Mockery::close();
}
public function setUp()
{
$this->queryCache = Mockery::mock(QueryCache::class);
$connection = Mockery::mock(ConnectionInterface::class);
$gramma = Mockery::mock(Grammar::class);
$processor = Mockery::mock(Processor::class);
$this->builder = new QueryCacheBuilder($this->queryCache, $connection, $gramma, $processor);
}
/** @test */
public function get_returns_the_queried_results()
{
$this->queryCache->shouldReceive('get')
->once();
$this->builder->get();
}
/** @test */
public function remember_enables_caching_with_the_correct_length()
{
$this->queryCache->shouldReceive('length')
->withArgs(['30'])
->once();
$this->builder->remember(30);
}
/** @test */
public function remember_forever_saves_the_query_for_10_years()
{
$this->queryCache->shouldReceive('length')
->withArgs(['5256000']) //10 years in minutes
->once();
$this->builder->rememberForever();
}
/** @test */
public function dont_remember_disables_caching()
{
$this->queryCache->shouldReceive('disable')
->once();
$this->builder->dontRemember();
}
/** @test */
public function new_query_returns_a_new_static()
{
$this->isInstanceOf(QueryCacheBuilder::class, $this->builder->newQuery());
}
}