-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="tests/TestFixture.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>src/Flintstone</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<testsuites> | ||
<testsuite name="Flintstone Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/** | ||
* Flintstone Unit Tests | ||
*/ | ||
|
||
class FeatureTest extends TestFixture { | ||
|
||
/** | ||
* Test 'set' operations | ||
*/ | ||
public function testSet() { | ||
$this->assertTrue($this->db->set('a', '1')); | ||
$this->assertTrue($this->db->set('b', 2)); | ||
$this->assertTrue($this->db->set('c', array(3, 4, 5))); | ||
} | ||
|
||
/** | ||
* Test 'set' operations | ||
* @expectedException Flintstone\FlintstoneException | ||
*/ | ||
public function testSetException() { | ||
$this->db->set('d', false); | ||
} | ||
|
||
/** | ||
* Test 'replace' operations | ||
*/ | ||
public function testReplace() { | ||
$this->assertTrue($this->db->set('a', '1')); | ||
$this->assertTrue($this->db->replace('a', '2')); | ||
$this->assertSame($this->db->get('a'), '2'); | ||
} | ||
|
||
/** | ||
* Test 'get' operations | ||
*/ | ||
public function testGet() { | ||
$this->assertFalse($this->db->get('a')); | ||
$this->assertTrue($this->db->set('a', '1')); | ||
$this->assertSame($this->db->get('a'), '1'); | ||
} | ||
|
||
/** | ||
* Test 'delete' operations | ||
*/ | ||
public function testDelete() { | ||
$this->assertFalse($this->db->delete('a')); | ||
$this->assertTrue($this->db->set('a', '1')); | ||
$this->assertTrue($this->db->delete('a')); | ||
$this->assertFalse($this->db->get('a')); | ||
} | ||
|
||
/** | ||
* Test 'flush' operations | ||
*/ | ||
public function testFlush() { | ||
$this->assertTrue($this->db->set('a', '1')); | ||
$this->assertTrue($this->db->set('b', 2)); | ||
$this->assertTrue($this->db->flush()); | ||
$this->assertFalse($this->db->get('a')); | ||
$this->assertFalse($this->db->get('b')); | ||
} | ||
|
||
/** | ||
* Test 'getKeys' operations | ||
*/ | ||
public function testGetKeys() { | ||
$this->assertTrue($this->db->set('a', '1')); | ||
$this->assertTrue($this->db->set('b', 2)); | ||
$this->assertTrue($this->db->set('c', array(3, 4, 5))); | ||
$keys = $this->db->getKeys(); | ||
$this->assertEquals(3, count($keys)); | ||
$this->assertContains('a', $keys); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* Flintstone Unit Tests | ||
*/ | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Flintstone\Flintstone; | ||
|
||
class TestFixture extends \PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* Flintstone database | ||
* @access protected | ||
* @var object | ||
*/ | ||
protected $db; | ||
|
||
/** | ||
* Load the test database | ||
*/ | ||
public function setUp() { | ||
$this->db = Flintstone::load('test', array('dir' => __DIR__)); | ||
} | ||
|
||
/** | ||
* Unload the test database and remove | ||
*/ | ||
public function tearDown() { | ||
Flintstone::unload('test'); | ||
$file = __DIR__ . '/test.dat'; | ||
unlink($file); | ||
} | ||
} |