RedUNIT\Base\Tags::testTagsWithSQL PHP Method

testTagsWithSQL() public method

Tests tags with SQL.
public testTagsWithSQL ( ) : void
return void
    public function testTagsWithSQL()
    {
        R::nuke();
        list($m1, $m2, $m3) = R::dispense('movie', 3);
        $m1->title = 'Frankenstein';
        $m2->title = 'Fall of the House Usher';
        $m3->title = 'Sleepy Hollow';
        R::tag($m1, 'horror,gothic');
        R::tag($m2, 'horror,gothic,short');
        R::tag($m3, 'horror,legend');
        asrt(count(R::tagged('movie', 'horror')), 3);
        asrt(count(R::tagged('movie', 'horror', ' LIMIT 2')), 2);
        asrt(count(R::tagged('movie', 'horror', ' LIMIT ?', array(2))), 2);
        asrt(count(R::tagged('movie', 'horror', ' ORDER BY movie.title DESC LIMIT ?', array(2))), 2);
        asrt(count(R::tagged('movie', 'horror,gothic', ' ORDER BY movie.title DESC LIMIT ?', array(1))), 1);
        asrt(count(R::tagged('movie', 'horror,gothic')), 3);
        asrt(count(R::taggedAll('movie', 'horror,gothic')), 2);
        asrt(count(R::tagged('movie', 'horror,gothic', ' LIMIT ? ', array(2))), 2);
        asrt(count(R::taggedAll('movie', 'horror,gothic', ' LIMIT ? ', array(2))), 2);
        asrt(count(R::tagged('movie', 'horror,gothic', ' LIMIT ? ', array(1))), 1);
        asrt(count(R::taggedAll('movie', 'horror,gothic', ' LIMIT ? ', array(1))), 1);
        asrt(count(R::tagged('movie', 'horror,legend', ' LIMIT ? ', array(1))), 1);
        asrt(count(R::taggedAll('movie', 'horror,legend', ' LIMIT ? ', array(1))), 1);
        asrt(count(R::tagged('movie', 'gothic,legend', ' LIMIT ? ', array(1))), 1);
        asrt(count(R::taggedAll('movie', 'gothic,legend', ' LIMIT ? ', array(1))), 0);
        asrt(count(R::tagged('movie', 'romance', ' LIMIT ? ', array(1))), 0);
        asrt(count(R::taggedAll('movie', 'romance', ' LIMIT ? ', array(1))), 0);
        asrt(count(R::tagged('movie', 'romance,xmas', ' LIMIT ? ', array(1))), 0);
        asrt(count(R::taggedAll('movie', 'romance,xmas', ' LIMIT ? ', array(1))), 0);
        asrt(count(R::tagged('movie', 'gothic,short', ' LIMIT ? ', array(4))), 2);
        asrt(count(R::taggedAll('movie', 'gothic,short', ' LIMIT ? ', array(4))), 1);
        asrt(count(R::tagged('movie', 'gothic,short', ' LIMIT 4 ')), 2);
        asrt(count(R::taggedAll('movie', 'gothic,short', ' LIMIT 4 ')), 1);
        asrt(count(R::tagged('movie', 'gothic,short', ' ORDER BY movie.id DESC LIMIT 4 ')), 2);
        asrt(count(R::taggedAll('movie', 'gothic,short', ' ORDER BY movie.id DESC LIMIT 4 ')), 1);
        asrt(count(R::tagged('movie', 'short', ' LIMIT ? ', array(4))), 1);
        asrt(count(R::taggedAll('movie', 'short', ' LIMIT ? ', array(4))), 1);
        asrt(count(R::tagged('movie', '', ' LIMIT ? ', array(4))), 0);
        asrt(count(R::taggedAll('movie', '', ' LIMIT ? ', array(4))), 0);
        asrt(count(R::tagged('movie', '', ' LIMIT 4 ')), 0);
        asrt(count(R::taggedAll('movie', '', ' LIMIT 4 ')), 0);
        asrt(count(R::tagged('movie', '', '')), 0);
        asrt(count(R::taggedAll('movie', '', '')), 0);
        asrt(count(R::tagged('movie', '')), 0);
        asrt(count(R::taggedAll('movie', '')), 0);
    }