コード例 #1
0
ファイル: QueryTest.php プロジェクト: aivavic/yii2
 public function testWhere()
 {
     $query = new Query();
     $query->where('id = :id', [':id' => 1]);
     $this->assertEquals('id = :id', $query->where);
     $this->assertEquals([':id' => 1], $query->params);
     $query->andWhere('name = :name', [':name' => 'something']);
     $this->assertEquals(['and', 'id = :id', 'name = :name'], $query->where);
     $this->assertEquals([':id' => 1, ':name' => 'something'], $query->params);
     $query->orWhere('age = :age', [':age' => '30']);
     $this->assertEquals(['or', ['and', 'id = :id', 'name = :name'], 'age = :age'], $query->where);
     $this->assertEquals([':id' => 1, ':name' => 'something', ':age' => '30'], $query->params);
 }