예제 #1
0
 public function testMongoAdapterHas()
 {
     $this->assertTrue($this->adapter->hasImage('id'));
     $mongoCollection = $this->getMockBuilder('MongoCollection')->disableOriginalConstructor()->getMock();
     $mongoCollection->expects($this->any())->method('findOne')->will($this->returnValue(false));
     /** @var $mongoCollection \MongoCollection */
     $this->adapter->setMongoCollection($mongoCollection);
     $this->assertFalse($this->adapter->hasImage('id'));
 }
 /**
  * Create service with name
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @param string $name
  * @param string $requestedName
  * @return StorageInterface
  */
 public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
 {
     $config = $this->getConfig($serviceLocator)[$requestedName];
     /** @var $mongoDb \MongoDB */
     $mongoDb = $serviceLocator->get($config['database']);
     $mongoCollection = new \MongoCollection($mongoDb, $config['collection']);
     $adapter = new MongoAdapter();
     if (isset($config['identifier'])) {
         $adapter->setIdentifierName($config['identifier']);
     }
     return $adapter->setMongoCollection($mongoCollection);
 }