Skip to content

Commit

Permalink
Add more tests for states
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed Apr 21, 2011
1 parent 2d66c45 commit a6806ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion classes/model/foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Model_Foo extends AutoModeler_ORM {

protected $_table_name = 'foobars';
protected $_table_name = 'foos';

protected $_data = array(
'id' => '',
Expand Down
2 changes: 2 additions & 0 deletions tests/test_automodeler.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public function test_load_no_limit()
$result = Model::factory('testuser')->load(NULL, 2);
$this->assertTrue($result instanceof Database_Result);
$this->assertTrue(count($result) == 2);

$this->assertSame(AutoModeler::STATE_LOADED, $result->current()->state());
}

/**
Expand Down
19 changes: 17 additions & 2 deletions tests/test_automodeler_orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* `name` VARCHAR( 50 ) NOT NULL
* ) ENGINE = INNODB;
*
* CREATE TABLE `foobars` (
* CREATE TABLE `foos` (
* `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,
* `name` VARCHAR( 50 ) NOT NULL
* ) ENGINE = INNODB;
Expand Down Expand Up @@ -133,6 +133,18 @@ public function provider_find_parent()
);
}

/**
* Tests __get() with a relationship
*
* @return null
*/
public function test_get()
{
$user = new Model_ORMUser(1);
$this->assertInstanceOf('Model_Foo', $user->foo);
$this->assertSame(AutoModeler::STATE_LOADED, $user->foo->state());
}

/**
* @dataProvider provider_find_parent
*
Expand Down Expand Up @@ -199,7 +211,10 @@ public function test_find_related($model_name, $model_id, $related_model, $expec
{
$model = new $model_name($model_id);

$this->assertSame($expected_count, count($model->find_related($related_model)));
$related = $model->find_related($related_model);

$this->assertSame($expected_count, count($related));
$this->assertSame(AutoModeler::STATE_LOADED, $related->current()->state());
}

public function provider_find_related_where()
Expand Down

0 comments on commit a6806ff

Please sign in to comment.