/** * @see Model\User (./tests/dummyModels/user.php) * @see Model\Kid (./tests/dummyModels/kid.php) * @see Model\Job (./tests/dummyModels/job.php) * @see Model\Job\User (./tests/dummyModels/job/user.php) * @see Model\Role (./tests/dummyModels/role.php) * @see Model\Role\User (./tests/dummyModels/role/user.php) */ public function setUp() { Model\User::setUp(); Model\Kid::setUp(); Model\Job::setUp(); Model\Job\User::setUp(); Model\Role::setUp(); Model\Role\User::setUp(); }
public function testDeleteCompositeSingle() { // Find WHERE IN u_id = 1 and r_id = 2 (sequece was follow its composite keys order) $role_user = Model\Role\User::find(array(1, 2)); // Consist $this->assertInstanceOf('Gas\\ORM', $role_user); $this->assertInstanceOf('Gas\\Data', $role_user->record); // No way we allow composite table, which define entities, delete itself $this->assertFalse($role_user->delete()); }
public function testFindCompositeSeveral() { // Find sequenced of records (which its paired ids follow its composite keys order) $role_users = Model\Role\User::find(array(1, 2), array(3, 2)); // Should be an array, contain 2 role_user object $this->assertCount(2, $role_users); foreach ($role_users as $role_user) { // Consist $this->assertInstanceOf('Gas\\ORM', $role_user); $this->assertInstanceOf('Gas\\Data', $role_user->record); // Check results switch ($role_user->u_id) { case '1': $this->assertEquals($role_user->r_id, '2'); break; case '3': $this->assertEquals($role_user->r_id, '2'); break; } } }
$gasdir = implode(DIRECTORY_SEPARATOR, $fragdir); // Catch Base Directory if (defined('ROOTPATH')) { array_splice($fragdir, -2); } else { array_splice($fragdir, -3); } $basedir = implode(DIRECTORY_SEPARATOR, $fragdir); // Define the PATH and ENVIRONMENT define('ENVIRONMENT', 'testing'); if (defined('ROOTPATH')) { define('APPPATH', $basedir . DIRECTORY_SEPARATOR); define('BASEPATH', APPPATH . 'vendor' . DIRECTORY_SEPARATOR . 'CodeIgniter' . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR); } else { define('APPPATH', $basedir . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR); define('BASEPATH', $basedir . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR); } // Define Gas ORM configuration for unit testing $config = array('models_path' => array('Model' => __DIR__ . DIRECTORY_SEPARATOR . 'dummyModels'), 'cache_request' => FALSE, 'auto_create_models' => FALSE, 'auto_create_tables' => FALSE); // Include Gas ORM configuration and Bootstrap include_once $gasdir . DIRECTORY_SEPARATOR . 'bootstrap.php'; // Initialize all Model's setup Model\Job\User::setUp(); Model\Role\User::setUp(); Model\Job::setUp(); Model\Kid::setUp(); Model\Role::setUp(); Model\User::setUp(); Model\Wife::setUp(); // Reconnect Gas\Core::connect(DB_GROUP);