3 require_once 'PHPUnit/Framework/TestCase.php';
5 class StorageTest extends PHPUnit_Framework_TestCase {
6 protected $storage_path;
9 protected function setUp(){
10 $this->storage_path = dirname(__FILE__) . "filestore-test";
11 $this->s = new sfjp\Wiki\Storage\File(array('storage.file.datadir' => $this->storage_path));
14 protected function tearDown() {
18 protected function cleanup() {
19 if (!is_dir($this->storage_path))
21 $dh = opendir($this->storage_path);
23 while ($ent = readdir($dh)) {
24 if ($ent == '.' || $ent == '..')
26 unlink("{$this->storage_path}/{$ent}");
29 rmdir($this->storage_path);
32 public function testNew() {
33 self::assertTrue(isset($this->s));
37 public function testGetSet() {
38 $text = "hoge\nfuga\r\nyeah!";
39 $this->s->set('page1', $text);
40 self::assertEquals($text, $this->s->get('page1'));
43 public function testList() {
45 $this->s->set('foo', 'foo 1');
46 $this->s->set('Bar', 'bar 2');
47 self::assertTrue(in_array('foo', $this->s->get_list()));
48 self::assertTrue(in_array('Bar', $this->s->get_list()));
49 self::assertTrue(!in_array('boo', $this->s->get_list()));
52 public function testRemove() {
53 $this->s->set('hoge', '1');
54 self::assertTrue(in_array('hoge', $this->s->get_list()));
55 $this->s->remove('hoge');
56 self::assertTrue(!in_array('hoge', $this->s->get_list()));