public function testFromArray() { $this->if($this->mockClass('Spy\\Timeline\\Driver\\QueryBuilder\\QueryBuilderFactory', '\\Mock'))->and($this->mockClass('Spy\\Timeline\\Driver\\QueryBuilder\\Criteria\\CriteriaInterface', '\\Mock'))->and($this->mockClass('Spy\\Timeline\\Driver\\ActionManagerInterface', '\\Mock'))->and($this->mockClass('Spy\\Timeline\\Model\\ComponentInterface', '\\Mock'))->and($criteria = new \Mock\CriteriaInterface())->and($factory = new \Mock\QueryBuilderFactory())->and($factory->getMockController()->createAsserterFromArray = $criteria)->and($component = new \Mock\ComponentInterface())->and($actionManager = new \Mock\ActionManagerInterface())->and($actionManager->getMockController()->findComponents = array($component))->and($qb = new QueryBuilderTested($factory))->and($data = array('subject' => array('hash'), 'page' => 10, 'max_per_page' => 100, 'sort' => array('createdAt', 'DESC'), 'criterias' => array('type' => 'expr')))->and($resultExpected = new QueryBuilderTested($factory))->and($resultExpected->setPage(10))->and($resultExpected->setMaxPerPage(100))->and($resultExpected->orderBy('createdAt', 'DESC'))->and($resultExpected->setCriterias($criteria))->and($resultExpected->addSubject($component))->object($data = $qb->fromArray($data, $actionManager))->isEqualTo($resultExpected); }
public function testFromArray() { $this->if($model = new TestedModel())->and($this->mockClass('Spy\\Timeline\\Driver\\QueryBuilder\\Criteria\\Operator', '\\Mock'))->and($this->mockClass('Spy\\Timeline\\Driver\\QueryBuilder\\Criteria\\Asserter', '\\Mock'))->and($this->mockClass('Spy\\Timeline\\Driver\\QueryBuilder\\QueryBuilderFactory', '\\Mock'))->and($operator = new \Mock\Operator())->and($asserter = new \Mock\Asserter())->and($factory = new \Mock\QueryBuilderFactory())->and($factory->getMockController()->createOperatorFromArray = $operator)->and($factory->getMockController()->createAsserterFromArray = $asserter)->and($resultExpected = new TestedModel())->and($resultExpected->addCriteria($asserter))->and($resultExpected->addCriteria($operator))->and($resultExpected->setType('AND'))->object($model->fromArray(array('type' => 'operator', 'value' => 'AND', 'criterias' => array(array('type' => 'expr'), array('type' => 'operator'))), $factory))->isEqualTo($resultExpected)->object($model->fromArray(array('type' => 'operator', 'value' => 'AND', 'criterias' => array(array('type' => 'operator'), array('type' => 'expr'))), $factory))->isNotEqualTo($resultExpected); }