Пример #1
0
 function test_query_tool_load_current()
 {
     $rd = new Dataface_QueryTool('Profiles', $this->table1->db, array());
     $s = $rd->loadCurrent();
     $this->assertTrue(is_a($s, 'Dataface_Record'));
     // should load all columns except the blobs
     $this->assertEquals($s->getValue('id'), 10);
     $this->assertEquals($s->getValue('fname'), 'John');
     $this->assertEquals($s->getValueAsString('lastlogin'), '2005-06-30 00:00:00');
     //		$this->assertTrue(!$s->hasValue('photo'), 'Photo should not have an associated value. Blobs should not be loaded by the result descriptor');
     $this->assertTrue($s->hasValue('photo_mimetype'), 'Photo mimetype should have a value.');
     $this->assertEquals($rd->found(), 3);
     $this->assertEquals($rd->cardinality(), 3);
     $this->assertEquals($rd->cursor(), 0);
     $this->assertEquals($rd->start(), 0);
     $this->assertEquals($rd->end(), 2);
     // now try to specify a cursor
     $rd2 = new Dataface_QueryTool('Profiles', $this->table1->db, array('-cursor' => '1'));
     $s = $rd2->loadCurrent();
     $this->assertTrue(is_a($s, 'Dataface_Record'));
     $this->assertEquals($s->getValue('id'), 11);
     $this->assertEquals($s->getValue('fname'), 'Johnson');
     $this->assertEquals($s->getValueAsString('lastlogin'), '2005-06-30 00:00:00');
     $this->assertEquals($rd2->found(), 3);
     $this->assertEquals($rd2->cardinality(), 3);
     $this->assertEquals($rd2->cursor(), 1);
     $this->assertEquals($rd2->start(), 0);
     $this->assertEquals($rd2->end(), 2);
     $rd2 = new Dataface_QueryTool('Profiles', $this->table1->db, array('-cursor' => 1, '-limit' => 2));
     $s = $rd2->loadCurrent();
     $this->assertTrue(is_a($s, 'Dataface_Record'));
     $this->assertEquals($s->getValue('id'), 11);
     $this->assertEquals($s->getValue('fname'), 'Johnson');
     $this->assertEquals($s->getValueAsString('lastlogin'), '2005-06-30 00:00:00');
     $this->assertEquals($rd2->found(), 3);
     $this->assertEquals($rd2->cardinality(), 3);
     $this->assertEquals($rd2->cursor(), 1);
     $this->assertEquals($rd2->start(), 0);
     $this->assertEquals($rd2->end(), 1);
     $rd2 = new Dataface_QueryTool('Profiles', $this->table1->db, array('-cursor' => 1, '-limit' => 2, 'fname' => 'John'));
     $s = $rd2->loadCurrent();
     $this->assertTrue(is_a($s, 'Dataface_Record'));
     $this->assertEquals($s->getValue('id'), 11);
     $this->assertEquals($s->getValue('fname'), 'Johnson');
     $this->assertEquals($s->getValueAsString('lastlogin'), '2005-06-30 00:00:00');
     $this->assertEquals($rd2->found(), 2);
     $this->assertEquals($rd2->cardinality(), 3);
     $this->assertEquals($rd2->cursor(), 1);
     $this->assertEquals($rd2->start(), 0);
     $this->assertEquals($rd2->end(), 1);
     $rd2 = new Dataface_QueryTool('Profiles', $this->table1->db, array('-cursor' => 0, '-limit' => 2, 'fname' => '=John'));
     $s = $rd2->loadCurrent();
     $this->assertTrue(is_a($s, 'Dataface_Record'));
     $this->assertEquals($s->getValue('id'), 10);
     $this->assertEquals($s->getValue('fname'), 'John');
     $this->assertEquals($s->getValueAsString('lastlogin'), '2005-06-30 00:00:00');
     $this->assertEquals($rd2->found(), 1);
     $this->assertEquals($rd2->cardinality(), 3);
     $this->assertEquals($rd2->cursor(), 0);
     $this->assertEquals($rd2->start(), 0);
     $this->assertEquals($rd2->end(), 0);
 }