Skip to content

Commit 18a1b03

Browse files
committed
Update unit tests.
1 parent 1521ae8 commit 18a1b03

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/SimpleCache/Cache.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,19 @@ public function deleteMultiple($keys)
124124
{
125125
return $this->driver->deleteMultiple($keys);
126126
}
127+
128+
/**
129+
* Create or rebuid the data schema.
130+
* This method is avaialbe for Mysql and Sqlite drivers.
131+
*
132+
* @return bool
133+
*/
134+
public function rebuild(): bool
135+
{
136+
if (method_exists($this->driver, 'rebuild')) {
137+
return $this->driver->rebuild();
138+
}
139+
140+
return false;
141+
}
127142
}

tests/SimpleCache/CacheTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,28 @@ public function testIsExpired()
131131
$result = $method->invokeArgs($cache, [$dateInterval, $time]);
132132
$this->assertFalse($result);
133133
}
134+
135+
public function testRebuildShouldReturnTrue()
136+
{
137+
$driver = new Cache('mysql', [
138+
'dbname' => 'shieldon_unittest',
139+
'user' => 'shieldon',
140+
'pass' => 'taiwan',
141+
]);
142+
143+
$this->assertTrue($driver->rebuild());
144+
145+
$driver = new Cache('sqlite', [
146+
'storage' => create_tmp_directory()
147+
]);
148+
149+
$this->assertTrue($driver->rebuild());
150+
}
151+
152+
public function testRebuildShouldReturnFalse()
153+
{
154+
$driver = new Cache('apcu');
155+
156+
$this->assertFalse($driver->rebuild());
157+
}
134158
}

0 commit comments

Comments
 (0)