コード例 #1
0
ファイル: DatabaseTest.php プロジェクト: nilamdoc/KYCGlobal
 /**
  * Creating the test database
  */
 public function setUp()
 {
     $options = array('db' => array('adapter' => 'Connection', 'connection' => $this->_connection, 'fixtures' => $this->_fixtures));
     if ($this->with('PostgreSql')) {
         $options['db']['alters']['change']['id'] = array('value' => function ($id) {
             return (object) 'default';
         });
     }
     Fixtures::config($options);
     Fixtures::save('db');
 }
コード例 #2
0
ファイル: AclNodeTest.php プロジェクト: jails/li3_access
 public function testNodeWithNonStrictMode()
 {
     Fixtures::save('db');
     extract($this->_models);
     $result = Set::extract(Aco::node('root/printers/refill/unexisting', false), '/id');
     $expected = ['9', '6', '1'];
     $this->assertEqual($expected, $result);
 }
コード例 #3
0
ファイル: DatabaseTest.php プロジェクト: rapzo/lithium
 public function testOneToManyUsingSameKeyName()
 {
     Fixtures::drop('db', array('galleries'));
     $fixture = Fixtures::get('db', 'galleries');
     $fixture->alter('change', 'id', array('to' => 'gallery_id'));
     Fixtures::save('db', array('galleries'));
     Galleries::reset();
     Galleries::config(array('meta' => array('connection' => $this->_connection, 'key' => 'gallery_id')));
     $opts = array('conditions' => array('Galleries.gallery_id' => 1));
     $query = new Query($opts + array('type' => 'read', 'model' => 'lithium\\tests\\fixture\\model\\gallery\\Galleries', 'source' => 'galleries', 'alias' => 'Galleries', 'with' => array('Images')));
     $galleries = $this->_db->read($query);
     $this->assertCount(3, $galleries->first()->images);
 }
コード例 #4
0
ファイル: DatabaseTest.php プロジェクト: fedeisas/lithium
 /**
  * Prove that two distinct models each having a different connection to a different
  * database are working independently upon the correct databases.
  */
 public function testSwitchingDatabaseDistinctModels()
 {
     $connection1 = $this->_connection;
     $connection2 = $this->_connection . '_alternative';
     $connectionConfig1 = Connections::get($connection1, array('config' => true));
     $connectionConfig2 = Connections::get($connection2, array('config' => true));
     parent::connect($connection2);
     $this->skipIf(!$connectionConfig2, "The `'{$connection2}' connection is not available`.");
     $this->skipIf(!$this->with(array('MySql', 'PostgreSql', 'Sqlite3')));
     $bothInMemory = $connectionConfig1['database'] == ':memory:';
     $bothInMemory = $bothInMemory && $connectionConfig2['database'] == ':memory:';
     $this->skipIf($bothInMemory, 'Cannot use two connections with in memory databases');
     Fixtures::save('db_alternative');
     Galleries::config(array('meta' => array('connection' => $connection1)));
     Images::config(array('meta' => array('connection' => $connection1)));
     $galleriesCountOriginal = Galleries::find('count');
     $imagesCountOriginal = Images::find('count');
     $gallery = Galleries::create(array('name' => 'record_in_db'));
     $gallery->save();
     $image = Images::find('first', array('conditions' => array('id' => 1)));
     $image->delete();
     Galleries::config(array('meta' => array('connection' => $connection2)));
     $expected = $galleriesCountOriginal;
     $result = Galleries::find('count');
     $this->assertEqual($expected, $result);
     $expected = $imagesCountOriginal - 1;
     $result = Images::find('count');
     $this->assertEqual($expected, $result);
     Fixtures::clear('db_alternative');
 }
コード例 #5
0
ファイル: PermissionTest.php プロジェクト: jails/li3_access
 public function testAllowOnTheFlyPrivilege()
 {
     Fixtures::save('db');
     $this->assertFalse(Permission::check('Micheal', 'tpsReports', ['publish']));
     $this->assertTrue(Permission::allow('Micheal', 'tpsReports', ['publish']));
     $this->assertTrue(Permission::check('Micheal', 'tpsReports', ['publish']));
     $this->assertTrue(Permission::check('Micheal', 'root/tpsReports', ['publish']));
     $this->assertTrue(Permission::check('Micheal', 'root/tpsReports/update', ['publish']));
 }
コード例 #6
0
ファイル: SourceTest.php プロジェクト: fedeisas/lithium
 public function testSerializingCollection()
 {
     Fixtures::save('db');
     $data = Images::find('all');
     $this->skipIf(!$data, 'Fixtures not applied/available.');
     $result = true;
     try {
         $data = serialize($data);
         $data = unserialize($data);
     } catch (Exception $e) {
         $result = false;
         $data = array();
     }
     $this->assertTrue($result);
     $expected = 'Amiga 1200';
     foreach ($data as $item) {
         $result = $item->title;
         break;
     }
     $this->assertEqual($expected, $result);
 }
コード例 #7
0
ファイル: TreeTest.php プロジェクト: jails/li3_tree
 public function testDelete()
 {
     Fixtures::create('db', ['image']);
     Fixtures::save('db', ['comment']);
     Comment::actsAs('Tree', ['scope' => ['image_id']]);
     $entities = Comment::find('all', ['order' => ['lft' => 'asc']]);
     $this->assertTrue($entities[2]->delete());
     $this->assertTrue($entities[6]->delete());
     $entities = Comment::find('all', ['order' => ['id' => 'asc']]);
     $this->assertTrue($entities[1]->verify() === true);
     $this->assertTrue($entities[5]->verify() === true);
 }