Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (56 sloc) 1.845 kB
7f11481 @isofarro Initial checkin of IsotopeOrm plus simple setup tests
authored
1 <?php
2
3 require_once dirname(dirname(__FILE__)) . '/IsotopeOrm.php';
4
5 class IsotopeOrmTest extends PHPUnit_Framework_TestCase {
6 var $orm;
7 var $sqliteFile = '/tmp/tmp-isotope-orm-tests.db';
8 var $config = array(
9 'datasource' => 'sqlite:/tmp/tmp-isotope-orm-tests.db'
10 );
11
12 public function setUp() {
13 if (file_exists($this->sqliteFile)) {
14 unlink($this->sqliteFile);
15 }
16
17 $this->orm = new IsotopeOrm($this->config);
18 }
19
20 public function tearDown() {
21 if (file_exists($this->sqliteFile)) {
22 unlink($this->sqliteFile);
23 }
24 }
25
26 function testInitIsotopeOrm() {
27 $this->assertTrue(class_exists('IsotopeOrm'));
28
b54cd02 @isofarro Getting the skeleton of the framework together
authored
29 $class = new IsotopeOrm($this->config);
7f11481 @isofarro Initial checkin of IsotopeOrm plus simple setup tests
authored
30 $this->assertTrue(is_a($class, 'IsotopeOrm'));
31 }
32
33 public function testIsotopeOrmSetInvalidConfig() {
34 $orm = new IsotopeOrm();
35
36 $this->setExpectedException('InvalidArgumentException');
37 $orm->setConfig(false);
38 }
39
40 public function testIsotopeOrmSetConfig() {
41 $orm = new IsotopeOrm();
ab860d6 @isofarro Clean up unit tests for mostly clean output
authored
42 $orm->setConfig($this->config);
7f11481 @isofarro Initial checkin of IsotopeOrm plus simple setup tests
authored
43 }
44
b54cd02 @isofarro Getting the skeleton of the framework together
authored
45
46 public function testProceduralCreateModelSchema() {
8e96215 @isofarro Starting to flesh out the IsotopeOrmModel and applying it's IsotopeOr…
authored
47 $schema = $this->orm->createModelSchema('testModel');
48 $this->assertNotNull($schema);
49 $this->assertTrue(is_a($schema, 'IsotopeOrmModelSchema'));
b54cd02 @isofarro Getting the skeleton of the framework together
authored
50 }
51
4f1833d @isofarro simple tests for creating a schema definition - just fields
authored
52 public function testCreateExistingModelSchema() {
8e96215 @isofarro Starting to flesh out the IsotopeOrmModel and applying it's IsotopeOr…
authored
53 $schema = $this->orm->createModelSchema('testModel');
54 $this->assertNotNull($schema);
55 $this->assertTrue(is_a($schema, 'IsotopeOrmModelSchema'));
97d7de3 @isofarro Simple getSchema function from IsotopeOrmModelSchema
authored
56
57 $this->setExpectedException('InvalidArgumentException');
8e96215 @isofarro Starting to flesh out the IsotopeOrmModel and applying it's IsotopeOr…
authored
58 $schema = $this->orm->createModelSchema('testModel');
59 }
60
61 public function testUnknownGetSchema() {
62 $schema = $this->orm->getModelSchema('unknownModel');
63 $this->assertFalse($schema);
64 }
65
66 public function testGetModel() {
67 $model = $this->orm->getModel('testModel');
68 $this->assertNotNull($model);
69 $this->assertTrue(is_a($model, 'IsotopeOrmModel'));
70
97d7de3 @isofarro Simple getSchema function from IsotopeOrmModelSchema
authored
71 }
b54cd02 @isofarro Getting the skeleton of the framework together
authored
72
7f11481 @isofarro Initial checkin of IsotopeOrm plus simple setup tests
authored
73 }
74
75 ?>
Something went wrong with that request. Please try again.