9 Commits

Author SHA1 Message Date
Emanuele Minotto
a2b752033f CS fix 2016-07-09 11:45:35 +02:00
Emanuele Minotto
eaa95e0e96 Fixed identifiers values extraction 2016-07-09 11:45:34 +02:00
Emanuele Minotto
90d29ad6c7 Allow object as constructor argument 2016-07-09 11:45:34 +02:00
Emanuele Minotto
66864cbbee missing initializations and arrays 2016-07-09 11:45:34 +02:00
Emanuele Minotto
02cb83edd1 small refactoring 2016-07-09 11:45:34 +02:00
Emanuele Minotto
8f17913f4b namespaces 2016-07-09 11:45:34 +02:00
Emanuele Minotto
cf6bd490f4 fixed phpdocs 2016-07-09 11:45:34 +02:00
Emanuele Minotto
18e9faf50d added new tests 2016-07-09 11:45:34 +02:00
Emanuele Minotto
aeb6db5d98 added old tests to the legacy group 2016-07-07 00:16:01 +02:00
67 changed files with 3748 additions and 186 deletions

View File

@@ -4,10 +4,6 @@ services:
- mongodb
- redis-server
cache:
directories:
- $HOME/.composer/cache
php:
- 5.5
- 5.6
@@ -19,17 +15,7 @@ before_install:
- composer self-update
install:
- composer require satooshi/php-coveralls:~0.6@stable --no-update
- composer install --prefer-dist --no-interaction --no-progress
before_script:
- vendor/bin/php-cs-fixer -v fix --diff --dry-run
- composer --prefer-source install
script:
- vendor/bin/phpunit --verbose --coverage-text --coverage-clover=coverage.clover
after_script:
- if [[ $TRAVIS_PHP_VERSION != "5.6" && $TRAVIS_PULL_REQUEST == "false" ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fi
notifications:
email: false
- vendor/bin/phpunit --verbose

View File

@@ -9,8 +9,7 @@
"doctrine/couchdb": "^1.0.0-beta4",
"phpunit/phpunit": "^4.8|^5.0",
"aws/aws-sdk-php": "^3.8",
"riak/riak-client": "dev-master",
"friendsofphp/php-cs-fixer": "^1.11"
"riak/riak-client": "dev-master"
},
"suggest": {
"aws/aws-sdk-php": "to use the DynamoDB storage",
@@ -27,7 +26,8 @@
},
"autoload-dev": {
"psr-4": {
"Doctrine\\Tests\\": "tests/Doctrine/Tests"
"Doctrine\\Tests\\": "tests/Doctrine/Tests",
"Doctrine\\KeyValueStore\\": "tests/Doctrine/KeyValueStore"
}
}
}

View File

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

View File

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

View File

