blob: 1e47819feb59f8d829c39bd06aa4feb16b81b1c1 (
plain)
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
namespace Elastica\Test\Filter;
use Elastica\Test\Base as BaseTest;
class AbstractTest extends BaseTest
{
public function testSetCached()
{
$stubFilter = $this->getStub();
$stubFilter->setCached(true);
$arrayFilter = current($stubFilter->toArray());
$this->assertTrue($arrayFilter['_cache']);
$stubFilter->setCached(false);
$arrayFilter = current($stubFilter->toArray());
$this->assertFalse($arrayFilter['_cache']);
}
public function testSetCachedDefaultValue()
{
$stubFilter = $this->getStub();
$stubFilter->setCached();
$arrayFilter = current($stubFilter->toArray());
$this->assertTrue($arrayFilter['_cache']);
}
public function testSetCacheKey()
{
$stubFilter = $this->getStub();
$cacheKey = 'myCacheKey';
$stubFilter->setCacheKey($cacheKey);
$arrayFilter = current($stubFilter->toArray());
$this->assertEquals($cacheKey, $arrayFilter['_cache_key']);
}
/**
* @expectedException \Elastica\Exception\InvalidException
*/
public function testSetCacheKeyEmptyKey()
{
$stubFilter = $this->getStub();
$cacheKey = '';
$stubFilter->setCacheKey($cacheKey);
}
public function testSetName()
{
$stubFilter = $this->getStub();
$name = 'myFilter';
$stubFilter->setName($name);
$arrayFilter = current($stubFilter->toArray());
$this->assertEquals($name, $arrayFilter['_name']);
}
private function getStub()
{
return $this->getMockForAbstractClass('Elastica\Filter\AbstractFilter');
}
}
|