Ejemplo n.º 1
0
 function Test_of_countBySql()
 {
     $AkTestUser = new AkTestUser();
     $this->assertEqual($AkTestUser->countBySql("SELECT COUNT(*) FROM ak_test_users"), count($AkTestUser->find()));
     $this->assertEqual($AkTestUser->countBySql("SELECT COUNT(*) FROM ak_test_users WHERE first_name = 'Tim'"), count($AkTestUser->findAll("first_name = 'Tim'")));
 }
Ejemplo n.º 2
0
 public function Test_of_findBySql()
 {
     $Users = new AkTestUser();
     $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users WHERE first_name = 'Hilario'");
     $this->assertTrue($FoundUsers[0]->last_name == 'Hervás Añó');
     $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE first_name = ?", array('Hilario')));
     $this->assertTrue($FoundUsers[0]->last_name == 'Hervás Añó');
     $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE first_name = ?", 'Hilario'));
     $this->assertTrue($FoundUsers[0]->last_name == 'Hervás Añó');
     $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE last_name = ?", array('last_name' => 'Ferrer Martínez')));
     $this->assertTrue($FoundUsers[0]->first_name == 'Bermi');
     $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE last_name = ? AND first_name = ?", array('Ferrer Martínez', 'Bermi')));
     $this->assertTrue($FoundUsers[0]->first_name == 'Bermi');
     $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users", 6);
     $this->assertEqual(count($FoundUsers), 6);
     $this->assertErrorPattern("/DEPRECATED WARNING.*findBySql.*/");
     $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users", 6, 6);
     $this->assertEqual(count($FoundUsers), 3);
     $this->assertErrorPattern("/DEPRECATED WARNING.*findBySql.*/");
     $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users WHERE iad=123");
     $this->assertEqual(count($FoundUsers), 0);
     $this->assertError();
 }
Ejemplo n.º 3
0
    function Test_of_findBySql()
    {
        $Users = new AkTestUser();
        
        $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users WHERE first_name = 'Hilario'");
        $this->assertTrue($FoundUsers[0]->last_name == 'Hervás Añó');
        
        $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE first_name = ?",array('Hilario')));
        $this->assertTrue($FoundUsers[0]->last_name == 'Hervás Añó');
        
        $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE first_name = ?",'Hilario'));
        $this->assertTrue($FoundUsers[0]->last_name == 'Hervás Añó');
        
        $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE last_name = ?",array('last_name'=>'Ferrer Martínez')));
        $this->assertTrue($FoundUsers[0]->first_name == 'Bermi');
        
        $FoundUsers = $Users->findBySql(array("SELECT * FROM ak_test_users WHERE last_name = ? AND first_name = ?",array('Ferrer Martínez','Bermi')));
        $this->assertTrue($FoundUsers[0]->first_name == 'Bermi');
        
        $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users",6);
        $this->assertEqual(count($FoundUsers), 6);
        
        $FoundUsers = $Users->findBySql("SELECT * FROM ak_test_users",6,6);
        $this->assertEqual(count($FoundUsers), 3);

    }
Ejemplo n.º 4
0
 function Test_of_get_and_set_DisplayField()
 {
     $AkTestField = new AkTestField();
     $this->assertEqual($AkTestField->getDisplayField(), 'id');
     $AkTestField->setDisplayField('text_field');
     $this->assertEqual($AkTestField->getDisplayField(), 'text_field');
     $AkTestUser = new AkTestUser();
     $this->assertEqual($AkTestUser->getDisplayField(), 'id');
     $AkTestUser->addCombinedAttributeConfiguration('name', "%s %s", 'first_name', 'last_name');
     $this->assertEqual($AkTestUser->getDisplayField(), 'name');
     $AkTestField->setDisplayField('invalid_field');
     $this->assertEqual($AkTestUser->getDisplayField(), 'name');
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $this->setTableName("ak_test_members");
     parent::__construct(@(array) func_get_args());
 }