コード例 #1
0
 public function testDelete()
 {
     $this->_mock = new Mock_Database($this, array(array('many', "SELECT *\nFROM people\nWHERE `id` IN (?, ?)", array(1, 2), null, array('return' => array(array('id' => '1', 'passport_id' => 3), array('id' => '2', 'passport_id' => 4)))), array('execute', "DELETE FROM people\nWHERE `id` IN (?, ?)", array(1, 2)), array('many', "SELECT *\nFROM passports\nWHERE `id` IN (?, ?)", array(3, 4), null, array('return' => array(array('id' => '3'), array('id' => '4')))), array('execute', "DELETE FROM passports\nWHERE `id` IN (?, ?)", array(3, 4))), array('debug' => false));
     \Snowfire\Database\Model::database($this->_mock);
     $people_model = new People();
     $passports_model = new Passports();
     $people_model->delete(array('id' => array(1, 2)), array('passports' => $passports_model));
 }
コード例 #2
0
 public function testDelete()
 {
     $this->_mock = new Mock_Database($this, array(array('many', "SELECT *\nFROM products\nWHERE `id` = ?", array(1), null, array('return' => array(array('id' => '1')))), array('execute', "DELETE FROM products_categories\nWHERE `product_id` IN (?)", array(1)), array('execute', "DELETE FROM products\nWHERE `id` = ?", array(1))), array('debug' => false));
     \Snowfire\Database\Model::database($this->_mock);
     $prod_model = new Products1();
     $cat_model = new Categories1();
     $prod_model->delete(array('id' => 1), array('categories' => $cat_model));
 }
コード例 #3
0
 public function testMany()
 {
     $this->_mock = new Mock_Database($this, array(array('many', "SELECT products.*\nFROM products", array(), null, array('return' => array(array('id' => 1), array('id' => 2)))), array('many', "SELECT products_options.*\nFROM products_options\nWHERE `product_id` IN (?, ?)", array(1, 2), null, array('return' => array(array('id' => 3, 'product_id' => 1), array('id' => 4, 'product_id' => 2))))));
     \Snowfire\Database\Model::database($this->_mock);
     $prod_model = new Products();
     $opt_model = new Products_Options();
     $this->assertEquals(array(array('id' => 1, 'options' => array(array('id' => 3, 'product_id' => 1))), array('id' => 2, 'options' => array(array('id' => 4, 'product_id' => 2)))), $prod_model->many(array('foreign_models' => array('options' => $opt_model))));
 }
コード例 #4
0
ファイル: ModelTest.php プロジェクト: snowfire/database
 private function _users_model($expected)
 {
     $this->_mock = new Mock_Database($this, $expected);
     \Snowfire\Database\Model::database($this->_mock);
     return new Users(array('account_id' => 5));
 }