-
Notifications
You must be signed in to change notification settings - Fork 1
/
sfDoctrineProxyCacheTest.php
59 lines (37 loc) · 1.63 KB
/
sfDoctrineProxyCacheTest.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
<?php
/*
* This file is part of the sfCacheTaggingPlugin package.
* (c) 2009-2010 Ilya Sabelnikov <fruit.dev@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once realpath(dirname(__FILE__) . '/../../../../../test/bootstrap/functional.php');
require_once sfConfig::get('sf_symfony_lib_dir') . '/vendor/lime/lime.php';
$t = new lime_test();
$connection = Doctrine::getConnectionByTableName('BlogPost');
$connection->beginTransaction();
$cacheManager = sfContext::getInstance()->getViewCacheManager();
/* @var $cacheManager sfViewCacheTagManager */
$q = BlogPostTable::getInstance()->createQuery('p');
$t->isa_ok($q->getResultCacheDriver(), 'sfDoctrineProxyCache', 'instance of Proxy');
$q
->useResultCache()
->select('*')
->addWhere('id != ?', 4)
->leftJoin('p.BlogPostComment c')
->limit(5);
$q->clearResultCache();
$hash = $q->getResultCacheHash();
$t->ok(! $q->getResultCacheDriver()->contains($hash), 'hash is new');
$posts = $q->execute();
$t->ok($q->getResultCacheDriver()->contains($hash), 'hash exists');
$t->is(gettype($q->getResultCacheDriver()->fetch($hash)), 'string', 'cache seamse to be ok');
$post = $posts->getFirst();
$post->delete();
$t->ok(! $q->getResultCacheDriver()->contains($hash), 'cache invalidated');
$posts = $q->execute();
$t->ok($q->getResultCacheDriver()->contains($hash), 'cache updated');
$q->getResultCacheDriver()->delete($hash);
$t->ok(! $q->getResultCacheDriver()->contains($hash), 'cache removed');
$connection->rollback();