getCountSubquery() public method

Returns the count subquery for DataModel's has() and whereHas() methods.
public getCountSubquery ( string $tableAlias = null ) : JDatabaseQuery
$tableAlias string The alias of the local table in the query. Leave blank to use the table's name.
return JDatabaseQuery
Esempio n. 1
0
    /**
     * @group           HasMany
     * @group           HasManyGetCountSubquery
     * @covers          FOF30\Model\DataModel\Relation\HasMany::getCountSubquery
     */
    public function testGetCountSubquery()
    {
        //\PHPUnit_Framework_Error_Warning::$enabled = false;
        $model = $this->buildModel();
        $relation = new HasMany($model, 'Children');
        $query = $relation->getCountSubquery();
        $check = '
SELECT COUNT(*)
FROM `#__fakeapp_children` AS `reltbl`
WHERE `reltbl`.`fakeapp_parent_id` = `#__fakeapp_parents`.`fakeapp_parent_id`';
        $this->assertEquals($check, $query, 'HasMany::getCountSubquery Returned the wrong query');
    }