root/branches/0.9/tests/CacheFileTestCase.php

Revision 2359, 2.2 KB (checked in by meus, 16 months ago)

removing ending ?> and some tabs

Line 
1<?php
2require_once("UnitTestCase.php");
3
4class Doctrine_Cache_FileTestCase extends Doctrine_UnitTestCase {
5    public function setUp() {
6        parent::setUp();
7        $this->manager->setAttribute(Doctrine::ATTR_CACHE, Doctrine::CACHE_FILE);
8    }
9    public function testStore() {
10        $this->cache->store($this->old);
11        $this->assertTrue($this->cache->exists(4));
12
13        $record = $this->cache->fetch(4);
14        $this->assertTrue($record instanceof Doctrine_Record);
15        $this->assertTrue($record->obtainIdentifier() == $this->old->obtainIdentifier());
16       
17        $this->assertTrue($this->cache->getTable() == $this->objTable);
18    }
19    public function testGetFetched() {
20        $this->assertTrue(is_array($this->cache->getFetched()));
21    }
22    public function testGetFileName() {
23        $this->assertEqual($this->manager->getRoot().DIRECTORY_SEPARATOR."cache".DIRECTORY_SEPARATOR."entity".DIRECTORY_SEPARATOR."4.cache", $this->cache->getFileName(4));
24    }
25    public function testGetStats() {
26        $this->assertTrue(gettype($this->cache->getStats()) == "array");
27    }
28    public function testDestructor() {
29        $this->objTable->setAttribute(Doctrine::ATTR_CACHE_TTL,1);
30        $this->objTable->setAttribute(Doctrine::ATTR_CACHE_SIZE,5);
31        $this->cache->__destruct();
32        $this->assertTrue($this->cache->count() == 5);
33
34        $this->objTable->setAttribute(Doctrine::ATTR_CACHE_TTL,1);
35        $this->objTable->setAttribute(Doctrine::ATTR_CACHE_SIZE,1);
36        $this->cache->__destruct();
37        $this->assertTrue($this->cache->count() == 1);
38
39    }
40    public function testDeleteMultiple() {
41        $this->objTable->find(5);
42        $this->objTable->find(6);
43       
44        $deleted = $this->cache->deleteMultiple(array(5,6));
45        $this->assertTrue($deleted == 2);
46    }
47    public function testDeleteAll() {
48        $this->cache->deleteAll();
49        $this->assertTrue($this->cache->count() == 0);
50    }
51    public function testExists() {
52        $this->assertFalse($this->cache->exists(313213123));
53        $this->assertTrue($this->cache->exists(4));
54    }
55    public function testGetFactory() {
56        $this->assertTrue($this->cache->getTable() == $this->objTable);
57    }
58
59}
Note: See TracBrowser for help on using the browser.