Ejemplo n.º 1
0
 /**
  *  test the criteria ->has* magic method
  *  
  *  @since  11-8-10
  */
 public function testHas()
 {
     $c = new MingoCriteria();
     $this->assertFalse($c->hasFoo());
     $c->isFoo(1);
     $this->assertTrue($c->hasFoo());
     $this->assertFalse($c->hasBar());
     $c->gteBar(2);
     $this->assertTrue($c->hasBar());
     $this->assertTrue($c->hasFoo());
 }
Ejemplo n.º 2
0
 /**
  *  assure right index is queried
  *  
  *  with 2 similar indexes using SQLite (and I assume MySQL) the interface's
  *  index table selector would mess up because it would choose the first table
  *  since the where would match and the sort was never taken into account, so a
  *  PDOException would be thrown:
  *  
  *  PDOException: SQLSTATE[HY000]: General error: 1 no such column: che
  *  
  *  this test is here to make sure that is fixed
  *  
  *  @since  9-2-11
  */
 public function testSimilarIndexes()
 {
     $db = $this->getDb();
     // create a more advanced table...
     $table = new MingoTable(__FUNCTION__);
     $table->setField('foo', MingoField::TYPE_STR);
     $table->setField('bar', MingoField::TYPE_STR);
     $table->setField('che', MingoField::TYPE_STR);
     // create 2 similar indexes...
     $table->setIndex('foo_and_bar', array('foo', 'bar'));
     $table->setIndex('foo_and_che', array('foo', 'che'));
     // make sure the table exists in the db
     $this->setTable($table);
     // now try and query the second index...
     $where_criteria = new MingoCriteria();
     $where_criteria->isFoo(__FUNCTION__);
     $where_criteria->descChe();
     // no errors should be thrown...
     $list = $db->get($table, $where_criteria);
     $this->assertEmpty($list);
 }