14 Commits

Author SHA1 Message Date
Emanuele Minotto
e32cd91113 Merge pull request #94 from doctrine/issues/91
RiakStorage upgrade
2019-09-20 21:42:29 +02:00
EmanueleMinotto
8f07e47320 Replace riak client with php-riak/riak-client 2019-09-20 21:28:57 +02:00
EmanueleMinotto
186c8e04d2 Add riak to Travis 2019-09-11 21:55:39 +02:00
Emanuele Minotto
fe7dcc5c79 Merge pull request #95 from doctrine/issues/93
MongoDbStorage upgrade
2019-09-11 21:42:11 +02:00
EmanueleMinotto
218a870dd3 Create UPGRADE.md 2019-09-11 21:36:23 +02:00
EmanueleMinotto
b62b9ea098 Drop PHP 5.5 support 2019-09-11 21:36:23 +02:00
EmanueleMinotto
3800fa4d5c Add mongo to Travis 2019-09-11 21:36:23 +02:00
EmanueleMinotto
a50dade76d Replace legacy Mongo class with MongoDB Client 2019-09-11 21:36:23 +02:00
EmanueleMinotto
6f154f5378 Add mongodb/mongodb dependency 2019-09-08 08:23:09 +02:00
Emanuele Minotto
ac4c317a7e Merge pull request #92 from doctrine/fix-tests-for-maintainance
Fix storage tests for maintainance
2019-09-03 08:31:00 +02:00
EmanueleMinotto
705d5fc1d1 Add different versions support 2019-08-31 15:44:22 +02:00
EmanueleMinotto
465bd365f7 Remove HHVM support 2019-08-31 15:44:22 +02:00
EmanueleMinotto
9fb5e498ed Replace deprecated TestCase::getMock 2019-08-31 15:44:22 +02:00
EmanueleMinotto
573723ab3c Skip legacy Riak tests 2019-08-31 15:03:05 +02:00
71 changed files with 498 additions and 4118 deletions

View File

@@ -5,13 +5,31 @@ services:
- redis-server
php:
- 5.5
- 5.6
- 7.0
- hhvm
- 7.1
- 7.2
- 7.3
addons:
apt:
sources:
-
key_url: 'https://packagecloud.io/gpg.key'
sourceline: 'deb https://packagecloud.io/basho/riak/ubuntu/ trusty main'
-
key_url: 'https://packagecloud.io/gpg.key'
sourceline: 'deb-src https://packagecloud.io/basho/riak/ubuntu/ trusty main'
update: true
cache:
apt: true
before_install:
- if [[ $TRAVIS_PHP_VERSION != "hhvm" && $TRAVIS_PHP_VERSION != "7.0" ]]; then sh ./tests/travis.sh; fi
- sudo apt-get install -y --allow-unauthenticated riak
- sudo service riak start
- pecl install --force mongodb
- if [[ ${TRAVIS_PHP_VERSION:0:1} != "7" ]]; then sh ./tests/travis.sh; fi
- composer self-update
install:

7
UPGRADE.md Normal file
View File

@@ -0,0 +1,7 @@
# Upgrade to 0.3
## BC Break: Fixed MongoDB storage usage
Before v0.3 the storage name associated to a class wasn't used when the storage is `MongoDbStorage`.
In order to be consistent with other storage drivers, the `storageName` is now used for the collection name when storing and data.
To get the same behavior as in older versions, pass the collection name given in the constructor arguments as storage name.

View File

@@ -9,13 +9,13 @@
"doctrine/couchdb": "^1.0.0-beta4",
"phpunit/phpunit": "^4.8|^5.0",
"aws/aws-sdk-php": "^3.8",
"riak/riak-client": "dev-master"
"php-riak/riak-client": "^1.0@alpha",
"mongodb/mongodb": "^1.4"
},
"suggest": {
"aws/aws-sdk-php": "to use the DynamoDB storage",
"doctrine/couchdb": "to use the CouchDB storage",
"ext-couchbase": "to use the Couchbase storage",
"riak/riak-client": "to use the Riak storage"
"ext-couchbase": "to use the Couchbase storage"
},
"description": "Simple Key-Value Store Abstraction Layer that maps to PHP objects, allowing for many backends.",
"license": "MIT",
@@ -26,8 +26,7 @@
},
"autoload-dev": {
"psr-4": {
"Doctrine\\Tests\\": "tests/Doctrine/Tests",
"Doctrine\\KeyValueStore\\": "tests/Doctrine/KeyValueStore"
"Doctrine\\Tests\\": "tests/Doctrine/Tests"
}
}
}

View File

@@ -8,7 +8,7 @@ This guide covers getting started with the Doctrine Key Value Store.
To use the KeyValueStore you actually need:
- PHP 5.5 or above
- PHP 5.6 or above
- Composer Package Manager (`Install Composer
<http://getcomposer.org/doc/00-intro.md>`_)

View File

@@ -224,36 +224,35 @@ See the `AWS docs <http://docs.aws.amazon.com/amazondynamodb/latest/developergui
MongoDB
-------
Mongo support is provided using a `Mongo <http://php.net/manual/en/class.mongo.php>`_
instance, the collection name and the database name.
Both the options ``collection`` and ``database`` are required.
MongoDB is based on `mongodb/mongodb <https://github.com/mongodb/mongo-php-library>`_:
MongoDB support is provided using a `Database <https://docs.mongodb.com/php-library/current/reference/class/MongoDBDatabase/>`_
instance.
.. code-block:: php
<?php
use MongoDB\Client;
use Doctrine\KeyValueStore\Storage\MongoDbStorage;
$conn = new \Mongo(/* connection parameters and options */);
$client = new Client(/* connection parameters and options */);
$storage = new MongoDbStorage($conn, array(
'collection' => 'your_collection',
'database' => 'your_database',
));
$storage = new MongoDbStorage($client->your_database);
Riak
----
Riak support is provided through the library `riak/riak-client <https://github.com/nacmartin/riak-client>`_ :
Riak support is provided through the library `php-riak/riak-client <https://github.com/php-riak/riak-client>`_ :
.. code-block:: php
<?php
use Doctrine\KeyValueStore\Storage\RiakStorage;
use Riak\Client;
use Riak\Client\RiakClientBuilder;
$conn = new Riak(/* connection parameters */);
$conn = (new RiakClientBuilder())
->withNodeUri(/* connection DNS */)
->build();
$storage = new RiakStorage($conn);

View File

