function it_detect_device_from_cache(VisitorManagerInterface $visitorManager, TokenPoolInterface $tokenPool, FingerprintGeneratorInterface $fingerprintGenerator, CollatorInterface $collator, DeviceCacheInterface $deviceCache) { $this->beConstructedWith($visitorManager, $collator); $visitorManager->visit(Argument::exact($tokenPool->getWrappedObject()), Argument::exact($collator->getWrappedObject()))->shouldNotBeCalled(1); $fingerprint = sha1(time()); $fingerprintGenerator->generate(Argument::exact($tokenPool->getWrappedObject()))->shouldBeCalledTimes(1)->willReturn($fingerprint); $this->setFingerprintGenerator($fingerprintGenerator); $deviceCache->get(Argument::exact($fingerprint))->shouldBeCalledTimes(1)->willReturn(new CacheDevice(new Device(array()), $fingerprint)); $deviceCache->add(Argument::any())->shouldNotBeCalled(); $this->setDeviceCache($deviceCache); $collator->removeAll()->shouldNotBeCalled(0); $collator->getAll()->shouldNotBeCalled(0); $this->detect($tokenPool)->shouldReturnAnInstanceOf('DeviceDetectorIO\\DeviceDetector\\Device\\CacheDevice'); }
function it_detect_device(TokenPoolInterface $tokenPool, CollatorInterface $collator, VisitorManagerInterface $visitorManager) { $visitorManager->visit(Argument::exact($tokenPool->getWrappedObject()), Argument::exact($collator->getWrappedObject()))->shouldBeCalledTimes(1)->willReturn(VisitorInterface::STATE_SEEKING); $collator->removeAll()->shouldBeCalledTimes(1); $collator->getAll()->shouldBeCalledTimes(1)->willReturn(array()); $this->beConstructedWith($visitorManager, $collator); $this->detect($tokenPool)->shouldReturnAnInstanceOf('DeviceDetectorIO\\DeviceDetector\\Device\\Device'); }