Exemple #1
0
 /**
  * Creating the test database
  */
 public function setUp()
 {
     Fixtures::config(array('db' => array('adapter' => 'Connection', 'connection' => $this->_connection, 'fixtures' => $this->_fixtures)));
     Fixtures::create('db');
     $db = $this->_db;
     if (!$db::enabled('schema')) {
         $gallery = Fixtures::get('db', 'galleries');
         $images = Fixtures::get('db', 'images');
         Galleries::schema($gallery->fields());
         Images::schema($images->fields());
     }
 }
Exemple #2
0
 /**
  * Creating the test database
  */
 public function setUp()
 {
     Fixtures::config(array('db' => array('adapter' => 'Connection', 'connection' => $this->_connection, 'fixtures' => $this->_fixtures)));
     Fixtures::create('db', array('galleries'));
 }
Exemple #3
0
 public function testCreate()
 {
     Fixtures::create('db', ['comment', 'image']);
     Comment::actsAs('Tree', ['scope' => ['image_id']]);
     $root1 = Comment::create(['image_id' => 1]);
     $root1->save();
     $root2 = Comment::create(['image_id' => 2]);
     $root2->save();
     $neighbor1 = Comment::create(['image_id' => 1]);
     $neighbor1->save();
     $idField = Comment::key();
     $subelement1 = Comment::create(['image_id' => 1, 'parent_id' => $neighbor1->{$idField}]);
     $subelement1->save();
     $entities = Comment::find('all', ['order' => ['id' => 'asc']]);
     $expected = ['1' => ['id' => '1', 'image_id' => '1', 'body' => null, 'parent_id' => null, 'lft' => '1', 'rght' => '2', 'published' => 'N'], '2' => ['id' => '2', 'image_id' => '2', 'body' => null, 'parent_id' => null, 'lft' => '1', 'rght' => '2', 'published' => 'N'], '3' => ['id' => '3', 'image_id' => '1', 'body' => null, 'parent_id' => null, 'lft' => '3', 'rght' => '6', 'published' => 'N'], '4' => ['id' => '4', 'image_id' => '1', 'body' => null, 'parent_id' => '3', 'lft' => '4', 'rght' => '5', 'published' => 'N']];
     $this->assertEqual($expected, $entities->data());
 }