@@ -34,98 +34,88 @@ use Doctrine\KeyValueStore\Id\NullIdConverter;
class Configuration
{
/**
* @var null|MappingDriver
* @param array
*/
private $mappingDriver;
/**
* @var null|Cache
*/
private $metadataCache;
/**
* @var null|IdConverterStrategy
*/
private $idConverter;
private $config;
/**
* Get mapping driver implementation used with this configuration.
*
* @return MappingDriver
* @return \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver
*/
public function getMappingDriverImpl()
{
if (! isset($this->mappingDriver)) {
if (! isset($this->config['mappingDriver'])) {
throw KeyValueStoreException::mappingDriverMissing();
}
return $this->mappingDriver;
return $this->config['mappingDriver'];
}
/**
* Set the mapping driver implementation.
*
* @param MappingDriver $driver
* @param \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver $driver
*
* @return Configuration
* @return \Doctrine\KeyValueStore\Configuration
*/
public function setMappingDriverImpl(MappingDriver $driver)
{
$this->mappingDriver = $driver;
$this->config['mappingDriver'] = $driver;
return $this;
}
/**
* Set the Metadata Mapping cache used with this configuration.
*
* @param Cache $cache
* @param \Doctrine\Common\Cache\Cache $cache
*
* @return Configuration
* @return \Doctrine\KeyValueStore\Configuration
*/
public function setMetadataCache(Cache $cache)
{
$this->metadataCache = $cache;
$this->config['metadataCache'] = $cache;
return $this;
}
/**
* Get the metadata mapping cache used with this configuration.
*
* @return Cache
* @return \Doctrine\Common\Cache\Cache $cache
*/
public function getMetadataCache()
{
if (! isset($this->metadataCache)) {
$this->metadataCache = new ArrayCache();
if (! isset($this->config['metadataCache'])) {
$this->config['metadataCache'] = new ArrayCache();
}
return $this->metadataCache;
return $this->config['metadataCache'];
}
/**
* Set the ID Converter Strategy
*
* @param IdConverterStrategy $strategy
* @param \Doctrine\KeyValueStore\Id\IdConverterStrategy
*
* @return Configuration
* @return \Doctrine\KeyValueStore\Configuration
*/
public function setIdConverterStrategy(IdConverterStrategy $strategy)
{
$this->idConverter = $strategy;
$this->config['idConverter'] = $strategy;
return $this;
}
/**
* Get the Id Converter strategy
*
* @return IdConverterStrategy
* @return \Doctrine\KeyValueStore\Id\IdConverterStrategy
*/
public function getIdConverterStrategy()
{
if (! isset($this->idConverter)) {
$this->idConverter = new NullIdConverter();
if (! isset($this->config['idConverter'])) {
$this->config['idConverter'] = new NullIdConverter();
}
return $this->idConverter;
return $this->config['idConverter'];
}
}

View File

@@ -45,14 +45,14 @@ class EntityManager
* Create a new EntityManager
*
* @param Storage $storageDriver
* @param Configuration $configuration
* @param Configuration $config
*/
public function __construct(Storage $storageDriver, Configuration $configuration)
public function __construct(Storage $storageDriver, Configuration $config)
{
$classMetadataFactory = new ClassMetadataFactory($configuration->getMappingDriverImpl());
$classMetadataFactory->setCacheDriver($configuration->getMetadataCache());
$cmf = new ClassMetadataFactory($config->getMappingDriverImpl());
$cmf->setCacheDriver($config->getMetadataCache());
$this->unitOfWork = new UnitOfWork($classMetadataFactory, $storageDriver, $configuration);
$this->unitOfWork = new UnitOfWork($cmf, $storageDriver, $config);
$this->storageDriver = $storageDriver;
}
@@ -79,7 +79,7 @@ class EntityManager
* @param string $className
* @param string $partitionKey
*
* @return RangeQuery
* @return \Doctrine\KeyValueStore\Query\RangeQuery
*/
public function createRangeQuery($className, $partitionKey)
{
@@ -124,16 +124,13 @@ class EntityManager
}
/**
* @return UnitOfWork
* @return \Doctrine\KeyValueStore\UnitOfWork
*/
public function getUnitOfWork()
{
return $this->unitOfWork;
}
/**
* @see UnitOfWork::clear()
*/
public function clear()
{
return $this->unitOfWork->clear();

View File

@@ -21,50 +21,35 @@
namespace Doctrine\KeyValueStore\Id;
use Doctrine\KeyValueStore\Mapping\ClassMetadata;
use InvalidArgumentException;
class CompositeIdHandler implements IdHandlingStrategy
{
/**
* {@inheritDoc}
*/
public function normalizeId(ClassMetadata $metadata, $key)
{
if (! $metadata->isCompositeKey && ! is_array($key)) {
return [
$metadata->identifier[0] => $key,
];
}
if (! is_array($key)) {
throw new InvalidArgumentException('Array of identifier key-value pairs is expected!');
}
$id = [];
foreach ($metadata->identifier as $field) {
if (! isset($key[$field])) {
throw new InvalidArgumentException(
sprintf('Missing identifier field %s in request for the primary key.', $field)
);
$id = [$metadata->identifier[0] => $key];
} elseif (! is_array($key)) {
throw new \InvalidArgumentException('Array of identifier key-value pairs is expected!');
} else {
$id = [];
foreach ($metadata->identifier as $field) {
if (! isset($key[$field])) {
throw new \InvalidArgumentException(
"Missing identifier field $field in request for the primary key."
);
}
$id[$field] = $key[$field];
}
$id[$field] = $key[$field];
}
return $id;
}
/**
* {@inheritDoc}
*/
public function getIdentifier(ClassMetadata $metadata, $object)
{
return $metadata->getIdentifierValues($object);
}
/**
* {@inheritDoc}
*/
public function hash($key)
{
return implode('__##__', (array) $key);

View File

@@ -31,23 +31,6 @@ namespace Doctrine\KeyValueStore\Id;
*/
interface IdConverterStrategy
{
/**
* Serialize data for the persistence.
*
* @param string $class
* @param mixed $data
*
* @return string
*/
public function serialize($class, $data);
/**
* Unserialize data from the persistence system.
*
* @param string $class
* @param mixed $data
*
* @return mixed
*/
public function unserialize($class, $data);
}

View File

@@ -22,17 +22,11 @@ namespace Doctrine\KeyValueStore\Id;
class NullIdConverter implements IdConverterStrategy
{
/**
* {@inheritDoc}
*/
public function serialize($class, $data)
{
return $data;
}
/**
* {@inheritDoc}
*/
public function unserialize($class, $data)
{
return $data;

View File

@@ -24,9 +24,6 @@ use Doctrine\KeyValueStore\Mapping\ClassMetadata;
class SingleIdHandler implements IdHandlingStrategy
{
/**
* {@inheritDoc}
*/
public function normalizeId(ClassMetadata $metadata, $key)
{
if (is_scalar($key)) {
@@ -37,18 +34,12 @@ class SingleIdHandler implements IdHandlingStrategy
}
}
/**
* {@inheritDoc}
*/
public function getIdentifier(ClassMetadata $metadata, $object)
{
$values = $metadata->getIdentifierValues($object);
return $values[$metadata->identifier[0]];
}
/**
* {@inheritDoc}
*/
public function hash($key)
{
return $key;

View File

@@ -21,12 +21,8 @@
namespace Doctrine\KeyValueStore\Mapping;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as CommonClassMetadata;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\KeyValueStore\Mapping\Annotations\Entity;
use Doctrine\KeyValueStore\Mapping\Annotations\Id;
use Doctrine\KeyValueStore\Mapping\Annotations\Transient;
use ReflectionClass;
class AnnotationDriver implements MappingDriver
{
@@ -50,19 +46,19 @@ class AnnotationDriver implements MappingDriver
/**
* Loads the metadata for the specified class into the provided container.
*
* @param string $className
* @param CommonClassMetadata $metadata
* @param string $className
* @param ClassMetadata $metadata
*/
public function loadMetadataForClass($className, CommonClassMetadata $metadata)
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
$class = $metadata->getReflectionClass();
if (! $class) {
// this happens when running annotation driver in combination with
// static reflection services. This is not the nicest fix
$class = new ReflectionClass($metadata->name);
$class = new \ReflectionClass($metadata->name);
}
$entityAnnot = $this->reader->getClassAnnotation($class, Entity::class);
$entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\KeyValueStore\Mapping\Annotations\Entity');
if (! $entityAnnot) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
@@ -70,26 +66,21 @@ class AnnotationDriver implements MappingDriver
// Evaluate annotations on properties/fields
foreach ($class->getProperties() as $property) {
$idAnnot = $this->reader->getPropertyAnnotation($property, Id::class);
$idAnnot = $this->reader->getPropertyAnnotation(
$property,
'Doctrine\KeyValueStore\Mapping\Annotations\Id'
);
$transientAnnot = $this->reader->getPropertyAnnotation(
$property,
'Doctrine\KeyValueStore\Mapping\Annotations\Transient'
);
if ($idAnnot) {
$metadata->mapIdentifier($property->getName());
// if it's an identifier, can't be also a transient
// nor a mapped field
continue;
}
$transientAnnot = $this->reader->getPropertyAnnotation($property, Transient::class);
if ($transientAnnot) {
} elseif ($transientAnnot) {
$metadata->skipTransientField($property->getName());
// if it's a transiend, can't be also a mapped field
continue;
} else {
$metadata->mapField(['fieldName' => $property->getName()]);
}
$metadata->mapField([
'fieldName' => $property->getName(),
]);
}
}
@@ -100,7 +91,6 @@ class AnnotationDriver implements MappingDriver
*/
public function getAllClassNames()
{
return [];
}
/**

View File

@@ -25,91 +25,37 @@ use ReflectionClass;
class ClassMetadata implements BaseClassMetadata
{
/**
* @var string
*/
public $name;
/**
* @var string
*/
public $storageName;
/**
* @var array
*/
public $fields = [];
/**
* @var array
*/
public $identifier = [];
/**
* @var bool
*/
public $isCompositeKey = false;
/**
* @var array
*/
public $rootClassName;
public $fields = [];
public $identifier = [];
public $isCompositeKey = false;
public $transientFields = [];
public $reflFields = [];
public $reflClass;
/**
* @var array
*/
public $reflFields = [];
/**
* @var null|mixed
*/
private $prototype;
/**
* @param string|object $class
*/
public function __construct($class)
public function __construct($className)
{
if (is_object($class)) {
$reflectionClass = new ReflectionClass($class);
$class = $reflectionClass->getName();
}
$this->name = $class;
$this->name = $className;
}
/**
* Add a mapped identifier.
*
* @param string $fieldName
*/
public function mapIdentifier($fieldName)
{
$this->identifier[] = $fieldName;
$this->isCompositeKey = count($this->identifier) > 1;
$this->mapField([
'fieldName' => $fieldName,
'id' => true,
]);
$this->mapField(['fieldName' => $fieldName, 'id' => true]);
}
/**
* Add a mapped field.
*
* @param array $mapping
*/
public function mapField(array $mapping)
public function mapField($mapping)
{
if (! isset($this->transientFields[$mapping['fieldName']])) {
$this->fields[$mapping['fieldName']] = $mapping;
}
}
/**
* Add a transient field.
*
* @param string $fieldName
*/
public function skipTransientField($fieldName)
{
// it's necessary to unset because ClassMetadataFactory::initializeReflection has already run
@@ -132,29 +78,21 @@ class ClassMetadata implements BaseClassMetadata
return clone $this->prototype;
}
/**
* @return array
*/
public function __sleep()
{
return ['fields', 'isCompositeKey', 'identifier', 'name', 'storageName'];
}
/**
* Get identifiers values.
*
* @param object $object
*
* @return array
*/
public function getIdentifierValues($object)
{
$instance = $object ?: $this->newInstance();
return array_intersect_key(
get_object_vars($instance),
array_flip($this->identifier)
);
$id = [];
foreach ($this->identifier as $field) {
$value = $this->reflFields[$field]->getValue($object);
if ($value !== null) {
$id[$field] = $value;
}
}
return $id;
}
/**

View File

@@ -21,9 +21,10 @@
namespace Doctrine\KeyValueStore\Mapping;
use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as CommonClassMetadata;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\ReflectionService;
use Doctrine\KeyValueStore\Mapping\ClassMetadata as KeyValueMetadata;
/**
* Load Metadata of an entity.
@@ -32,29 +33,17 @@ use Doctrine\Common\Persistence\Mapping\ReflectionService;
*/
class ClassMetadataFactory extends AbstractClassMetadataFactory
{
/**
* @var MappingDriver
*/
private $mappingDriver;
/**
* @param MappingDriver $driver
*/
public function __construct(MappingDriver $driver)
{
$this->mappingDriver = $driver;
}
/**
* {@inheritDoc}
*/
protected function initialize()
{
}
/**
* {@inheritDoc}
*/
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
{
throw new \InvalidArgumentException('aliasing is not supported.');
@@ -79,26 +68,17 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
}
/**
* {@inheritDoc}
*/
protected function newClassMetadataInstance($className)
{
return new ClassMetadata($className);
return new KeyValueMetadata($className);
}
/**
* {@inheritDoc}
*/
protected function getDriver()
{
return $this->mappingDriver;
}
/**
* {@inheritDoc}
*/
protected function wakeupReflection(CommonClassMetadata $class, ReflectionService $reflService)
protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService)
{
$class->reflClass = $reflService->getClass($class->name);
foreach ($class->fields as $fieldName => $mapping) {
@@ -106,28 +86,20 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
}
/**
* {@inheritDoc}
*/
protected function initializeReflection(CommonClassMetadata $class, ReflectionService $reflService)
protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
{
$class->reflClass = $reflService->getClass($class->name);
if (! $class->reflClass) {
return;
}
foreach ($class->reflClass->getProperties() as $property) {
$class->mapField([
'fieldName' => $property->getName(),
]);
if ($class->reflClass) {
foreach ($class->reflClass->getProperties() as $property) {
$class->mapField(['fieldName' => $property->getName()]);
}
}
}
/**
* {@inheritDoc}
* copied from doctrine/common - tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php
*/
protected function isEntity(CommonClassMetadata $class)
protected function isEntity(ClassMetadata $class)
{
return true;
}

View File

@@ -23,8 +23,6 @@ namespace Doctrine\KeyValueStore\Mapping;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as CommonClassMetadata;
use Doctrine\Common\Persistence\Mapping\Driver\FileDriver;
use Doctrine\Common\Persistence\Mapping\MappingException;
use InvalidArgumentException;
use ReflectionClass;
class XmlDriver extends FileDriver
{
@@ -72,14 +70,14 @@ class XmlDriver extends FileDriver
try {
$xmlRoot = $this->getElement($className);
} catch (MappingException $exception) {
throw new InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
if ($xmlRoot->getName() != 'entity') {
throw new InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
$class = new ReflectionClass($className);
$class = new \ReflectionClass($className);
if (isset($xmlRoot['storage-name'])) {
$metadata->storageName = $xmlRoot['storage-name'];

View File

@@ -73,11 +73,6 @@ class RangeQuery
*/
protected $em;
/**
* @param EntityManager $em
* @param string $className
* @param string $partitionKey
*/
public function __construct(EntityManager $em, $className, $partitionKey)
{
$this->em = $em;
@@ -85,33 +80,21 @@ class RangeQuery
$this->partitionKey = $partitionKey;
}
/**
* Set query limit.
*
* @param int $limit
*
* @return RangeQuery
*/
public function setLimit($limit)
{
$this->limit = $limit;
return $this;
}
/**
* Get query results limit.
*
* @return int
*/
public function getLimit()
{
return $this->limit;
}
/**
* Get class name.
* Get className.
*
* @return string
* @return className.
*/
public function getClassName()
{
@@ -119,9 +102,9 @@ class RangeQuery
}
/**
* Get partition key.
* Get partitionKey.
*
* @return string
* @return partitionKey.
*/
public function getPartitionKey()
{

View File

@@ -20,6 +20,7 @@
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\DBAL\Connection;
use Doctrine\KeyValueStore\NotFoundException;
/**
@@ -78,7 +79,7 @@ class ArrayStorage implements Storage
*/
public function update($storageName, $key, array $data)
{
if (! isset($this->data[$storageName])) {
if (!isset($this->data[$storageName])) {
$this->data[$storageName] = [];
}
@@ -92,11 +93,11 @@ class ArrayStorage implements Storage
*/
public function delete($storageName, $key)
{
if (! isset($this->data[$storageName])) {
if (!isset($this->data[$storageName])) {
return;
}
if (! isset($this->data[$storageName][serialize($key)])) {
if (!isset($this->data[$storageName][serialize($key)])) {
return;
}
@@ -112,11 +113,11 @@ class ArrayStorage implements Storage
*/
public function find($storageName, $key)
{
if (! isset($this->data[$storageName])) {
if (!isset($this->data[$storageName])) {
throw new NotFoundException();
}
if (! isset($this->data[$storageName][serialize($key)])) {
if (!isset($this->data[$storageName][serialize($key)])) {
throw new NotFoundException();
}

View File

@@ -36,13 +36,10 @@ use WindowsAzure\Table\TableRestProxy;
class AzureSdkTableStorage implements Storage, RangeQueryStorage
{
/**
* @var TableRestProxy
* @var \WindowsAzure\Table\TableRestProxy
*/
private $client;
/**
* @param TableRestProxy $client
*/
public function __construct(TableRestProxy $client)
{
$this->client = $client;
@@ -154,11 +151,6 @@ class AzureSdkTableStorage implements Storage, RangeQueryStorage
return $this->getProperties($result->getEntity());
}
/**
* @param Entity $entity
*
* @return array
*/
private function getProperties(Entity $entity)
{
$properties = [];
@@ -213,11 +205,6 @@ class AzureSdkTableStorage implements Storage, RangeQueryStorage
return $rows;
}
/**
* @param string $value
*
* @return string
*/
private function quoteFilterValue($value)
{
return "'" . str_replace("'", '', $value) . "'";
@@ -229,7 +216,7 @@ class AzureSdkTableStorage implements Storage, RangeQueryStorage
* @param array $key
* @param array $data
*
* @return Entity
* @return \WindowsAzure\Table\Model\Entity
*/
private function createEntity(array $key, array $data)
{
@@ -249,10 +236,6 @@ class AzureSdkTableStorage implements Storage, RangeQueryStorage
/**
* Infer the property type of variables.
*
* @param mixed $propertyValue
*
* @return string
*/
private function getPropertyType($propertyValue)
{

View File

@@ -34,13 +34,10 @@ use Doctrine\KeyValueStore\NotFoundException;
class CassandraStorage implements Storage
{
/**
* @var Session
* @var \Cassandra\Session
*/
private $session;
/**
* @param Session $session
*/
public function __construct(Session $session)
{
$this->session = $session;

View File

@@ -20,7 +20,6 @@
namespace Doctrine\KeyValueStore\Storage;
use Couchbase;
use Doctrine\KeyValueStore\NotFoundException;
/**
@@ -29,16 +28,16 @@ use Doctrine\KeyValueStore\NotFoundException;
class CouchbaseStorage implements Storage
{
/**
* @var Couchbase
* @var \Couchbase
*/
protected $client;
/**
* Constructor
*
* @param Couchbase $couchbase
* @param \Couchbase $couchbase
*/
public function __construct(Couchbase $couchbase)
public function __construct(\Couchbase $couchbase)
{
$this->client = $couchbase;
}

View File

@@ -32,32 +32,11 @@ use Doctrine\KeyValueStore\NotFoundException;
*/
class DBALStorage implements Storage
{
/**
* @var Connection
*/
private $conn;
/**
* @var string
*/
private $table;
/**
* @var string
*/
private $keyColumn;
/**
* @var string
*/
private $dataColumn;
/**
* @param Connection $conn
* @param string $table
* @param string $keyColumn
* @param string $dataColumn
*/
public function __construct(
Connection $conn,
$table = 'storage',
@@ -70,16 +49,15 @@ class DBALStorage implements Storage
$this->dataColumn = $dataColumn;
}
/**
* {@inheritDoc}
*/
public function supportsPartialUpdates()
{
return false;
}
/**
* {@inheritDoc}
* Does this storage support composite primary keys?
*
* @return bool
*/
public function supportsCompositePrimaryKeys()
{
@@ -87,7 +65,9 @@ class DBALStorage implements Storage
}
/**
* {@inheritDoc}
* Does this storage require composite primary keys?
*
* @return bool
*/
public function requiresCompositePrimaryKeys()
{
@@ -95,7 +75,10 @@ class DBALStorage implements Storage
}
/**
* {@inheritDoc}
* Insert data into the storage key specified.
*
* @param array|string $key
* @param array $data
*/
public function insert($storageName, $key, array $data)
{
@@ -109,7 +92,10 @@ class DBALStorage implements Storage
}
/**
* {@inheritDoc}
* Update data into the given key.
*
* @param array|string $key
* @param array $data
*/
public function update($storageName, $key, array $data)
{
@@ -124,7 +110,9 @@ class DBALStorage implements Storage
}
/**
* {@inheritDoc}
* Delete data at key
*
* @param array|string $key
*/
public function delete($storageName, $key)
{
@@ -135,7 +123,11 @@ class DBALStorage implements Storage
}
/**
* {@inheritDoc}
* Find data at key
*
* @param array|string $key
*
* @return array
*/
public function find($storageName, $key)
{
@@ -158,7 +150,9 @@ class DBALStorage implements Storage
}
/**
* {@inheritDoc}
* Return a name of the underlying storage.
*
* @return string
*/
public function getName()
{

View File

@@ -33,55 +33,33 @@ use Doctrine\Common\Cache\Cache;
class DoctrineCacheStorage implements Storage
{
/**
* @var Cache
* @var Doctrine\Common\Cache\Cache
*/
private $cache;
/**
* @var bool
*/
private $supportsCompositeKeys;
/**
* @param Cache $cache
* @param bool $supportsCompositeKeys
*/
public function __construct(Cache $cache, $supportsCompositeKeys = true)
{
$this->cache = $cache;
$this->supportsCompositeKeys = $supportsCompositeKeys;
}
/**
* {@inheritDoc}
*/
public function supportsPartialUpdates()
{
return false;
}
/**
* {@inheritDoc}
*/
public function supportsCompositePrimaryKeys()
{
return $this->supportsCompositeKeys;
}
/**
* {@inheritDoc}
*/
public function requiresCompositePrimaryKeys()
{
return false;
}
/**
* @param string $storageName
* @param array|string $key
*
* @return string
*/
private function flattenKey($storageName, $key)
{
if (! $this->supportsCompositeKeys) {
@@ -96,45 +74,30 @@ class DoctrineCacheStorage implements Storage
return $hash;
}
/**
* {@inheritDoc}
*/
public function insert($storageName, $key, array $data)
{
$key = $this->flattenKey($storageName, $key);
$this->cache->save($key, $data);
}
/**
* {@inheritDoc}
*/
public function update($storageName, $key, array $data)
{
$key = $this->flattenKey($storageName, $key);
$this->cache->save($key, $data);
}
/**
* {@inheritDoc}
*/
public function delete($storageName, $key)
{
$key = $this->flattenKey($storageName, $key);
$this->cache->delete($key);
}
/**
* {@inheritDoc}
*/
public function find($storageName, $key)
{
$key = $this->flattenKey($storageName, $key);
return $this->cache->fetch($key);
}
/**
* {@inheritDoc}
*/
public function getName()
{
return 'doctrine_cache';

View File

@@ -290,7 +290,9 @@ class DynamoDbStorage implements Storage
}
/**
* {@inheritDoc}
* Return a name of the underlying storage.
*
* @return string
*/
public function getName()
{

View File

@@ -21,8 +21,7 @@
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\KeyValueStore\NotFoundException;
use Mongo;
use RuntimeException;
use MongoDB\Database;
/**
* MongoDb storage
@@ -32,57 +31,16 @@ use RuntimeException;
class MongoDbStorage implements Storage
{
/**
* @var Mongo
* @var Database
*/
protected $mongo;
private $database;
/**
* @var array
* @param Database $database
*/
protected $dbOptions;
/**
* @var \MongoCollection
*/
protected $collection;
/**
* Constructor
*
* @param Mongo $mongo
* @param array $dbOptions
*/
public function __construct(Mongo $mongo, array $dbOptions = [])
public function __construct(Database $database)
{
$this->mongo = $mongo;
$this->dbOptions = array_merge([
'database' => '',
'collection' => '',
], $dbOptions);
}
/**
* Initialize the mongodb collection
*
* @throws RuntimeException
*/
public function initialize()
{
if (null !== $this->collection) {
return;
}
if (empty($this->dbOptions['database'])) {
throw new RuntimeException('The option "database" must be set');
}
if (empty($this->dbOptions['collection'])) {
throw new RuntimeException('The option "collection" must be set');
}
$this->collection = $this
->mongo
->selectDB($this->dbOptions['database'])
->selectCollection($this->dbOptions['collection']);
$this->database = $database;
}
/**
@@ -114,14 +72,12 @@ class MongoDbStorage implements Storage
*/
public function insert($storageName, $key, array $data)
{
$this->initialize();
$value = [
'key' => $key,
'value' => $data,
];
$this->collection->insert($value);
$this->database
->selectCollection($storageName)
->insertOne([
'key' => $key,
'value' => $data,
]);
}
/**
@@ -129,14 +85,14 @@ class MongoDbStorage implements Storage
*/
public function update($storageName, $key, array $data)
{
$this->initialize();
$value = [
'key' => $key,
'value' => $data,
];
$this->collection->update(['key' => $key], $value);
$this->database
->selectCollection($storageName)
->replaceOne([
'key' => $key,
], [
'key' => $key,
'value' => $data,
]);
}
/**
@@ -144,9 +100,11 @@ class MongoDbStorage implements Storage
*/
public function delete($storageName, $key)
{
$this->initialize();
$this->collection->remove(['key' => $key]);
$this->database
->selectCollection($storageName)
->deleteOne([
'key' => $key,
]);
}
/**
@@ -154,19 +112,29 @@ class MongoDbStorage implements Storage
*/
public function find($storageName, $key)
{
$this->initialize();
$result = $this->database
->selectCollection($storageName, [
'typeMap' => [
'array' => 'array',
'document' => 'array',
'root' => 'array',
],
])
->findOne([
'key' => $key,
]);
$value = $this->collection->findOne(['key' => $key], ['value']);
if ($value) {
return $value['value'];
if (! $result || ! $result['value']) {
throw new NotFoundException();
}
throw new NotFoundException();
return $result['value'];
}
/**
* {@inheritDoc}
* Return a name of the underlying storage.
*
* @return string
*/
public function getName()
{

View File

@@ -21,7 +21,6 @@
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\KeyValueStore\NotFoundException;
use Redis;
/**
* @author Marcel Araujo <admin@marcelaraujo.me>
@@ -29,7 +28,7 @@ use Redis;
class RedisStorage implements Storage
{
/**
* @var Redis
* @var \Redis
*/
protected $client;
@@ -48,10 +47,10 @@ class RedisStorage implements Storage
/**
* Constructor
*
* @param Redis $redis
* @param array $dbOptions
* @param \Redis $redis
* @param array $dbOptions
*/
public function __construct(Redis $redis, $dbOptions = [])
public function __construct($redis, $dbOptions = [])
{
$this->client = $redis;
@@ -127,7 +126,9 @@ class RedisStorage implements Storage
}
/**
* {@inheritDoc}
* Return a name of the underlying storage.
*
* @return string
*/
public function getName()
{

View File

@@ -21,7 +21,14 @@
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\KeyValueStore\NotFoundException;
use Riak\Client;
use Riak\Client\Command\Kv\DeleteValue;
use Riak\Client\Command\Kv\FetchValue;
use Riak\Client\Command\Kv\StoreValue;
use Riak\Client\Core\Query\RiakLocation;
use Riak\Client\Core\Query\RiakNamespace;
use Riak\Client\Core\Query\RiakObject;
use Riak\Client\RiakClient;
use Riak\Client\RiakException;
/**
* @author Markus Bachmann <markus.bachmann@bachi.biz>
@@ -29,14 +36,11 @@ use Riak\Client;
class RiakStorage implements Storage
{
/**
* @var Client
* @var RiakClient
*/
protected $client;
private $client;
/**
* @param Client $riak
*/
public function __construct(Client $riak)
public function __construct(RiakClient $riak)
{
$this->client = $riak;
}
@@ -65,14 +69,25 @@ class RiakStorage implements Storage
return false;
}
private function store($storageName, $key, array $data)
{
$location = $this->getRiakLocation($storageName, $key);
$riakObject = new RiakObject();
$riakObject->setContentType('application/json');
$riakObject->setValue(json_encode($data));
$store = StoreValue::builder($location, $riakObject)->build();
$this->client->execute($store);
}
/**
* {@inheritDoc}
*/
public function insert($storageName, $key, array $data)
{
$bucket = $this->client->bucket($storageName);
$object = $bucket->newObject($key, $data);
$object->store();
$this->store($storageName, $key, $data);
}
/**
@@ -80,12 +95,7 @@ class RiakStorage implements Storage
*/
public function update($storageName, $key, array $data)
{
$bucket = $this->client->bucket($storageName);
/** @var $object \Riak\Object */
$object = $bucket->get($key);
$object->setData($data);
$object->store();
$this->store($storageName, $key, $data);
}
/**
@@ -93,17 +103,15 @@ class RiakStorage implements Storage
*/
public function delete($storageName, $key)
{
$bucket = $this->client->bucket($storageName);
$location = $this->getRiakLocation($storageName, $key);
/** @var $object \Riak\Object */
$object = $bucket->get($key);
$delete = DeleteValue::builder($location)->build();
if (! $object->exists()) {
// object does not exist, do nothing
return;
try {
$this->client->execute($delete);
} catch (RiakException $exception) {
// deletion can fail silent
}
$object->delete();
}
/**
@@ -111,16 +119,29 @@ class RiakStorage implements Storage
*/
public function find($storageName, $key)
{
$bucket = $this->client->bucket($storageName);
$location = $this->getRiakLocation($storageName, $key);
/** @var $object \Riak\Object */
$object = $bucket->get($key);
// fetch object
$fetch = FetchValue::builder($location)->build();
if (! $object->exists()) {
throw new NotFoundException;
try {
$result = $this->client->execute($fetch);
} catch (RiakException $exception) {
throw new NotFoundException();
}
return $object->getData();
$json = (string) $result
->getValue()
->getValue();
return json_decode($json, true);
}
private function getRiakLocation($storageName, $key)
{
$namespace = new RiakNamespace('default', $storageName);
return new RiakLocation($namespace, $key);
}
/**

View File

@@ -34,12 +34,14 @@ use Doctrine\KeyValueStore\NotFoundException;
class SimpleDbStorage implements Storage
{
/**
* @var SimpleDbClient
* @var \Aws\SimpleDb\SimpleDbClient
*/
protected $client;
/**
* @param SimpleDbClient $client
* Constructor
*
* @param \Aws\SimpleDb\SimpleDbClient $client
*/
public function __construct(SimpleDbClient $client)
{
@@ -132,7 +134,9 @@ class SimpleDbStorage implements Storage
}
/**
* {@inheritDoc}
* Return a name of the underlying storage.
*
* @return string
*/
public function getName()
{
@@ -141,8 +145,6 @@ class SimpleDbStorage implements Storage
/**
* @param string $tableName
*
* @return string
*/
protected function createDomain($domainName)
{
@@ -160,9 +162,8 @@ class SimpleDbStorage implements Storage
}
/**
* @param array $data
*
* @return array
* @param string $key
* @param array $data
*/
protected function makeAttributes($data)
{

View File

@@ -36,12 +36,10 @@ class UnitOfWork
* @var ClassMetadataFactory
*/
private $cmf;
/**
* @var Storage
*/
private $storageDriver;
/**
* @var IdHandlingStrategy
*/
@@ -55,38 +53,14 @@ class UnitOfWork
*
* @var array
*/
private $identifiers = [];
private $identifiers;
/**
* @var array
*/
private $originalData = [];
/**
* @var array
*/
private $originalData;
private $scheduledInsertions = [];
/**
* @var array
*/
private $scheduledDeletions = [];
/**
* @var array
*/
private $identityMap = [];
/**
* @var \Doctrine\KeyValueStore\Id\IdConverterStrategy
*/
private $idConverter;
/**
* @param ClassMetadataFactory $cmf
* @param Storage $storageDriver
* @param Configuration|null $config
*/
public function __construct(ClassMetadataFactory $cmf, Storage $storageDriver, Configuration $config = null)
{
$this->cmf = $cmf;
@@ -97,22 +71,11 @@ class UnitOfWork
new Id\SingleIdHandler();
}
/**
* @param string $className
*
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
*/
public function getClassMetadata($className)
{
return $this->cmf->getMetadataFor($className);
}
/**
* @param string $className
* @param mixed $id
*
* @return null|string|array
*/
private function tryGetById($className, $id)
{
$idHash = $this->idHandler->hash($id);
@@ -122,14 +85,6 @@ class UnitOfWork
return;
}
/**
* @param string $className
* @param string|array $key
*
* @throws NotFoundException
*
* @return mixed
*/
public function reconstititute($className, $key)
{
$class = $this->cmf->getMetadataFor($className);
@@ -329,9 +284,6 @@ class UnitOfWork
$this->scheduledDeletions = [];
}
/**
* Clear the unit of work.
*/
public function clear()
{
$this->scheduledInsertions = [];

View File

@@ -2,7 +2,7 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Doctrine KeyValueStore">
<directory suffix="Test.php">tests/Doctrine</directory>
<directory suffix="Test.php">tests/Doctrine/Tests/KeyValueStore</directory>
</testsuite>
</testsuites>
@@ -16,5 +16,6 @@
<var name="DOCTRINE_KEYVALUE_AZURE_AUTHSCHEMA" value="sharedlite" />
<var name="DOCTRINE_KEYVALUE_AZURE_NAME" value="" />
<var name="DOCTRINE_KEYVALUE_AZURE_KEY" value="" />
<env name="RIAK_DNS" value="" />
</php>
</phpunit>

View File

@@ -1,123 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\KeyValueStore\Id\IdConverterStrategy;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Configuration
*/
class ConfigurationTest extends PHPUnit_Framework_TestCase
{
/**
* @var Configuration
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new Configuration;
}
/**
* @covers ::getMappingDriverImpl
* @expectedException \Doctrine\KeyValueStore\KeyValueStoreException
*/
public function testGetMappingDriverImpl()
{
$this->assertInstanceOf(
MappingDriver::class,
$this->object->getMappingDriverImpl()
);
}
/**
* @covers ::getMappingDriverImpl
* @covers ::setMappingDriverImpl
* @depends testGetMappingDriverImpl
*/
public function testSetMappingDriverImpl()
{
$mappingDriver = $this->getMock(MappingDriver::class);
$setterOutput = $this->object->setMappingDriverImpl($mappingDriver);
$this->assertInstanceOf(Configuration::class, $setterOutput);
$this->assertInstanceOf(MappingDriver::class, $this->object->getMappingDriverImpl());
}
/**
* @covers ::getMetadataCache
*/
public function testGetMetadataCache()
{
$this->assertInstanceOf(
Cache::class,
$this->object->getMetadataCache()
);
}
/**
* @covers ::setMetadataCache
* @depends testGetMetadataCache
*/
public function testSetMetadataCache()
{
$cache = $this->getMock(Cache::class);
$setterOutput = $this->object->setMetadataCache($cache);
$this->assertInstanceOf(Configuration::class, $setterOutput);
$this->assertSame($cache, $this->object->getMetadataCache());
}
/**
* @covers ::getIdConverterStrategy
*/
public function testGetIdConverterStrategy()
{
$this->assertInstanceOf(
IdConverterStrategy::class,
$this->object->getIdConverterStrategy()
);
}
/**
* @covers ::setIdConverterStrategy
* @depends testGetIdConverterStrategy
*/
public function testSetIdConverterStrategy()
{
$idConverterStrategy = $this->getMock(IdConverterStrategy::class);
$setterOutput = $this->object->setIdConverterStrategy($idConverterStrategy);
$this->assertInstanceOf(Configuration::class, $setterOutput);
$this->assertSame($idConverterStrategy, $this->object->getIdConverterStrategy());
}
}

View File

@@ -1,175 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\KeyValueStore\Storage\Storage;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
/**
* @coversDefaultClass Doctrine\KeyValueStore\EntityManager
*/
class EntityManagerTest extends PHPUnit_Framework_TestCase
{
/**
* @var Storage
*/
private $storage;
/**
* @var EntityManager
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->storage = $this->getMock(Storage::class);
$configuration = $this->getMock(Configuration::class);
$configuration
->method('getMappingDriverImpl')
->willReturn($this->getMock(MappingDriver::class));
$this->object = new EntityManager($this->storage, $configuration);
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::createRangeQuery
*
* @todo Implement testCreateRangeQuery().
*/
public function testCreateRangeQuery()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::persist
*
* @todo Implement testPersist().
*/
public function testPersist()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::remove
*
* @todo Implement testRemove().
*/
public function testRemove()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::flush
*
* @todo Implement testFlush().
*/
public function testFlush()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::unwrap
*/
public function testUnwrap()
{
$this->assertSame(
$this->storage,
$this->object->unwrap()
);
}
/**
* @covers ::getUnitOfWork
*/
public function testGetUnitOfWork()
{
$this->assertInstanceOf(
UnitOfWork::class,
$this->object->getUnitOfWork()
);
}
/**
* @covers ::clear
*/
public function testClear()
{
$this->object->clear();
$clearedKeys = [
'scheduledInsertions',
'scheduledDeletions',
'identifiers',
'originalData',
'identityMap',
];
$unitOfWork = $this->object->getUnitOfWork();
$reflectionClass = new ReflectionClass($unitOfWork);
foreach ($clearedKeys as $clearedKey) {
$property = $reflectionClass->getProperty($clearedKey);
$property->setAccessible(true);
$value = $property->getValue($unitOfWork);
$this->assertInternalType('array', $value);
$this->assertEmpty($value);
}
}
/**
* @covers ::getClassMetadata
*
* @todo Implement testGetClassMetadata().
*/
public function testGetClassMetadata()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
}

View File

@@ -1,148 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Id;
use Doctrine\KeyValueStore\Mapping\ClassMetadata;
use InvalidArgumentException;
use PHPUnit_Framework_TestCase;
use stdClass;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Id\CompositeIdHandler
*/
class CompositeIdHandlerTest extends PHPUnit_Framework_TestCase
{
/**
* @var CompositeIdHandler
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new CompositeIdHandler;
}
/**
* @covers ::normalizeId
*/
public function testNormalizeId()
{
$classMetadata = $this
->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
$classMetadata->isCompositeKey = false;
$classMetadata->identifier = ['id'];
$key = 'test';
$normalizedId = $this->object->normalizeId($classMetadata, $key);
$this->assertSame(['id' => $key], $normalizedId);
$key = ['id' => 'bar'];
$normalizedId = $this->object->normalizeId($classMetadata, $key);
$this->assertSame($key, $normalizedId);
}
/**
* @covers ::normalizeId
*/
public function testWrongNormalizeId()
{
$classMetadata = $this
->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
$classMetadata->isCompositeKey = true;
$classMetadata->identifier = ['id'];
$this->setExpectedException(InvalidArgumentException::class);
$this->object->normalizeId($classMetadata, 'test');
$classMetadata->isCompositeKey = false;
$classMetadata->identifier = ['id'];
$key = ['foo' => 'bar'];
$this->setExpectedException(InvalidArgumentException::class);
$this->object->normalizeId($classMetadata, $key);
}
/**
* @covers ::getIdentifier
*/
public function testGetIdentifier()
{
$data = rand();
$metadata = $this
->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
$object = new stdClass;
$metadata->identifier = ['id'];
$metadata
->expects($this->once())
->method('getIdentifierValues')
->with($this->equalTo($object))
->willReturn($data);
$identifier = $this->object->getIdentifier($metadata, $object);
$this->assertSame($data, $identifier);
}
/**
* @covers ::hash
* @dataProvider keysProvider
*/
public function testHash($key, $expected)
{
$this->assertSame(
$expected,
$this->object->hash($key)
);
}
/**
* @return array
*/
public function keysProvider()
{
$stdClass = new stdClass;
$stdClass->foo = 'bar';
$stdClass->bar = 'foo';
return [
[['foo', 'bar'], 'foo__##__bar'],
[$stdClass, 'bar__##__foo'],
['bar', 'bar'],
];
}
}

View File

@@ -1,69 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Id;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Id\NullIdConverter
*/
class NullIdConverterTest extends PHPUnit_Framework_TestCase
{
/**
* @var NullIdConverter
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new NullIdConverter;
}
/**
* @covers ::serialize
*/
public function testSerialize()
{
$data = rand();
$this->assertSame(
$data,
$this->object->serialize(rand(), $data)
);
}
/**
* @covers ::unserialize
*/
public function testUnserialize()
{
$data = rand();
$this->assertSame(
$data,
$this->object->unserialize(rand(), $data)
);
}
}

View File

@@ -1,109 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Id;
use Doctrine\KeyValueStore\Mapping\ClassMetadata;
use PHPUnit_Framework_TestCase;
use stdClass;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Id\SingleIdHandler
*/
class SingleIdHandlerTest extends PHPUnit_Framework_TestCase
{
/**
* @var SingleIdHandler
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new SingleIdHandler;
}
/**
* @covers ::normalizeId
*/
public function testNormalizeId()
{
$metadata = $this
->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
$key = rand();
$normalizedId = $this->object->normalizeId($metadata, $key);
$this->assertSame($key, $normalizedId);
$metadata->identifier = ['id'];
$key = [
'id' => rand(),
];
$normalizedId = $this->object->normalizeId($metadata, $key);
$this->assertSame($key['id'], $normalizedId);
}
/**
* @covers ::getIdentifier
*/
public function testGetIdentifier()
{
$data = rand();
$metadata = $this
->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
$object = new stdClass;
$metadata->identifier = ['id'];
$metadata
->expects($this->once())
->method('getIdentifierValues')
->with($this->equalTo($object))
->willReturn([
'id' => $data,
]);
$identifier = $this->object->getIdentifier($metadata, $object);
$this->assertSame($data, $identifier);
}
/**
* @covers ::hash
*/
public function testHash()
{
$key = rand();
$this->assertSame(
$key,
$this->object->hash($key)
);
}
}

View File

@@ -1,115 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Mapping;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as CommonClassMetadata;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
use stdClass;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Mapping\AnnotationDriver
*/
class AnnotationDriverTest extends PHPUnit_Framework_TestCase
{
/**
* @var AnnotationReader
*/
private $annotationReader;
/**
* @var AnnotationDriver
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->annotationReader = $this->getMock(AnnotationReader::class);
$this->object = new AnnotationDriver($this->annotationReader);
}
/**
* @covers ::loadMetadataForClass
*/
public function testLoadMetadataForClass()
{
$storageName = sha1(rand());
$reflectionClass = $this
->getMockBuilder(ReflectionClass::class)
->disableOriginalConstructor()
->getMock();
$classAnnotation = $this->getMock(stdClass::class);
$classAnnotation->storageName = $storageName;
$metadata = $this->getMock(CommonClassMetadata::class);
$metadata
->method('getReflectionClass')
->willReturn($reflectionClass);
$this->annotationReader
->method('getClassAnnotation')
->willReturn($classAnnotation);
$reflectionClass
->method('getProperties')
->willReturn([]);
$this->object->loadMetadataForClass(sha1(rand()), $metadata);
}
/**
* @covers ::loadMetadataForClass
* @expectedException InvalidArgumentException
*/
public function testWrongLoadMetadataForClass()
{
$metadata = $this->getMock(CommonClassMetadata::class);
$metadata->name = 'stdClass';
$this->object->loadMetadataForClass(sha1(rand()), $metadata);
}
/**
* @covers ::getAllClassNames
*/
public function testGetAllClassNames()
{
$allClassNames = $this->object->getAllClassNames();
$this->assertInternalType('array', $allClassNames);
}
/**
* @covers ::isTransient
*/
public function testIsTransient()
{
$transient = $this->object->isTransient('stdClass');
$this->assertFalse($transient);
}
}

View File

@@ -1,320 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Mapping;
use PHPUnit_Framework_Assert;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
use stdClass;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Mapping\ClassMetadata
*/
class ClassMetadataTest extends PHPUnit_Framework_TestCase
{
/**
* @var ClassMetadata
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$class = rand(0, 1) ? stdClass::class : new stdClass;
$this->object = new ClassMetadata($class);
}
/**
* @covers ::skipTransientField
*/
public function testSkipTransientField()
{
$field = 'foo';
$this->object->skipTransientField($field);
$this->assertArrayNotHasKey($field, $this->object->fields);
$this->assertArrayHasKey($field, $this->object->transientFields);
}
/**
* @covers ::mapField
* @depends testSkipTransientField
*/
public function testMapField()
{
$field = [
'fieldName' => 'foo',
];
$this->object->mapField($field);
$this->assertArraySubset(['foo' => $field], $this->object->fields);
$transientField = [
'fieldName' => 'bar',
];
$this->object->skipTransientField('bar');
$this->object->mapField($transientField);
$this->assertArrayNotHasKey('bar', $this->object->fields);
}
/**
* @covers ::mapIdentifier
* @depends testMapField
*/
public function testMapIdentifier()
{
$this->object->mapIdentifier('id');
$this->assertFalse($this->object->isCompositeKey);
$this->assertContains('id', $this->object->identifier);
$this->assertArraySubset([
'id' => ['fieldName' => 'id', 'id' => true],
], $this->object->fields);
$this->object->mapIdentifier('pk');
$this->assertTrue($this->object->isCompositeKey);
$this->assertContains('id', $this->object->identifier);
$this->assertContains('pk', $this->object->identifier);
$this->assertArraySubset([
'id' => ['fieldName' => 'id', 'id' => true],
'pk' => ['fieldName' => 'pk', 'id' => true],
], $this->object->fields);
}
/**
* @covers ::newInstance
*/
public function testNewInstance()
{
$prototype = PHPUnit_Framework_Assert::readAttribute($this->object, 'prototype');
$this->assertNull($prototype);
$instance = $this->object->newInstance();
$prototype = PHPUnit_Framework_Assert::readAttribute($this->object, 'prototype');
$this->assertNotNull($prototype);
$this->assertInstanceOf('stdClass', $prototype);
$this->assertInstanceOf('stdClass', $instance);
$this->assertNotSame($prototype, $instance);
}
/**
* @covers ::__sleep
*/
public function testSleep()
{
$attributes = $this->object->__sleep();
foreach ($attributes as $attribute) {
$this->assertClassHasAttribute($attribute, ClassMetadata::class);
}
$this->assertInternalType('string', serialize($this->object));
}
/**
* @covers ::getIdentifierValues
*/
public function testGetIdentifierValues()
{
$identifierValues = $this->object->getIdentifierValues(new stdClass);
$this->assertInternalType('array', $identifierValues);
$this->assertEmpty($identifierValues);
$object = new stdClass;
$object->id = rand();
$this->object->mapIdentifier('id');
$identifierValues = $this->object->getIdentifierValues($object);
$this->assertInternalType('array', $identifierValues);
$this->assertNotEmpty($identifierValues);
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->markTestIncomplete();
}
/**
* @covers ::getIdentifier
*/
public function testGetIdentifier()
{
$identifier = $this->object->getIdentifier();
$this->assertInternalType('array', $identifier);
foreach ($identifier as $key => $value) {
$this->assertInternalType('integer', $key);
$this->assertInternalType('string', $value);
}
}
/**
* @covers ::getReflectionClass
*/
public function testGetReflectionClass()
{
$reflectionClass = $this->object->getReflectionClass();
$this->assertInstanceOf(ReflectionClass::class, $reflectionClass);
$this->assertSame('stdClass', $reflectionClass->name);
}
/**
* @covers ::isIdentifier
*/
public function testIsIdentifier()
{
$this->object->mapIdentifier('id');
$this->assertTrue($this->object->isIdentifier('id'));
$this->assertFalse($this->object->isIdentifier('test'));
}
/**
* @covers ::hasField
*/
public function testHasField()
{
$this->object->mapField(['fieldName' => 'foo']);
$this->assertTrue($this->object->hasField('foo'));
$this->assertFalse($this->object->hasField('bar'));
}
/**
* @covers ::hasAssociation
*/
public function testHasAssociation()
{
$this->assertFalse($this->object->hasAssociation(sha1(rand())));
}
/**
* @covers ::isSingleValuedAssociation
*/
public function testIsSingleValuedAssociation()
{
$this->assertFalse($this->object->isSingleValuedAssociation(sha1(rand())));
}
/**
* @covers ::isCollectionValuedAssociation
*/
public function testIsCollectionValuedAssociation()
{
$this->assertFalse($this->object->isCollectionValuedAssociation(sha1(rand())));
}
/**
* @covers ::getFieldNames
*/
public function testGetFieldNames()
{
$this->object->mapField(['fieldName' => 'foo']);
$fieldNames = $this->object->getFieldNames();
$this->assertInternalType('array', $fieldNames);
foreach ($fieldNames as $key => $value) {
$this->assertInternalType('integer', $key);
$this->assertInternalType('string', $value);
}
$this->assertSame(['foo'], $fieldNames);
}
/**
* @covers ::getIdentifierFieldNames
*/
public function testGetIdentifierFieldNames()
{
$identifierFieldNames = $this->object->getIdentifierFieldNames();
$this->assertInternalType('array', $identifierFieldNames);
foreach ($identifierFieldNames as $key => $value) {
$this->assertInternalType('integer', $key);
$this->assertInternalType('string', $value);
}
}
/**
* @covers ::getAssociationNames
*/
public function testGetAssociationNames()
{
$this->markTestIncomplete();
}
/**
* @covers ::getTypeOfField
*/
public function testGetTypeOfField()
{
$this->markTestIncomplete();
}
/**
* @covers ::getAssociationTargetClass
*/
public function testGetAssociationTargetClass()
{
$this->markTestIncomplete();
}
/**
* @covers ::isAssociationInverseSide
*/
public function testIsAssociationInverseSide()
{
$this->assertFalse($this->object->isAssociationInverseSide(sha1(rand())));
}
/**
* @covers ::getAssociationMappedByTargetField
*/
public function testGetAssociationMappedByTargetField()
{
$this->markTestIncomplete();
}
}

View File

@@ -1,54 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Mapping;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Mapping\XmlDriver
*/
class XmlDriverTest extends PHPUnit_Framework_TestCase
{
/**
* @var XmlDriver
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new XmlDriver(__DIR__ . '/Fixtures/xml');
}
/**
* @covers ::loadMetadataForClass
*
* @todo Implement testLoadMetadataForClass().
*/
public function testLoadMetadataForClass()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
}

View File

@@ -1,54 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Mapping;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Mapping\YamlDriver
*/
class YamlDriverTest extends PHPUnit_Framework_TestCase
{
/**
* @var YamlDriver
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new YamlDriver(__DIR__ . '/Fixtures/yaml');
}
/**
* @covers ::loadMetadataForClass
*
* @todo Implement testLoadMetadataForClass().
*/
public function testLoadMetadataForClass()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
}

View File

@@ -1,260 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Query;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\KeyValueStore\EntityManager;
use Doctrine\KeyValueStore\Storage\DoctrineCacheStorage;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
use RuntimeException;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Query\RangeQuery
*/
class RangeQueryTest extends PHPUnit_Framework_TestCase
{
/**
* @var EntityManager
*/
private $entityManager;
/**
* @var string
*/
private $className;
/**
* @var string
*/
private $partitionKey;
/**
* @var RangeQuery
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->entityManager = $this
->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
$this->className = sha1(rand());
$this->partitionKey = sha1(rand());
$this->object = new RangeQuery(
$this->entityManager,
$this->className,
$this->partitionKey
);
}
/**
* @covers ::setLimit
* @covers ::getLimit
*/
public function testLimit()
{
$limit = rand();
$setterOutput = $this->object->setLimit($limit);
$this->assertInstanceOf(RangeQuery::class, $setterOutput);
$this->assertSame($limit, $this->object->getLimit());
}
/**
* @covers ::getClassName
*/
public function testGetClassName()
{
$this->assertSame(
$this->className,
$this->object->getClassName()
);
}
/**
* @covers ::getPartitionKey
*/
public function testGetPartitionKey()
{
$this->assertSame(
$this->partitionKey,
$this->object->getPartitionKey()
);
}
/**
* @covers ::getConditions
*/
public function testGetConditions()
{
$reflectionClass = new ReflectionClass($this->object);
$constants = $reflectionClass->getConstants();
$conditions = $this->object->getConditions();
$this->assertInternalType('array', $conditions);
foreach ($conditions as $condition) {
$this->assertArrayHasKey($condition[0], $constants);
}
}
/**
* @covers ::rangeEquals
* @depends testGetConditions
*/
public function testRangeEquals()
{
$value = 'test';
$output = $this->object->rangeEquals($value);
$this->assertInstanceOf(RangeQuery::class, $output);
$conditions = $this->object->getConditions();
$this->assertArraySubset(
[[RangeQuery::CONDITION_EQ, $value]],
$conditions
);
}
/**
* @covers ::rangeNotEquals
* @depends testGetConditions
*/
public function testRangeNotEquals()
{
$value = 'test';
$output = $this->object->rangeNotEquals($value);
$this->assertInstanceOf(RangeQuery::class, $output);
$conditions = $this->object->getConditions();
$this->assertArraySubset(
[[RangeQuery::CONDITION_NEQ, $value]],
$conditions
);
}
/**
* @covers ::rangeLessThan
* @depends testGetConditions
*/
public function testRangeLessThan()
{
$value = 'test';
$output = $this->object->rangeLessThan($value);
$this->assertInstanceOf(RangeQuery::class, $output);
$conditions = $this->object->getConditions();
$this->assertArraySubset(
[[RangeQuery::CONDITION_LT, $value]],
$conditions
);
}
/**
* @covers ::rangeLessThanEquals
* @depends testGetConditions
*/
public function testRangeLessThanEquals()
{
$value = 'test';
$output = $this->object->rangeLessThanEquals($value);
$this->assertInstanceOf(RangeQuery::class, $output);
$conditions = $this->object->getConditions();
$this->assertArraySubset(
[[RangeQuery::CONDITION_LE, $value]],
$conditions
);
}
/**
* @covers ::rangeGreaterThan
* @depends testGetConditions
*/
public function testRangeGreaterThan()
{
$value = 'test';
$output = $this->object->rangeGreaterThan($value);
$this->assertInstanceOf(RangeQuery::class, $output);
$conditions = $this->object->getConditions();
$this->assertArraySubset(
[[RangeQuery::CONDITION_GT, $value]],
$conditions
);
}
/**
* @covers ::rangeGreaterThanEquals
* @depends testGetConditions
*/
public function testRangeGreaterThanEquals()
{
$value = 'test';
$output = $this->object->rangeGreaterThanEquals($value);
$this->assertInstanceOf(RangeQuery::class, $output);
$conditions = $this->object->getConditions();
$this->assertArraySubset(
[[RangeQuery::CONDITION_GE, $value]],
$conditions
);
}
/**
* @covers ::execute
*
* @todo Implement testExecute().
*/
public function testExecute()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::execute
*/
public function testWrongExecute()
{
$this->entityManager
->method('unwrap')
->willReturn(new DoctrineCacheStorage(new ArrayCache));
$this->setExpectedException(RuntimeException::class);
$this->object->execute();
}
}

View File

@@ -1,151 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use PHPUnit_Framework_TestCase;
use WindowsAzure\Common\ServicesBuilder;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\AzureSdkTableStorage
*/
class AzureSdkTableStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var AzureSdkTableStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
if (empty($GLOBALS['DOCTRINE_KEYVALUE_AZURE_NAME']) || empty($GLOBALS['DOCTRINE_KEYVALUE_AZURE_KEY'])) {
$this->markTestSkipped('Missing Azure credentials.');
}
$connectionString = sprintf(
'DefaultEndpointsProtocol=http;AccountName=%s;AccountKey=%s',
$GLOBALS['DOCTRINE_KEYVALUE_AZURE_NAME'],
$GLOBALS['DOCTRINE_KEYVALUE_AZURE_KEY']
);
$tableProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
$this->storage = new AzureSdkTableStorage($tableProxy);
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('azure_table_sdk', $this->object->getName());
}
/**
* @covers ::executeRangeQuery
*
* @todo Implement testExecuteRangeQuery().
*/
public function testExecuteRangeQuery()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
}

View File

@@ -1,129 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\CassandraStorage
* @requires extension cassandra
*/
class CassandraStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var CassandraStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new CassandraStorage;
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('cassandra', $this->object->getName());
}
}

View File

@@ -1,140 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\CouchDB\CouchDBClient;
use Doctrine\CouchDB\HTTP\StreamClient;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\CouchDbStorage
*/
class CouchDbStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var CouchDbStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$client = $this
->getMockBuilder(StreamClient::class)
->disableOriginalConstructor()
->getMock();
$this->couchdb = $this
->getMockBuilder(CouchDBClient::class)
->setConstructorArgs([$client, 'test'])
->getMock();
$this->object = new CouchDbStorage($this->couchdb);
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('couchdb', $this->object->getName());
}
}

View File

@@ -1,129 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\CouchbaseStorage
* @requires extension couchbase
*/
class CouchbaseStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var CouchbaseStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new CouchbaseStorage;
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('couchbase', $this->object->getName());
}
}

View File

@@ -1,129 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\DBAL\Connection;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\DBALStorage
*/
class DBALStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var DBALStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new DBALStorage($this->getMock(Connection::class));
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('dbal', $this->object->getName());
}
}

View File

@@ -1,129 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\Common\Cache\ArrayCache;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\DoctrineCacheStorage
*/
class DoctrineCacheStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var DoctrineCacheStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new DoctrineCacheStorage(new ArrayCache);
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('doctrine_cache', $this->object->getName());
}
}

View File

@@ -1,134 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use Aws\DynamoDb\DynamoDbClient;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\DynamoDbStorage
*/
class DynamoDbStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var DynamoDbStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$dynamoDbClient = $this
->getMockBuilder(DynamoDbClient::class)
->disableOriginalConstructor()
->getMock();
$this->object = new DynamoDbStorage($dynamoDbClient);
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('dynamodb', $this->object->getName());
}
}

View File

@@ -1,140 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\MongoDbStorage
* @requires extension mongo
*/
class MongoDbStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var MongoDbStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new MongoDbStorage;
}
/**
* @covers ::initialize
*
* @todo Implement testInitialize().
*/
public function testInitialize()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('mongodb', $this->object->getName());
}
}

View File

@@ -1,140 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\RedisStorage
* @requires extension redis
*/
class RedisStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var RedisStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new RedisStorage;
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('redis', $this->object->getName());
}
/**
* @covers ::getKeyName
*
* @todo Implement testGetKeyName().
*/
public function testGetKeyName()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
}

View File

@@ -1,318 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use PHPUnit_Framework_TestCase;
use Riak\Bucket;
use Riak\Client;
use Riak\Object;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\RiakStorage
*/
class RiakStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var Client
*/
private $client;
/**
* @var RiakStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->client = $this
->getMockBuilder(Client::class)
->disableOriginalConstructor()
->getMock();
$this->object = new RiakStorage($this->client);
}
/**
* @covers ::supportsPartialUpdates
*/
public function testSupportsPartialUpdates()
{
$this->assertFalse($this->object->supportsPartialUpdates());
}
/**
* @covers ::supportsCompositePrimaryKeys
*/
public function testSupportsCompositePrimaryKeys()
{
$this->assertFalse($this->object->supportsCompositePrimaryKeys());
}
/**
* @covers ::requiresCompositePrimaryKeys
*/
public function testRequiresCompositePrimaryKeys()
{
$this->assertFalse($this->object->requiresCompositePrimaryKeys());
}
/**
* @covers ::insert
*/
public function testInsert()
{
$bucket = $this
->getMockBuilder(Bucket::class)
->disableOriginalConstructor()
->getMock();
$this->client
->expects($this->once())
->method('bucket')
->willReturn($bucket);
$objectMock = $this
->getMockBuilder(Object::class)
->disableOriginalConstructor()
->getMock();
$objectMock
->expects($this->once())
->method('store');
$bucket
->expects($this->once())
->method('newObject')
->will($this->returnCallback(function ($key, $data) use ($objectMock) {
$this->assertEquals('foobar', $key);
$this->assertEquals(['title' => 'Riak test'], $data);
return $objectMock;
}));
$this->object->insert('riak-test', 'foobar', ['title' => 'Riak test']);
}
/**
* @covers ::update
*/
public function testUpdate()
{
$objectMock = $this
->getMockBuilder(Object::class)
->disableOriginalConstructor()
->getMock();
$bucket = $this
->getMockBuilder(Bucket::class)
->disableOriginalConstructor()
->getMock();
$this->client
->expects($this->once())
->method('bucket')
->willReturn($bucket);
$bucket
->expects($this->once())
->method('get')
->willReturn($objectMock);
$objectMock
->expects($this->once())
->method('setData')
->will($this->returnCallback(function ($data) {
$this->assertEquals(['title' => 'Riak cookbook'], $data);
}));
$objectMock
->expects($this->once())
->method('store');
$this->object->update('riak-test', 'foobar', ['title' => 'Riak cookbook']);
}
/**
* @covers ::delete
*/
public function testDelete()
{
$objectMock = $this
->getMockBuilder(Object::class)
->disableOriginalConstructor()
->getMock();
$bucket = $this
->getMockBuilder(Bucket::class)
->disableOriginalConstructor()
->getMock();
$this->client
->expects($this->once())
->method('bucket')
->willReturn($bucket);
$bucket
->expects($this->once())
->method('get')
->with('foobar')
->willReturn($objectMock);
$objectMock
->expects($this->once())
->method('exists')
->willReturn(true);
$objectMock
->expects($this->once())
->method('delete');
$this->object->delete('riak-test', 'foobar');
}
/**
* @covers ::delete
*/
public function testDeleteWithNotExistKey()
{
$objectMock = $this
->getMockBuilder(Object::class)
->disableOriginalConstructor()
->getMock();
$bucket = $this
->getMockBuilder(Bucket::class)
->disableOriginalConstructor()
->getMock();
$this->client
->expects($this->once())
->method('bucket')
->willReturn($bucket);
$bucket
->expects($this->once())
->method('get')
->with('foobar')
->willReturn($objectMock);
$objectMock
->expects($this->once())
->method('exists')
->willReturn(false);
$objectMock
->expects($this->never())
->method('delete');
$this->object->delete('riak-test', 'foobar');
}
/**
* @covers ::find
*/
public function testFind()
{
$objectMock = $this
->getMockBuilder(Object::class)
->disableOriginalConstructor()
->getMock();
$bucket = $this
->getMockBuilder(Bucket::class)
->disableOriginalConstructor()
->getMock();
$this->client
->expects($this->once())
->method('bucket')
->willReturn($bucket);
$bucket
->expects($this->once())
->method('get')
->with('foobar')
->willReturn($objectMock);
$objectMock
->expects($this->once())
->method('exists')
->willReturn(true);
$objectMock
->expects($this->once())
->method('getData')
->willReturn(['title' => 'Riak Test']);
$this->assertEquals(['title' => 'Riak Test'], $this->object->find('riaktest', 'foobar'));
}
/**
* @covers ::find
* @expectedException Doctrine\KeyValueStore\NotFoundException
*/
public function testFindWithNotExistKey()
{
$objectMock = $this
->getMockBuilder(Object::class)
->disableOriginalConstructor()
->getMock();
$bucket = $this
->getMockBuilder(Bucket::class)
->disableOriginalConstructor()
->getMock();
$this->client
->expects($this->once())
->method('bucket')
->willReturn($bucket);
$bucket
->expects($this->once())
->method('get')
->with('foobar')
->willReturn($objectMock);
$objectMock
->expects($this->once())
->method('exists')
->willReturn(false);
$objectMock
->expects($this->never())
->method('getData');
$this->object->find('riak-test', 'foobar');
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('riak', $this->object->getName());
}
}

View File

@@ -1,134 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore\Storage;
use Aws\SimpleDb\SimpleDbClient;
use PHPUnit_Framework_TestCase;
/**
* @coversDefaultClass Doctrine\KeyValueStore\Storage\SimpleDbStorage
*/
class SimpleDbStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var SimpleDbStorage
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$simpleDbClient = $this
->getMockBuilder(SimpleDbClient::class)
->disableOriginalConstructor()
->getMock();
$this->object = new SimpleDbStorage($simpleDbClient);
}
/**
* @covers ::supportsPartialUpdates
*
* @todo Implement testSupportsPartialUpdates().
*/
public function testSupportsPartialUpdates()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::supportsCompositePrimaryKeys
*
* @todo Implement testSupportsCompositePrimaryKeys().
*/
public function testSupportsCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::requiresCompositePrimaryKeys
*
* @todo Implement testRequiresCompositePrimaryKeys().
*/
public function testRequiresCompositePrimaryKeys()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::insert
*
* @todo Implement testInsert().
*/
public function testInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::update
*
* @todo Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::delete
*
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::find
*
* @todo Implement testFind().
*/
public function testFind()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::getName
*/
public function testGetName()
{
$this->assertEquals('simpledb', $this->object->getName());
}
}

View File

@@ -1,148 +0,0 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\KeyValueStore;
use Doctrine\KeyValueStore\Mapping\ClassMetadataFactory;
use Doctrine\KeyValueStore\Storage\Storage;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
/**
* @coversDefaultClass Doctrine\KeyValueStore\UnitOfWork
*/
class UnitOfWorkTest extends PHPUnit_Framework_TestCase
{
/**
* @var UnitOfWork
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$classMetadataFactory = $this
->getMockBuilder(ClassMetadataFactory::class)
->disableOriginalConstructor()
->getMock();
$storage = $this->getMock(Storage::class);
$configuration = $this->getMock(Configuration::class);
$this->object = new UnitOfWork($classMetadataFactory, $storage, $configuration);
}
/**
* @covers ::getClassMetadata
*
* @todo Implement testGetClassMetadata().
*/
public function testGetClassMetadata()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::reconstititute
*
* @todo Implement testReconstititute().
*/
public function testReconstititute()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::createEntity
*
* @todo Implement testCreateEntity().
*/
public function testCreateEntity()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::scheduleForInsert
*
* @todo Implement testScheduleForInsert().
*/
public function testScheduleForInsert()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::scheduleForDelete
*
* @todo Implement testScheduleForDelete().
*/
public function testScheduleForDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::commit
*
* @todo Implement testCommit().
*/
public function testCommit()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete();
}
/**
* @covers ::clear
*/
public function testClear()
{
$clearedKeys = [
'scheduledInsertions',
'scheduledDeletions',
'identifiers',
'originalData',
'identityMap',
];
$this->object->clear();
$reflectionClass = new ReflectionClass($this->object);
$defaultProperties = $reflectionClass->getDefaultProperties();
foreach ($clearedKeys as $clearedKey) {
$property = $reflectionClass->getProperty($clearedKey);
$property->setAccessible(true);
$this->assertSame(
$defaultProperties[$clearedKey],
$property->getValue($this->object)
);
}
}
}

View File

@@ -22,9 +22,6 @@ namespace Doctrine\Tests\KeyValueStore;
use Doctrine\KeyValueStore\Configuration;
/**
* @group legacy
*/
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
public function testNoMappingDriver()

View File

@@ -23,9 +23,6 @@ namespace Doctrine\Tests\KeyValueStore\Functional;
use Doctrine\KeyValueStore\Mapping\Annotations as KVS;
use Doctrine\Tests\KeyValueStoreTestCase;
/**
* @group legacy
*/
abstract class BasicCrudTestCase extends KeyValueStoreTestCase
{
private $manager;

View File

@@ -23,9 +23,6 @@ namespace Doctrine\Tests\KeyValueStore\Functional;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\KeyValueStore\Storage\DoctrineCacheStorage;
/**
* @group legacy
*/
class CompositeBasicCrudTest extends BasicCrudTestCase
{
private $cache;

View File

@@ -25,9 +25,6 @@ use Doctrine\KeyValueStore\Mapping\Annotations as KVS;
use Doctrine\KeyValueStore\Storage\DoctrineCacheStorage;
use Doctrine\Tests\KeyValueStoreTestCase;
/**
* @group legacy
*/
class InheritanceTest extends KeyValueStoreTestCase
{
private $manager;

View File

@@ -23,9 +23,6 @@ namespace Doctrine\Tests\KeyValueStore\Functional;
use Doctrine\KeyValueStore\Mapping\Annotations as KVS;
use Doctrine\Tests\KeyValueStoreTestCase;
/**
* @group legacy
*/
class PersistTest extends KeyValueStoreTestCase
{
/**

View File

@@ -23,9 +23,6 @@ namespace Doctrine\Tests\KeyValueStore\Functional;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\KeyValueStore\Storage\DoctrineCacheStorage;
/**
* @group legacy
*/
class SingleBasicCrudTest extends BasicCrudTestCase
{
private $cache;

View File

@@ -25,9 +25,6 @@ use Doctrine\KeyValueStore\Storage\AzureSdkTableStorage;
use Doctrine\Tests\KeyValueStoreTestCase;
use WindowsAzure\Common\ServicesBuilder;
/**
* @group legacy
*/
class AzureSdkTableTest extends KeyValueStoreTestCase
{
private $storage;

View File

@@ -24,7 +24,6 @@ use Cassandra;
use Doctrine\KeyValueStore\Storage\CassandraStorage;
/**
* @group legacy
* @requires extension cassandra
*/
class CassandraTest extends \PHPUnit_Framework_TestCase

View File

@@ -26,9 +26,6 @@ use Doctrine\KeyValueStore\Storage\WindowsAzureTable\SharedKeyLiteAuthorization;
use Doctrine\KeyValueStore\Storage\WindowsAzureTableStorage;
use Doctrine\Tests\KeyValueStoreTestCase;
/**
* @group legacy
*/
class WindowsAzureTableTest extends KeyValueStoreTestCase
{
private $storage;

View File

@@ -25,7 +25,6 @@ use ReflectionClass;
/**
* @coversDefaultClass \Doctrine\KeyValueStore\Mapping\ClassMetadata
* @group legacy
*/
class ClassMetadataTest extends \PHPUnit_Framework_TestCase
{

View File

@@ -20,9 +20,6 @@
namespace Doctrine\Tests\KeyValueStore\Storage;
/**
* @group legacy
*/
abstract class AbstractStorageTestCase extends \PHPUnit_Framework_TestCase
{
/**

View File

@@ -28,7 +28,6 @@ use Doctrine\KeyValueStore\Storage\CouchDbStorage;
* @author Emanuele Minotto <minottoemanuele@gmail.com>
*
* @covers \Doctrine\KeyValueStore\Storage\CouchDbStorage
* @group legacy
*/
class CouchDbStorageTest extends \PHPUnit_Framework_TestCase
{

View File

@@ -27,7 +27,6 @@ use Doctrine\KeyValueStore\Storage\CouchbaseStorage;
*
* @author Simon Schick <simonsimcity@gmail.com>
*
* @group legacy
* @requires extension couchbase
*/
class CouchbaseStorageTest extends \PHPUnit_Framework_TestCase

View File

@@ -20,38 +20,34 @@
namespace Doctrine\Tests\KeyValueStore\Storage;
use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Storage\MongoDbStorage;
use MongoDB\Client;
/**
* MongoDb storage testcase
*
* @author Markus Bachmann <markus.bachmann@bachi.biz>
*
* @group legacy
* @requires extension mongo
* @covers \Doctrine\KeyValueStore\Storage\MongoDbStorage
* @requires extension mongodb
*/
class MongoDbStorageTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Client
*/
private $client;
/**
* @var MongoDbStorage
*/
private $storage;
protected function setUp()
{
$this->mongo = $this->getMock('\Mongo');
$this->mongodb = $this->getMockBuilder('\MongoDB')->disableOriginalConstructor()->getMock();
$this->mongo->expects($this->any())
->method('selectDB')
->will($this->returnValue($this->mongodb));
$this->collection = $this->getMockBuilder('MongoCollection')->disableOriginalConstructor()->getMock();
$this->mongodb->expects($this->once())
->method('selectCollection')
->will($this->returnValue($this->collection));
$this->storage = new MongoDbStorage($this->mongo, [
'collection' => 'test',
'database' => 'test',
]);
$this->client = new Client();
$this->storage = new MongoDbStorage($this->client->test);
}
public function testInsert()
@@ -61,20 +57,21 @@ class MongoDbStorageTest extends \PHPUnit_Framework_TestCase
'title' => 'example book',
];
$dbDataset = [];
$this->storage->insert('mongodb', 'testInsert', $data);
$this->collection->expects($this->once())
->method('insert')
->will($this->returnCallback(function ($data) use (&$dbDataset) {
$dbDataset[] = $data;
}));
$result = $this->client
->test
->mongodb
->findOne([
'key' => 'testInsert',
]);
$this->storage->insert('mongodb', '1', $data);
$this->assertCount(1, $dbDataset);
$this->assertEquals([['key' => '1', 'value' => $data]], $dbDataset);
$this->assertSame($data, $result['value']->getArrayCopy());
}
/**
* @depends testInsert
*/
public function testUpdate()
{
$data = [
@@ -82,80 +79,67 @@ class MongoDbStorageTest extends \PHPUnit_Framework_TestCase
'title' => 'example book',
];
$dbDataset = [];
$this->storage->insert('mongodb', 'testUpdate', [
'foo' => 'bar',
]);
$this->storage->update('mongodb', 'testUpdate', $data);
$this->collection->expects($this->once())
->method('update')
->will($this->returnCallback(function ($citeria, $data) use (&$dbDataset) {
$dbDataset = [$citeria, $data];
}));
$result = $this->client
->test
->mongodb
->findOne([
'key' => 'testUpdate',
]);
$this->storage->update('mongodb', '1', $data);
$this->assertEquals(['key' => '1'], $dbDataset[0]);
$this->assertEquals(['key' => '1', 'value' => $data], $dbDataset[1]);
$this->assertSame($data, $result['value']->getArrayCopy());
}
/**
* @depends testInsert
*/
public function testDelete()
{
$dataset = [
[
'key' => 'foobar',
'value' => [
'author' => 'John Doe',
'title' => 'example book',
],
],
];
$this->storage->insert('mongodb', 'testDelete', [
'foo' => 'bar',
]);
$this->collection->expects($this->once())
->method('remove')
->will($this->returnCallback(function ($citeria) use (&$dataset) {
foreach ($dataset as $key => $row) {
if ($row['key'] === $citeria['key']) {
unset($dataset[$key]);
}
}
}
));
$this->storage->delete('mongodb', 'testDelete');
$this->storage->delete('test', 'foobar');
$result = $this->client
->test
->mongodb
->findOne([
'key' => 'testDelete',
]);
$this->assertCount(0, $dataset);
$this->assertNull($result);
}
/**
* @depends testInsert
*/
public function testFind()
{
$dataset = [
[
'key' => 'foobar',
'value' => [
'author' => 'John Doe',
'title' => 'example book',
],
],
'author' => 'John Doe',
'title' => 'example book',
];
$this->collection->expects($this->once())
->method('findOne')
->will($this->returnCallback(function ($citeria, $fields) use (&$dataset) {
foreach ($dataset as $key => $row) {
if ($row['key'] === $citeria['key']) {
return $row;
}
}
}
));
$this->storage->insert('mongodb', 'testFind', $dataset);
$data = $this->storage->find('test', 'foobar');
$data = $this->storage->find('mongodb', 'testFind');
$this->assertEquals($dataset[0]['value'], $data);
$this->assertEquals($dataset, $data);
}
public function testFindWithNotExistKey()
{
$this->setExpectedException(NotFoundException::class);
$this->storage->find('mongodb', 'not-existing-key');
}
public function testGetName()
{
$this->storage->initialize();
$this->assertEquals('mongodb', $this->storage->getName());
}
}

View File

@@ -25,7 +25,6 @@ use Doctrine\KeyValueStore\Storage\RedisStorage;
/**
* @author Marcel Araujo <admin@marcelaraujo.me>
*
* @group legacy
* @requires extension redis
*/
class RedisStorageTest extends \PHPUnit_Framework_TestCase

View File

@@ -20,32 +20,46 @@
namespace Doctrine\Tests\KeyValueStore\Storage;
use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Storage\RiakStorage;
use PHPUnit_Framework_TestCase;
use Riak\Client\Command\Kv\Builder\ListKeysBuilder;
use Riak\Client\Command\Kv\FetchValue;
use Riak\Client\Core\Query\RiakLocation;
use Riak\Client\Core\Query\RiakNamespace;
use Riak\Client\Core\Query\RiakObject;
use Riak\Client\Core\Transport\RiakTransportException;
use Riak\Client\RiakClient;
use Riak\Client\RiakClientBuilder;
/**
* @author Markus Bachmann <markus.bachmann@bachi.biz>
*
* @group legacy
*/
class RiakStorageTest extends \PHPUnit_Framework_TestCase
class RiakStorageTest extends PHPUnit_Framework_TestCase
{
/**
* @var RiakClient
*/
private $client;
/**
* @var RiakStorage
*/
private $storage;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $riak;
protected function setup()
protected function setUp()
{
$this->riak = $this->getMockBuilder('Riak\\Client')
->disableOriginalConstructor()
->getMock();
$dns = getenv('RIAK_DNS');
$this->storage = new RiakStorage($this->riak);
if (empty($dns)) {
$this->markTestSkipped('Missing Riak DNS');
}
$this->client = (new RiakClientBuilder())
->withNodeUri($dns)
->build();
$this->storage = new RiakStorage($this->client);
}
public function testSupportsPartialUpdates()
@@ -65,186 +79,124 @@ class RiakStorageTest extends \PHPUnit_Framework_TestCase
public function testInsert()
{
$bucket = $this->getMockBuilder('Riak\Bucket')
->disableOriginalConstructor()
->getMock();
$data = [
'title' => 'Riak test',
];
$this->riak->expects($this->once())
->method('bucket')
->will($this->returnValue($bucket));
$this->storage->insert('riak-test', 'foobar', $data);
$objectMock = $this->getMockBuilder('Riak\Object')
->disableOriginalConstructor()
->getMock();
$location = $this->getRiakLocation();
$objectMock->expects($this->once())
->method('store');
$fetch = FetchValue::builder($location)->build();
$that = $this;
$bucket->expects($this->once())
->method('newObject')
->will($this->returnCallback(function ($key, $data) use ($objectMock, $that) {
$that->assertEquals('foobar', $key);
$that->assertEquals(['title' => 'Riak test'], $data);
return $objectMock;
}));
$json = (string) $this->client
->execute($fetch)
->getValue()
->getValue();
$this->storage->insert('riak-test', 'foobar', ['title' => 'Riak test']);
}
public function testUpdate()
{
$objectMock = $this->getMockBuilder('Riak\Object')
->disableOriginalConstructor()
->getMock();
$bucket = $this->getMockBuilder('Riak\Bucket')
->disableOriginalConstructor()
->getMock();
$this->riak->expects($this->once())
->method('bucket')
->will($this->returnValue($bucket));
$bucket->expects($this->once())
->method('get')
->will($this->returnValue($objectMock));
$that = $this;
$objectMock->expects($this->once())
->method('setData')
->will($this->returnCallback(function ($data) use ($that) {
$that->assertEquals(['title' => 'Riak cookbook'], $data);
}));
$objectMock->expects($this->once())
->method('store');
$this->storage->update('riak-test', 'foobar', ['title' => 'Riak cookbook']);
}
public function testDelete()
{
$objectMock = $this->getMockBuilder('Riak\Object')
->disableOriginalConstructor()
->getMock();
$bucket = $this->getMockBuilder('Riak\Bucket')
->disableOriginalConstructor()
->getMock();
$this->riak->expects($this->once())
->method('bucket')
->will($this->returnValue($bucket));
$bucket->expects($this->once())
->method('get')
->with('foobar')
->will($this->returnValue($objectMock));
$objectMock->expects($this->once())
->method('exists')
->will($this->returnValue(true));
$objectMock->expects($this->once())
->method('delete');
$this->storage->delete('riak-test', 'foobar');
}
public function testDeleteWithNotExistKey()
{
$objectMock = $this->getMockBuilder('Riak\Object')
->disableOriginalConstructor()
->getMock();
$bucket = $this->getMockBuilder('Riak\Bucket')
->disableOriginalConstructor()
->getMock();
$this->riak->expects($this->once())
->method('bucket')
->will($this->returnValue($bucket));
$bucket->expects($this->once())
->method('get')
->with('foobar')
->will($this->returnValue($objectMock));
$objectMock->expects($this->once())
->method('exists')
->will($this->returnValue(false));
$objectMock->expects($this->never())
->method('delete');
$this->storage->delete('riak-test', 'foobar');
}
public function testFind()
{
$objectMock = $this->getMockBuilder('Riak\Object')
->disableOriginalConstructor()
->getMock();
$bucket = $this->getMockBuilder('Riak\Bucket')
->disableOriginalConstructor()
->getMock();
$this->riak->expects($this->once())
->method('bucket')
->will($this->returnValue($bucket));
$bucket->expects($this->once())
->method('get')
->with('foobar')
->will($this->returnValue($objectMock));
$objectMock->expects($this->once())
->method('exists')
->will($this->returnValue(true));
$objectMock->expects($this->once())
->method('getData')
->will($this->returnValue(['title' => 'Riak Test']));
$this->assertEquals(['title' => 'Riak Test'], $this->storage->find('riaktest', 'foobar'));
$this->assertSame($data, json_decode($json, true));
}
/**
* @expectedException Doctrine\KeyValueStore\NotFoundException
* @depends testInsert
*/
public function testUpdate()
{
$data = [
'title' => 'Riak update',
];
$this->storage->insert('riak-test', 'foobar', [
'title' => 'Riak insert',
]);
$location = $this->getRiakLocation();
$this->assertTotalBucketKeys(1, $location);
$this->storage->update('riak-test', 'foobar', $data);
$fetch = FetchValue::builder($location)->build();
$json = (string) $this->client
->execute($fetch)
->getValue()
->getValue();
$this->assertSame($data, json_decode($json, true));
$this->assertTotalBucketKeys(1, $location);
}
/**
* @depends testInsert
*/
public function testDelete()
{
$this->testInsert();
$this->storage->delete('riak-test', 'foobar');
$location = $this->getRiakLocation();
$fetch = FetchValue::builder($location)->build();
$this->setExpectedException(RiakTransportException::class);
$this->client->execute($fetch);
$this->assertTotalBucketKeys(0, $location);
}
/**
* @depends testDelete
*/
public function testDeleteWithNotExistKey()
{
$this->storage->delete('riak-test', 'foobar');
$this->storage->delete('riak-test', 'foobar');
}
/**
* @depends testInsert
*/
public function testFind()
{
$data = [
'title' => 'Riak test',
];
$this->storage->insert('riak-test', 'foobar', $data);
$result = $this->storage->find('riak-test', 'foobar');
$this->assertSame($data, $result);
}
public function testFindWithNotExistKey()
{
$objectMock = $this->getMockBuilder('Riak\Object')
->disableOriginalConstructor()
->getMock();
$bucket = $this->getMockBuilder('Riak\Bucket')
->disableOriginalConstructor()
->getMock();
$this->riak->expects($this->once())
->method('bucket')
->will($this->returnValue($bucket));
$bucket->expects($this->once())
->method('get')
->with('foobar')
->will($this->returnValue($objectMock));
$objectMock->expects($this->once())
->method('exists')
->will($this->returnValue(false));
$objectMock->expects($this->never())
->method('getData');
$this->storage->find('riak-test', 'foobar');
$this->setExpectedException(NotFoundException::class);
$this->storage->find('riak-test', 'foobar-1');
}
public function testGetName()
{
$this->assertEquals('riak', $this->storage->getName());
}
private function assertTotalBucketKeys($expectedTotal, $location)
{
$command = (new ListKeysBuilder($location->getNamespace()))->build();
$iterator = $this->client
->execute($command)
->getIterator();
$this->assertCount($expectedTotal, iterator_to_array($iterator));
}
private function getRiakLocation()
{
$namespace = new RiakNamespace('default', 'riak-test');
return new RiakLocation($namespace, 'foobar');
}
}

View File

@@ -22,9 +22,6 @@ namespace Doctrine\Tests\KeyValueStore\Storage\WindowsAzureTable;
use Doctrine\KeyValueStore\Storage\WindowsAzureTable\SharedKeyLiteAuthorization;
/**
* @group legacy
*/
class SharedKeyLiteTest extends \PHPUnit_Framework_TestCase
{
private $auth;

View File

@@ -20,20 +20,25 @@
namespace Doctrine\Tests\KeyValueStore\Storage;
use Doctrine\KeyValueStore\Http\Client;
use Doctrine\KeyValueStore\Http\Response;
use Doctrine\KeyValueStore\Storage\WindowsAzureTable\AuthorizationSchema;
use Doctrine\KeyValueStore\Storage\WindowsAzureTableStorage;
/**
* @group legacy
*/
class WindowsAzureTableStorageTest extends AbstractStorageTestCase
{
private $client;
protected function createStorage()
{
$this->client = $this->getMock('Doctrine\KeyValueStore\Http\Client');
$auth = $this->getMock('Doctrine\KeyValueStore\Storage\WindowsAzureTable\AuthorizationSchema');
$this->client = $this
->getMockBuilder(Client::class)
->disableOriginalConstructor()
->getMock();
$auth = $this
->getMockBuilder(AuthorizationSchema::class)
->disableOriginalConstructor()
->getMock();
$auth->expects($this->any())->method('signRequest')->will($this->returnValue('Authorization: SharedKeyLite testaccount1:uay+rilMVayH/SVI8X+a3fL8k/NxCnIePdyZSkqvydM='));
$storage = new WindowsAzureTableStorage(

View File

@@ -26,9 +26,6 @@ use Doctrine\KeyValueStore\EntityManager;
use Doctrine\KeyValueStore\Mapping;
use Doctrine\KeyValueStore\Storage\DoctrineCacheStorage;
/**
* @group legacy
*/
abstract class KeyValueStoreTestCase extends \PHPUnit_Framework_TestCase
{
public function createManager($storage = null, $driver = 'annotation')

View File

@@ -7,7 +7,5 @@ sudo apt-get install -y libuv-dev libssl-dev
cd /tmp && git clone https://github.com/datastax/php-driver.git && cd php-driver && git submodule update --init
cd ext && ./install.sh && cd "$TRAVIS_BUILD_DIR"
echo "extension=cassandra.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
# PHP extensions
yes | pecl install mongo
# PECL extensions
echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini