!C99Shell v. 2.1 [PHP 8 Update] [02.02.2022]!

Software: Apache/2.4.53 (Unix) OpenSSL/1.1.1o PHP/7.4.29 mod_perl/2.0.12 Perl/v5.34.1. PHP/7.4.29 

uname -a: Linux vps-2738122-x 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 

uid=1(daemon) gid=1(daemon) grupos=1(daemon) 

Safe-mode: OFF (not secure)

/opt/lampp/lib/php/test/MDB_QueryTool/tests/simpletest_tests/   drwxr-xr-x
Free 13.02 GB of 61.93 GB (21.03%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     mdb_querytool_testHaving.php (4.92 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// $Id: mdb_querytool_testHaving.php 225835 2006-12-26 11:59:24Z hugoki $

require_once dirname(__FILE__).'/mdb_querytool_test_base.php';

class 
TestOfMDB_QueryTool_Having extends TestOfMDB_QueryTool
{
    function 
TestOfMDB_QueryTool_Having($name __CLASS__) {
        
$this->UnitTestCase($name);
    }
    function 
test_getHaving() {
        
$this->qt =& new MDB_QT(TABLE_USER);
        
$having_string 'count(id) = 10';
        
$this->qt->setHaving($having_string);
        
$this->assertEqual($having_string$this->qt->getHaving());
    }
    function 
test_setHaving() {
        
// which company has exactly 2 workers???
        
$userIds = array();
        
$this->qt =& new MDB_QT(TABLE_USER);

        
$newData = array(
            
'login'       => 'hans',
            
'qt_password' => '0',
            
'name'        => 'Hans Dampf',
            
'address_id'  => 0,
            
'company_id'  => 1
        
);
        
$userIds[] = $this->qt->add($newData);

        
$this->qt->reset();
        
$this->qt->setWhere('id IN ('.implode(', '$userIds).')');
        
$this->qt->setGroup('company_id');
        
$this->qt->setHaving('COUNT(id) = 2');

        
// there are no company with 2 workers
        
$this->assertEqual(array(), $this->qt->getCol('company_id')); 

        
$newData = array(
            
'login'       => 'rudi',
            
'qt_password' => '0',
            
'name'        => 'Rudi Ratlos',
            
'address_id'  => 0,
            
'company_id'  => 1
        
);
        
$userIds[] = $this->qt->add($newData);
        
$newData = array(
            
'login'       => 'susi',
            
'qt_password' => '0',
            
'name'        => 'Susi Sorglos',
            
'address_id'  => 0,
            
'company_id'  => 5
        
);
        
$userIds[] = $this->qt->add($newData);

        
$this->qt->reset();
        
$this->qt->setWhere('id IN ('.implode(', '$userIds).')');
        
$this->qt->setGroup('company_id');
        
$this->qt->setHaving('count(id) = 2');

        
// company 1 has exactly 2 workers
        
$this->assertEqual(array(1), $this->qt->getCol('company_id'));

        
$newData = array(
            
'login'       => 'lieschen',
            
'qt_password' => '0',
            
'name'        => 'Lieschen Mueller',
            
'address_id'  => 0,
            
'company_id'  => 5
        
);
        
$userIds[] = $this->qt->add($newData);

        
$this->qt->reset();
        
$this->qt->setWhere('id IN ('.implode(', '$userIds).')');
        
$this->qt->setOrder('company_id');
        
$this->qt->setGroup('company_id');
        
$this->qt->setHaving('count(id) = 2');

        
// company 1 and 5 has exactly 2 workers
        
$this->assertEqual(array(15), $this->qt->getCol('company_id')); 
    }

    function 
test_addHaving() {
        
// which companies has more than one worker on the same place
        // and the company_id must be greater than 1
        
$userIds = array();
        
$this->qt =& new MDB_QT(TABLE_USER);
        
$newData = array(
            
'login'       => 'hans',
            
'qt_password' => '0',
            
'name'        => 'Hans Dampf',
            
'address_id'  => 1,
            
'company_id'  => 1
        
);
        
$userIds[] = $this->qt->add($newData);

        
$newData = array(
            
'login'       => 'rudi',
            
'qt_password' => '0',
            
'name'        => 'Rudi Ratlos',
            
'address_id'  => 1,
            
'company_id'  => 1
        
);
        
$userIds[] = $this->qt->add($newData);

        
$newData = array(
            
'login'       => 'susi',
            
'qt_password' => '0',
            
'name'        => 'Susi Sorglos',
            
'address_id'  => 2,
            
'company_id'  => 3
        
);
        
$userIds[] = $this->qt->add($newData);

        
$newData = array(
            
'login'       => 'lieschen',
            
'qt_password' => '0',
            
'name'        => 'Lieschen Mueller',
            
'address_id'  => 3,
            
'company_id'  => 5
        
);
        
$userIds[] = $this->qt->add($newData);

        
$newData = array(
            
'login'       => 'werner',
            
'qt_password' => '0',
            
'name'        => 'Werner Lehmann',
            
'address_id'  => 3,
            
'company_id'  => 5
        
);
        
$userIds[] = $this->qt->add($newData);
        


        
$this->qt->setGroup('company_id,address_id');
        
$this->qt->setHaving('count(address_id) > 1');
        
$this->qt->addHaving('company_id > 1');

        
// first test
        
$this->assertEqual(array(5), $this->qt->getCol('company_id')); 

        
$this->qt->reset();

        
$this->qt->setGroup('company_id,address_id');
        
$this->qt->addHaving('count(address_id) > 1'); // this is not correct but must also work.
        
$this->qt->addHaving('company_id > 1');

        
// second test
        
$this->assertEqual(array(5), $this->qt->getCol('company_id')); 
    }
}

if (!
defined('TEST_RUNNING')) {
    
define('TEST_RUNNING'true);
    
$test = &new TestOfMDB_QueryTool_Having();
    
$test->run(new HtmlReporter());
}
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.1 [PHP 8 Update] [02.02.2022] maintained byC99Shell Github | Generation time: 0.5324 ]--