Example #1
0
 /**
  * @return void
  */
 public function testArrayConditionArrayNot()
 {
     $result = $this->Posts->find()->all();
     // ID 1, 2, 3
     $this->assertSame(3, count($result));
     $result = $this->Posts->find()->where($this->Posts->arrayConditionArray('id NOT', [1, 2, 3]))->all();
     // nothing
     $this->assertSame(0, count($result));
     $result = $this->Posts->find()->where($this->Posts->arrayConditionArray('id NOT', [1, 3]))->all();
     // ID 2
     $this->assertSame(1, count($result));
     $result = $this->Posts->find()->where($this->Posts->arrayConditionArray('id NOT', [1]))->all();
     // ID 2, 3
     $this->assertSame(2, count($result));
     // BUGFIX: The core would treat NOT IN + [] as exception :(
     $result = $this->Posts->find()->where($this->Posts->arrayConditionArray('id NOT', []))->all();
     // ID 1, 2, 3
     $this->assertSame(3, count($result));
     // Logically, NOT IN + [] should be equal to no condition (or always true condition)
 }