public function testWithLocators() { $this->if($this->mockClass('\\Spy\\Timeline\\Filter\\DataHydrator', '\\Mock'))->and($this->mockClass('\\Spy\\Timeline\\Filter\\DataHydrator\\Locator\\LocatorInterface', '\\Mock'))->and($this->mockClass('\\Spy\\Timeline\\Model\\ActionInterface', '\\Mock'))->and($this->mockClass('\\Spy\\Timeline\\Model\\ActionComponentInterface', '\\Mock'))->and($this->mockClass('\\Spy\\Timeline\\Model\\ComponentInterface', '\\Mock'))->and($locator = new \Mock\LocatorInterface())->and($locator->getMockController()->supports = function ($model) { return $model == 'man'; })->and($locator->getMockController()->locate = function ($model, $components) { $components['man#chuck']->getMockController()->getData = 'Chuck Norris'; $components['man#bruce']->getMockController()->getData = 'Bruce Lee'; })->and($component1 = new \Mock\ComponentInterface())->and($component1->getMockController()->getModel = 'man')->and($component1->getMockController()->getHash = 'man#chuck')->and($component2 = new \Mock\ComponentInterface())->and($component2->getMockController()->getModel = 'man')->and($component2->getMockController()->getHash = 'man#bruce')->and($component3 = new \Mock\ComponentInterface())->and($component3->getMockController()->getModel = 'monkey')->and($actionComponent1 = new \Mock\ActionComponentInterface())->and($actionComponent1->getMockController()->getComponent = $component1)->and($actionComponent2 = new \Mock\ActionComponentInterface())->and($actionComponent2->getMockController()->getComponent = $component2)->and($actionComponent3 = new \Mock\ActionComponentInterface())->and($actionComponent3->getMockController()->getComponent = $component3)->and($action = new \Mock\ActionInterface())->and($action->getMockController()->getActionComponents = array($actionComponent1, $actionComponent2, $actionComponent3))->and($filter = new \Mock\DataHydrator())->and($filter->addLocator($locator))->array($filter->filter(array($action)))->hasSize(1)->string($component1->getData())->isEqualTo('Chuck Norris')->string($component2->getData())->isEqualTo('Bruce Lee')->variable($component3->getData())->isNull()->and($filter = new \Mock\DataHydrator(true))->and($filter->addLocator($locator))->array($filter->filter(array($action)))->hasSize(0); }
public function testToArray() { $this->if($qb = new QueryBuilderTested())->and($this->mockClass('Spy\\Timeline\\Driver\\QueryBuilder\\Criteria\\CriteriaInterface', '\\Mock'))->and($this->mockClass('Spy\\Timeline\\Model\\ComponentInterface', '\\Mock'))->and($subject = new \Mock\ComponentInterface())->and($subject->getMockController()->getHash = 'hash')->and($criteria = new \Mock\CriteriaInterface())->and($criteria->getMockController()->toArray = 'TOARRAYRESULT')->and($qb->setCriterias($criteria))->and($qb->setPage(10))->and($qb->setMaxPerPage(100))->and($qb->orderBy('createdAt', 'DESC'))->and($qb->addSubject($subject))->array($qb->toArray())->isIdenticalTo(array('subject' => array('hash'), 'page' => 10, 'max_per_page' => 100, 'criterias' => 'TOARRAYRESULT', 'sort' => array('createdAt', 'DESC'))); }
public function testGetIdent() { $this->if($this->mockClass('\\Spy\\Timeline\\Model\\ComponentInterface', '\\Mock'))->and($component = new \Mock\ComponentInterface())->and($component->getMockController()->getHash = 'myhash')->and($entry = new TestedModel($component))->string($entry->getIdent())->isEqualTo('myhash')->mock($component)->call('getHash')->once(); }
public function testNotify() { $this->if($this->mockClass('\\Spy\\Timeline\\Driver\\TimelineManagerInterface', '\\Mock'))->and($this->mockClass('\\Spy\\Timeline\\Model\\ActionInterface', '\\Mock'))->and($this->mockClass('\\Spy\\Timeline\\Model\\ComponentInterface', '\\Mock'))->and($manager = new \Mock\TimelineManagerInterface())->and($notifier = new TestedModel($manager))->and($action = new \Mock\ActionInterface())->and($ec = new EntryCollection())->when($notifier->notify($action, $ec))->mock($manager)->call('createAndPersist')->never()->mock($manager)->call('flush')->never()->and($component = new \Mock\ComponentInterface())->and($component->getMockController()->getModel = 'User')->and($component->getMockController()->getIdentifier = '1337')->and($ec->add(new Entry($component)))->when($notifier->notify($action, $ec))->mock($manager)->call('createAndPersist')->withArguments($action, $component, 'GLOBAL', 'notification')->once()->mock($manager)->call('flush')->once(); }
public function testBuild() { $this->if($this->mockClass('\\Spy\\Timeline\\Model\\ActionInterface', '\\Mock'))->if($this->mockClass('\\Spy\\Timeline\\Model\\ActionComponentInterface', '\\Mock'))->if($this->mockClass('\\Spy\\Timeline\\Model\\ComponentInterface', '\\Mock'))->and($component1 = new \Mock\ComponentInterface())->and($component1->getMockController()->getHash = 'hashOA')->and($component2 = new \Mock\ComponentInterface())->and($component2->getMockController()->getHash = 'hashoir')->and($component3 = new \Mock\ComponentInterface())->and($component3->getMockController()->getData = 'already set')->and($actionComponent1 = new \Mock\ActionComponentInterface())->and($actionComponent1->getMockController()->getComponent = $component1)->and($actionComponent2 = new \Mock\ActionComponentInterface())->and($actionComponent2->getMockController()->getComponent = $component2)->and($actionComponent3 = new \Mock\ActionComponentInterface())->and($actionComponent3->getMockController()->getComponent = $component2)->and($action = new \Mock\ActionInterface())->and($action->getMockController()->getActionComponents = array($actionComponent1, $actionComponent2, $actionComponent3))->and($entry = new TestedModel($action, 'key'))->when($entry->build())->array($entry->getComponents())->isIdenticalTo(array('hashOA' => $component1, 'hashoir' => $component2)); }