Example #1
0
 /**
  * Tests clearing a mocker.
  */
 public function testClearMocker()
 {
     $mocker = new QueryMocker();
     Query::setMocker($mocker);
     $this->assertNotNull(Query::getMocker());
     Query::clearMocker();
     $this->assertNull(Query::getMocker());
 }
 /**
  * Sets up the InsertQuery instance.
  */
 public function setUp()
 {
     $this->insertQuery = Query::insert();
 }
Example #3
0
 /**
  * Inserts fake data into the users table.
  *
  * @param int $amount The number of rows to insert.
  */
 private function insertFakeData($amount = 1)
 {
     if ((int) $amount < 1) {
         $amount = 1;
     }
     for ($i = 0; $i < $amount; $i++) {
         Query::insert()->into('users')->values(array('user_name' => '{string:user_name}', 'user_email' => '{string:user_email}', 'user_status' => '{int:user_status}'))->replace(array('user_name' => 'user' . ($i + 1), 'user_email' => 'user' . ($i + 1) . '@outlook.com', 'user_status' => mt_rand(0, 2)))->execute();
     }
 }
 /**
  * Tests to ensure DELETE queries are built properly.
  */
 public function testDeleteQuery()
 {
     $query = Query::delete()->from('mytable')->where('user_id > 3')->orderBy('user_id DESC')->limit(100);
     $result = MysqlDriver::generateQuery($query->getOptions());
     $this->assertEquals('
     DELETE FROM mytable
     WHERE user_id > 3
     ORDER BY user_id DESC
     LIMIT 100', $result);
 }
 /**
  * Sets up the DeleteQuery instance.
  */
 public function setUp()
 {
     $this->deleteQuery = Query::delete();
 }
 /**
  * Creates an instance of UpdateQuery for testing.
  */
 public function setUp()
 {
     $this->updateQuery = Query::update();
 }
 /**
  * Creates an instance of SelectQuery for testing.
  */
 public function setUp()
 {
     $this->selectQuery = Query::select();
 }
 /**
  * Creates an instance of ReplaceQuery for testing.
  */
 public function setUp()
 {
     $this->replaceQuery = Query::replace();
 }