@@ -21,35 +21,50 @@
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)) {
$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];
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[$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,6 +31,23 @@ 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,11 +22,17 @@ 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,6 +24,9 @@ use Doctrine\KeyValueStore\Mapping\ClassMetadata;
class SingleIdHandler implements IdHandlingStrategy
{
/**
* {@inheritDoc}
*/
public function normalizeId(ClassMetadata $metadata, $key)
{
if (is_scalar($key)) {
@@ -34,12 +37,18 @@ 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,8 +21,12 @@
namespace Doctrine\KeyValueStore\Mapping;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as CommonClassMetadata;
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
{
@@ -46,19 +50,19 @@ class AnnotationDriver implements MappingDriver
/**
* Loads the metadata for the specified class into the provided container.
*
* @param string $className
* @param ClassMetadata $metadata
* @param string $className
* @param CommonClassMetadata $metadata
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
public function loadMetadataForClass($className, CommonClassMetadata $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, 'Doctrine\KeyValueStore\Mapping\Annotations\Entity');
$entityAnnot = $this->reader->getClassAnnotation($class, Entity::class);
if (! $entityAnnot) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
@@ -66,21 +70,26 @@ class AnnotationDriver implements MappingDriver
// Evaluate annotations on properties/fields
foreach ($class->getProperties() as $property) {
$idAnnot = $this->reader->getPropertyAnnotation(
$property,
'Doctrine\KeyValueStore\Mapping\Annotations\Id'
);
$transientAnnot = $this->reader->getPropertyAnnotation(
$property,
'Doctrine\KeyValueStore\Mapping\Annotations\Transient'
);
$idAnnot = $this->reader->getPropertyAnnotation($property, Id::class);
if ($idAnnot) {
$metadata->mapIdentifier($property->getName());
} elseif ($transientAnnot) {
$metadata->skipTransientField($property->getName());
} else {
$metadata->mapField(['fieldName' => $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) {
$metadata->skipTransientField($property->getName());
// if it's a transiend, can't be also a mapped field
continue;
}
$metadata->mapField([
'fieldName' => $property->getName(),
]);
}
}
@@ -91,6 +100,7 @@ class AnnotationDriver implements MappingDriver
*/
public function getAllClassNames()
{
return [];
}
/**

View File

@@ -25,37 +25,91 @@ use ReflectionClass;
class ClassMetadata implements BaseClassMetadata
{
/**
* @var string
*/
public $name;
public $storageName;
public $rootClassName;
public $fields = [];
public $identifier = [];
public $isCompositeKey = false;
public $transientFields = [];
public $reflFields = [];
public $reflClass;
/**
* @var string
*/
public $storageName;
/**
* @var array
*/
public $fields = [];
/**
* @var array
*/
public $identifier = [];
/**
* @var bool
*/
public $isCompositeKey = false;
/**
* @var array
*/
public $transientFields = [];
/**
* @var array
*/
public $reflFields = [];
/**
* @var null|mixed
*/
private $prototype;
public function __construct($className)
/**
* @param string|object $class
*/
public function __construct($class)
{
$this->name = $className;
if (is_object($class)) {
$reflectionClass = new ReflectionClass($class);
$class = $reflectionClass->getName();
}
$this->name = $class;
}
/**
* 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,
]);
}
public function mapField($mapping)
/**
* Add a mapped field.
*
* @param array $mapping
*/
public function mapField(array $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
@@ -78,21 +132,29 @@ 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)
{
$id = [];
foreach ($this->identifier as $field) {
$value = $this->reflFields[$field]->getValue($object);
if ($value !== null) {
$id[$field] = $value;
}
}
return $id;
$instance = $object ?: $this->newInstance();
return array_intersect_key(
get_object_vars($instance),
array_flip($this->identifier)
);
}
/**

View File

@@ -21,10 +21,9 @@
namespace Doctrine\KeyValueStore\Mapping;
use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as CommonClassMetadata;
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.
@@ -33,17 +32,29 @@ use Doctrine\KeyValueStore\Mapping\ClassMetadata as KeyValueMetadata;
*/
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.');
@@ -68,17 +79,26 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
}
/**
* {@inheritDoc}
*/
protected function newClassMetadataInstance($className)
{
return new KeyValueMetadata($className);
return new ClassMetadata($className);
}
/**
* {@inheritDoc}
*/
protected function getDriver()
{
return $this->mappingDriver;
}
protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService)
/**
* {@inheritDoc}
*/
protected function wakeupReflection(CommonClassMetadata $class, ReflectionService $reflService)
{
$class->reflClass = $reflService->getClass($class->name);
foreach ($class->fields as $fieldName => $mapping) {
@@ -86,20 +106,28 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
}
protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
/**
* {@inheritDoc}
*/
protected function initializeReflection(CommonClassMetadata $class, ReflectionService $reflService)
{
$class->reflClass = $reflService->getClass($class->name);
if ($class->reflClass) {
foreach ($class->reflClass->getProperties() as $property) {
$class->mapField(['fieldName' => $property->getName()]);
}
if (! $class->reflClass) {
return;
}
foreach ($class->reflClass->getProperties() as $property) {
$class->mapField([
'fieldName' => $property->getName(),
]);
}
}
/**
* copied from doctrine/common - tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php
* {@inheritDoc}
*/
protected function isEntity(ClassMetadata $class)
protected function isEntity(CommonClassMetadata $class)
{
return true;
}

View File

@@ -23,6 +23,8 @@ 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
{
@@ -70,14 +72,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,6 +73,11 @@ class RangeQuery
*/
protected $em;
/**
* @param EntityManager $em
* @param string $className
* @param string $partitionKey
*/
public function __construct(EntityManager $em, $className, $partitionKey)
{
$this->em = $em;
@@ -80,21 +85,33 @@ 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 className.
* Get class name.
*
* @return className.
* @return string
*/
public function getClassName()
{
@@ -102,9 +119,9 @@ class RangeQuery
}
/**
* Get partitionKey.
* Get partition key.
*
* @return partitionKey.
* @return string
*/
public function getPartitionKey()
{

View File

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

View File

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

View File

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

View File

@@ -33,33 +33,55 @@ use Doctrine\Common\Cache\Cache;
class DoctrineCacheStorage implements Storage
{
/**
* @var Doctrine\Common\Cache\Cache
* @var 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) {
@@ -74,30 +96,45 @@ 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,9 +290,7 @@ class DynamoDbStorage implements Storage
}
/**
* Return a name of the underlying storage.
*
* @return string
* {@inheritDoc}
*/
public function getName()
{

View File

@@ -21,6 +21,8 @@
namespace Doctrine\KeyValueStore\Storage;
use Doctrine\KeyValueStore\NotFoundException;
use Mongo;
use RuntimeException;
/**
* MongoDb storage
@@ -30,7 +32,7 @@ use Doctrine\KeyValueStore\NotFoundException;
class MongoDbStorage implements Storage
{
/**
* @var \Mongo
* @var Mongo
*/
protected $mongo;
@@ -47,10 +49,10 @@ class MongoDbStorage implements Storage
/**
* Constructor
*
* @param \Mongo $mongo
* @param array $dbOptions
* @param Mongo $mongo
* @param array $dbOptions
*/
public function __construct(\Mongo $mongo, array $dbOptions = [])
public function __construct(Mongo $mongo, array $dbOptions = [])
{
$this->mongo = $mongo;
$this->dbOptions = array_merge([
@@ -62,7 +64,7 @@ class MongoDbStorage implements Storage
/**
* Initialize the mongodb collection
*
* @throws \RuntimeException
* @throws RuntimeException
*/
public function initialize()
{
@@ -71,10 +73,10 @@ class MongoDbStorage implements Storage
}
if (empty($this->dbOptions['database'])) {
throw new \RuntimeException('The option "database" must be set');
throw new RuntimeException('The option "database" must be set');
}
if (empty($this->dbOptions['collection'])) {
throw new \RuntimeException('The option "collection" must be set');
throw new RuntimeException('The option "collection" must be set');
}
$this->collection = $this
@@ -164,9 +166,7 @@ class MongoDbStorage implements Storage
}
/**
* Return a name of the underlying storage.
*
* @return string
* {@inheritDoc}
*/
public function getName()
{

View File

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

View File

@@ -29,15 +29,12 @@ use Riak\Client;
class RiakStorage implements Storage
{
/**
* @var \Riak\Client
* @var Client
*/
protected $client;
/**
* Constructor
*
* @param \Riak\Client $riak
* @param string $bucketName
* @param Client $riak
*/
public function __construct(Client $riak)
{

View File

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

View File

@@ -183,7 +183,7 @@ class WindowsAzureTableStorage implements Storage, RangeQueryStorage
$tableNode->appendChild($dom->createTextNode($tableName));
$xml = $dom->saveXML();
$url = $this->baseUrl . '/Tables';
$url = $this->baseUrl . '/Tables';
$response = $this->request('POST', $url, $xml, $headers);
if ($response->getStatusCode() != 201) {

View File

@@ -36,10 +36,12 @@ class UnitOfWork
* @var ClassMetadataFactory
*/
private $cmf;
/**
* @var Storage
*/
private $storageDriver;
/**
* @var IdHandlingStrategy
*/
@@ -53,14 +55,38 @@ class UnitOfWork
*
* @var array
*/
private $identifiers;
private $identifiers = [];
private $originalData;
/**
* @var array
*/
private $originalData = [];
/**
* @var array
*/
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;
@@ -71,11 +97,22 @@ 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);
@@ -85,6 +122,14 @@ class UnitOfWork
return;
}
/**
* @param string $className
* @param string|array $key
*
* @throws NotFoundException
*
* @return mixed
*/
public function reconstititute($className, $key)
{
$class = $this->cmf->getMetadataFor($className);
@@ -284,6 +329,9 @@ 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/Tests/KeyValueStore</directory>
<directory suffix="Test.php">tests/Doctrine</directory>
</testsuite>
</testsuites>

View File

@@ -0,0 +1,123 @@
<?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

@@ -0,0 +1,175 @@
<?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

@@ -0,0 +1,148 @@
<?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

@@ -0,0 +1,69 @@
<?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

@@ -0,0 +1,109 @@
<?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

@@ -0,0 +1,115 @@
<?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

@@ -0,0 +1,320 @@
<?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

@@ -0,0 +1,54 @@
<?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

@@ -0,0 +1,54 @@
<?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

@@ -0,0 +1,260 @@
<?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

@@ -0,0 +1,151 @@
<?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

@@ -0,0 +1,129 @@
<?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

@@ -0,0 +1,140 @@
<?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

@@ -0,0 +1,129 @@
<?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

@@ -0,0 +1,129 @@
<?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

@@ -0,0 +1,129 @@
<?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

@@ -0,0 +1,134 @@
<?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

@@ -0,0 +1,140 @@
<?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

@@ -0,0 +1,140 @@
<?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

@@ -0,0 +1,318 @@
<?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

@@ -0,0 +1,134 @@
<?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

@@ -0,0 +1,148 @@
<?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,6 +22,9 @@ namespace Doctrine\Tests\KeyValueStore;
use Doctrine\KeyValueStore\Configuration;
/**
* @group legacy
*/
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
public function testNoMappingDriver()

View File

@@ -23,6 +23,9 @@ 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,6 +23,9 @@ 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,6 +25,9 @@ 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,6 +23,9 @@ 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,6 +23,9 @@ 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,6 +25,9 @@ use Doctrine\KeyValueStore\Storage\AzureSdkTableStorage;
use Doctrine\Tests\KeyValueStoreTestCase;
use WindowsAzure\Common\ServicesBuilder;
/**
* @group legacy
*/
class AzureSdkTableTest extends KeyValueStoreTestCase
{
private $storage;

View File

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

View File

@@ -26,6 +26,9 @@ 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,6 +25,7 @@ use ReflectionClass;
/**
* @coversDefaultClass \Doctrine\KeyValueStore\Mapping\ClassMetadata
* @group legacy
*/
class ClassMetadataTest extends \PHPUnit_Framework_TestCase
{

View File

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

View File

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

View File

@@ -27,6 +27,7 @@ use Doctrine\KeyValueStore\Storage\MongoDbStorage;
*
* @author Markus Bachmann <markus.bachmann@bachi.biz>
*
* @group legacy
* @requires extension mongo
*/
class MongoDbStorageTest extends \PHPUnit_Framework_TestCase

View File

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

View File

@@ -24,6 +24,8 @@ use Doctrine\KeyValueStore\Storage\RiakStorage;
/**
* @author Markus Bachmann <markus.bachmann@bachi.biz>
*
* @group legacy
*/
class RiakStorageTest extends \PHPUnit_Framework_TestCase
{

View File

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

View File

@@ -23,6 +23,9 @@ namespace Doctrine\Tests\KeyValueStore\Storage;
use Doctrine\KeyValueStore\Http\Response;
use Doctrine\KeyValueStore\Storage\WindowsAzureTableStorage;
/**
* @group legacy
*/
class WindowsAzureTableStorageTest extends AbstractStorageTestCase
{
private $client;

View File

@@ -26,6 +26,9 @@ 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')