Ejemplo n.º 1
0
 /**
  * @see Gas\Core   (./classes/core.php)
  * @see Model\User (./tests/dummyModels/user.php)
  * @see Model\Wife (./tests/dummyModels/wife.php)
  */
 public function setUp()
 {
     // Prepare some table(s) for test,
     // and connect using related environment
     Model\User::setUp();
     Model\Wife::setUp();
     $this->db = Gas\Core::$db;
 }
Ejemplo n.º 2
0
 /**
  * @see Model\User      (./tests/dummyModels/user.php)
  * @see Model\Wife      (./tests/dummyModels/wife.php)
  * @see Model\Kid       (./tests/dummyModels/kid.php)
  * @see Model\Job       (./tests/dummyModels/job.php)
  */
 public function setUp()
 {
     Model\User::setUp();
     Model\Wife::setUp();
     Model\Kid::setUp();
     Model\Job::setUp();
     Model\Job\User::setUp();
 }
Ejemplo n.º 3
0
 public function testFindSeveral()
 {
     $wifes = Model\Wife::find(1, 2, 3);
     // Should be an array, contain 3 wife objects
     $this->assertCount(3, $wifes);
     foreach ($wifes as $wife) {
         // Consist
         $this->assertInstanceOf('Gas\\ORM', $wife);
         $this->assertInstanceOf('Gas\\Data', $wife->record);
         // Check results
         switch ($wife->id) {
             case '1':
                 $this->assertEquals($wife->name, 'Lourie Jones');
                 break;
             case '2':
                 $this->assertEquals($wife->name, 'Patricia Doe');
                 break;
             case '3':
                 $this->assertEquals($wife->name, 'Lily Sinatra');
                 break;
         }
     }
 }
Ejemplo n.º 4
0
 public function testEagerLoadBelongsToSimpleOne()
 {
     // Find wife with id `1`
     $wife1 = Model\Wife::with('user')->find(1);
     // Consist
     $this->assertInstanceOf('Gas\\ORM', $wife1);
     $this->assertInstanceOf('Gas\\Data', $wife1->record);
     // Check result
     $this->assertEquals($wife1->id, '1');
     $this->assertEquals($wife1->name, 'Lourie Jones');
     $this->assertEquals($wife1->hair_color, 'black');
     // Grab related husband (user)
     $wife1_husband = $wife1->user();
     // Consist
     $this->assertInstanceOf('Gas\\ORM', $wife1_husband);
     $this->assertInstanceOf('Gas\\Data', $wife1_husband->record);
     // Check results, this should be `Derek Jones` with `2` as his id
     // `derekjones@world.com` as his email and `derek` as his username
     $this->assertEquals($wife1_husband->id, '2');
     $this->assertEquals($wife1_husband->name, 'Derek Jones');
     $this->assertEquals($wife1_husband->email, '*****@*****.**');
     $this->assertEquals($wife1_husband->username, 'derek');
 }
Ejemplo n.º 5
0
 /**
  * @see Model\User (./tests/dummyModels/user.php)
  * @see Model\Wife (./tests/dummyModels/wife.php)
  */
 public function setUp()
 {
     Model\User::setUp();
     Model\Wife::setUp();
 }
Ejemplo n.º 6
0
$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);