diff options
author | Simon Holywell <[email protected]> | 2013-01-15 09:35:17 +0000 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2013-01-15 09:35:17 +0000 |
commit | 5f2fbc8151fa9f154b06c073fe4a7d096cb848c9 (patch) | |
tree | 55ff625c6691071a410e471720183aa8f0e9d950 | |
parent | 598927df4c32015e9b2a7a7eecb04eeda0a9dc3b (diff) |
Add in some PHPUnit tests
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | phpunit.xml | 11 | ||||
-rw-r--r-- | test/ORMTest.php | 47 | ||||
-rw-r--r-- | test/bootstrap.php | 3 |
4 files changed, 62 insertions, 0 deletions
@@ -1,3 +1,4 @@ *.swp *.sqlite docs/_build +/phpunit.phar diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..4718e62 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,11 @@ +<phpunit backupGlobals="true" + backupStaticAttributes="false" + bootstrap="test/bootstrap.php" + cacheTokens="false" + colors="true"> + <testsuites> + <testsuite name="Idiorm Test Suite"> + <directory suffix="Test.php">test</directory> + </testsuite> + </testsuites> +</phpunit>
\ No newline at end of file diff --git a/test/ORMTest.php b/test/ORMTest.php new file mode 100644 index 0000000..8a50479 --- /dev/null +++ b/test/ORMTest.php @@ -0,0 +1,47 @@ +<?php + +class ORMTest extends PHPUnit_Framework_TestCase { + + public function testStaticAtrributes() { + $this->assertEquals('0', ORM::CONDITION_FRAGMENT); + $this->assertEquals('1', ORM::CONDITION_VALUES); + } + + public function testForTable() { + $result = ORM::for_table('test'); + $this->assertInstanceOf('ORM', $result); + } + + public function testCreate() { + $model = ORM::for_table('test')->create(); + $this->assertInstanceOf('ORM', $model); + $this->assertTrue($model->is_new()); + } + + public function testIsNew() { + $model = ORM::for_table('test')->create(); + $this->assertTrue($model->is_new()); + + $model = ORM::for_table('test')->create(array('test' => 'test')); + $this->assertTrue($model->is_new()); + } + + public function testIsDirty() { + $model = ORM::for_table('test')->create(); + $this->assertFalse($model->is_dirty('test')); + + $model = ORM::for_table('test')->create(array('test' => 'test')); + $this->assertTrue($model->is_dirty('test')); + } + + public function testArrayAccess() { + $value = 'test'; + $model = ORM::for_table('test')->create(); + $model['test'] = $value; + $this->assertTrue(isset($model['test'])); + $this->assertEquals($model['test'], $value); + unset($model['test']); + $this->assertFalse(isset($model['test'])); + } + +}
\ No newline at end of file diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000..6f42c87 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,3 @@ +<?php + +require_once dirname(__FILE__) . '/../idiorm.php';
\ No newline at end of file |