예제 #1
0
 /**
  * testInList method
  *
  * @return void
  */
 public function testInList()
 {
     $this->assertTrue(Validation::inList('one', ['one', 'two']));
     $this->assertTrue(Validation::inList('two', ['one', 'two']));
     $this->assertFalse(Validation::inList('three', ['one', 'two']));
     $this->assertFalse(Validation::inList('1one', [0, 1, 2, 3]));
     $this->assertFalse(Validation::inList('one', [0, 1, 2, 3]));
     $this->assertTrue(Validation::inList('2', [1, 2, 3]));
     $this->assertFalse(Validation::inList('2x', [1, 2, 3]));
     $this->assertFalse(Validation::inList(2, ['1', '2x', '3']));
     $this->assertFalse(Validation::inList('One', ['one', 'two']));
     // No hexadecimal for numbers.
     $this->assertFalse(Validation::inList('0x7B', ['ABC', '123']));
     $this->assertFalse(Validation::inList('0x7B', ['ABC', 123]));
     // case insensitive
     $this->assertTrue(Validation::inList('one', ['One', 'Two'], true));
     $this->assertTrue(Validation::inList('Two', ['one', 'two'], true));
     $this->assertFalse(Validation::inList('three', ['one', 'two'], true));
 }
예제 #2
0
 /**
  * testInList method
  *
  * @return void
  */
 public function testInList()
 {
     $this->assertTrue(Validation::inList('one', array('one', 'two')));
     $this->assertTrue(Validation::inList('two', array('one', 'two')));
     $this->assertFalse(Validation::inList('three', array('one', 'two')));
     $this->assertFalse(Validation::inList('1one', array(0, 1, 2, 3)));
     $this->assertFalse(Validation::inList('one', array(0, 1, 2, 3)));
     $this->assertTrue(Validation::inList('2', array(1, 2, 3)));
     $this->assertFalse(Validation::inList('2x', array(1, 2, 3)));
     $this->assertFalse(Validation::inList(2, array('1', '2x', '3')));
     $this->assertFalse(Validation::inList('One', array('one', 'two')));
     // case insensitive
     $this->assertTrue(Validation::inList('one', array('One', 'Two'), true));
     $this->assertTrue(Validation::inList('Two', array('one', 'two'), true));
     $this->assertFalse(Validation::inList('three', array('one', 'two'), true));
 }