/**
  * https://github.com/studio107/Mindy_Query/issues/11
  * Issue #11
  */
 public function testIssue11()
 {
     // Fix hhvm test
     date_default_timezone_set('UTC');
     $this->initModels([new Solution()]);
     list($modelOne, $created) = Solution::objects()->getOrCreate(['status' => 1, 'name' => 'test', 'court' => 'qwe', 'question' => 'qwe', 'result' => 'qwe', 'content' => 'qwe']);
     $this->assertEquals(1, $modelOne->pk);
     $sql = Solution::objects()->filter(['id' => '1'])->updateSql(['status' => 2]);
     $db = ConnectionManager::getDb();
     $tableSql = $db->schema->quoteColumnName('tests_solution');
     $statusSql = $db->schema->quoteColumnName('status');
     $idSql = $db->schema->quoteColumnName('id');
     $this->assertEquals("UPDATE {$tableSql} SET {$statusSql}=2 WHERE ({$idSql}='1')", $sql);
     $this->dropmodels([new Solution()]);
 }
示例#2
0
 public function testToArray()
 {
     list($solution, $created) = Solution::objects()->getOrCreate(['status' => 1, 'name' => 'test', 'court' => 'qwe', 'question' => 'qwe', 'result' => 'qwe', 'content' => 'qwe']);
     $array = $solution->toArray();
     unset($array['created_at']);
     $this->assertEquals(['id' => '1', 'name' => 'test', 'court' => 'qwe', 'question' => 'qwe', 'result' => 'qwe', 'document' => null, 'content' => 'qwe', 'status' => 1, 'status__text' => 'Complete'], $array);
     $solution->status = Solution::STATUS_SUCCESS;
     $array = $solution->toArray();
     unset($array['created_at']);
     $this->assertEquals(['id' => '1', 'name' => 'test', 'court' => 'qwe', 'question' => 'qwe', 'result' => 'qwe', 'document' => null, 'content' => 'qwe', 'status' => 2, 'status__text' => 'Successful'], $array);
     $solution->save();
     $array = $solution->toArray();
     unset($array['created_at']);
     $this->assertEquals(['id' => '1', 'name' => 'test', 'court' => 'qwe', 'question' => 'qwe', 'result' => 'qwe', 'document' => null, 'content' => 'qwe', 'status' => 2, 'status__text' => 'Successful'], $array);
 }