Вход Регистрация
Файл: src/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php
Строк: 83
<?php

namespace DoctrineTestsCommonCollections;

use 
DoctrineCommonCollectionsCriteria;
use 
DoctrineCommonCollectionsExprComparison;
use 
DoctrineCommonCollectionsExprCompositeExpression;

class 
CriteriaTest extends PHPUnit_Framework_TestCase
{
    public function 
testCreate()
    {
        
$criteria Criteria::create();

        
$this->assertInstanceOf('DoctrineCommonCollectionsCriteria'$criteria);
    }

    public function 
testConstructor()
    {
        
$expr     = new Comparison("field""=""value");
        
$criteria = new Criteria($expr, array("foo" => "ASC"), 1020);

        
$this->assertSame($expr$criteria->getWhereExpression());
        
$this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings());
        
$this->assertEquals(10$criteria->getFirstResult());
        
$this->assertEquals(20$criteria->getMaxResults());
    }

    public function 
testWhere()
    {
        
$expr     = new Comparison("field""=""value");
        
$criteria = new Criteria();

        
$criteria->where($expr);

        
$this->assertSame($expr$criteria->getWhereExpression());
    }

    public function 
testAndWhere()
    {
        
$expr     = new Comparison("field""=""value");
        
$criteria = new Criteria();

        
$criteria->where($expr);
        
$expr $criteria->getWhereExpression();
        
$criteria->andWhere($expr);

        
$where $criteria->getWhereExpression();
        
$this->assertInstanceOf('DoctrineCommonCollectionsExprCompositeExpression'$where);

        
$this->assertEquals(CompositeExpression::TYPE_AND$where->getType());
        
$this->assertSame(array($expr$expr), $where->getExpressionList());
    }

    public function 
testOrWhere()
    {
        
$expr     = new Comparison("field""=""value");
        
$criteria = new Criteria();

        
$criteria->where($expr);
        
$expr $criteria->getWhereExpression();
        
$criteria->orWhere($expr);

        
$where $criteria->getWhereExpression();
        
$this->assertInstanceOf('DoctrineCommonCollectionsExprCompositeExpression'$where);

        
$this->assertEquals(CompositeExpression::TYPE_OR$where->getType());
        
$this->assertSame(array($expr$expr), $where->getExpressionList());
    }

    public function 
testOrderings()
    {
        
$criteria Criteria::create()
            ->
orderBy(array("foo" => "ASC"));

        
$this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings());
    }

    public function 
testExpr()
    {
        
$this->assertInstanceOf('DoctrineCommonCollectionsExpressionBuilder'Criteria::expr());
    }
}
Онлайн: 1
Реклама