From b1d0bfe3674257aaac276b1bcb12e94e711aba78 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 30 Jun 2016 12:28:24 +0200 Subject: [PATCH] TASK: Clean up docblocks, type hints, tests --- .../Command/IndexCommandController.php | 8 ++++- .../Command/MappingCommandController.php | 5 +-- .../DocumentPropertiesMismatchException.php | 9 +++-- .../Domain/Factory/ClientFactory.php | 6 ++-- .../Domain/Model/AbstractType.php | 8 ++--- .../ElasticSearch/Domain/Model/Client.php | 3 +- .../Model/Client/ClientConfiguration.php | 3 ++ .../ElasticSearch/Domain/Model/Document.php | 18 +++++----- .../Domain/Model/GenericType.php | 2 +- .../ElasticSearch/Domain/Model/Index.php | 13 ++++--- .../ElasticSearch/Domain/Model/Mapping.php | 19 +++++++---- .../Indexer/Object/IndexInformer.php | 7 ++-- .../Indexer/Object/ObjectIndexer.php | 34 +++++++++---------- .../Object/Transform/DateTransformer.php | 1 - .../Object/Transform/TransformerFactory.php | 3 +- .../Mapping/BackendMappingBuilder.php | 9 ++--- .../Mapping/EntityMappingBuilder.php | 11 +++--- .../Mapping/MappingCollection.php | 15 ++++---- Classes/Flowpack/ElasticSearch/Package.php | 20 ++++++----- .../ElasticSearch/Transfer/Exception.php | 6 ++++ .../ElasticSearch/Transfer/RequestService.php | 4 +-- .../ElasticSearch/Transfer/Response.php | 1 - LICENSE | 21 ++++++++++++ Tests/Functional/Domain/AbstractTest.php | 6 ++-- Tests/Functional/Domain/DocumentTest.php | 7 ++-- Tests/Functional/Fixtures/Tweet.php | 2 +- .../Indexer/Object/IndexInformerTest.php | 16 +++++---- .../Indexer/Object/ObjectIndexerTest.php | 21 +++++++----- .../Functional/Mapping/MappingBuilderTest.php | 9 +++-- composer.json | 1 + 30 files changed, 175 insertions(+), 113 deletions(-) create mode 100644 LICENSE diff --git a/Classes/Flowpack/ElasticSearch/Command/IndexCommandController.php b/Classes/Flowpack/ElasticSearch/Command/IndexCommandController.php index b250ef4..a8708d8 100644 --- a/Classes/Flowpack/ElasticSearch/Command/IndexCommandController.php +++ b/Classes/Flowpack/ElasticSearch/Command/IndexCommandController.php @@ -56,6 +56,7 @@ class IndexCommandController extends \TYPO3\Flow\Cli\CommandController * * @param string $indexName The name of the new index * @param string $clientName The client name to use + * @return void */ public function createCommand($indexName, $clientName = null) { @@ -84,6 +85,7 @@ public function createCommand($indexName, $clientName = null) * * @param string $indexName The name of the new index * @param string $clientName The client name to use + * @return void */ public function updateSettingsCommand($indexName, $clientName = null) { @@ -112,6 +114,7 @@ public function updateSettingsCommand($indexName, $clientName = null) * * @param string $indexName The name of the index to be removed * @param string $clientName The client name to use + * @return void */ public function deleteCommand($indexName, $clientName = null) { @@ -140,6 +143,7 @@ public function deleteCommand($indexName, $clientName = null) * * @param string $indexName The name of the index to be removed * @param string $clientName The client name to use + * @return void */ public function refreshCommand($indexName, $clientName = null) { @@ -164,6 +168,8 @@ public function refreshCommand($indexName, $clientName = null) /** * List available document type + * + * @return void */ public function showConfiguredTypesCommand() { @@ -181,6 +187,7 @@ public function showConfiguredTypesCommand() * @param string $object Class name of a domain object. If given, will only work on this single object * @param boolean $conductUpdate Set to TRUE to conduct the required corrections * @param string $clientName The client name to use + * @return void */ public function statusCommand($object = null, $conductUpdate = false, $clientName = null) { @@ -258,7 +265,6 @@ public function statusCommand($object = null, $conductUpdate = false, $clientNam /** * @param Client $client * @param string $className - * * @return array */ protected function getModificationsNeededStatesAndIdentifiers(Client $client, $className) diff --git a/Classes/Flowpack/ElasticSearch/Command/MappingCommandController.php b/Classes/Flowpack/ElasticSearch/Command/MappingCommandController.php index 69f056b..2a9d48b 100644 --- a/Classes/Flowpack/ElasticSearch/Command/MappingCommandController.php +++ b/Classes/Flowpack/ElasticSearch/Command/MappingCommandController.php @@ -11,6 +11,7 @@ * source code. */ +use Flowpack\ElasticSearch\Mapping\MappingCollection; use TYPO3\Flow\Annotations as Flow; /** @@ -178,11 +179,11 @@ protected function markupDiffValue($entityValue, $backendValue) /** * Traverses through mappingInformation array and aggregates by index and type names * - * @param \Flowpack\ElasticSearch\Mapping\MappingCollection $mappingCollection + * @param MappingCollection $mappingCollection * @throws \Flowpack\ElasticSearch\Exception * @return array with index names as keys, second level type names as keys */ - protected function buildArrayFromMappingCollection(\Flowpack\ElasticSearch\Mapping\MappingCollection $mappingCollection) + protected function buildArrayFromMappingCollection(MappingCollection $mappingCollection) { $return = array(); diff --git a/Classes/Flowpack/ElasticSearch/Domain/Exception/DocumentPropertiesMismatchException.php b/Classes/Flowpack/ElasticSearch/Domain/Exception/DocumentPropertiesMismatchException.php index fe75142..9bb57bd 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Exception/DocumentPropertiesMismatchException.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Exception/DocumentPropertiesMismatchException.php @@ -11,20 +11,23 @@ * source code. */ +use TYPO3\Flow\Error\Result; + /** * Signals a mismatch between the */ class DocumentPropertiesMismatchException extends \Flowpack\ElasticSearch\Exception { /** - * @var \TYPO3\Flow\Error\Result + * @var Result */ protected $errorResult; /** - * @param \TYPO3\Flow\Error\Result $result + * @param Result $result + * @return void */ - public function setErrorResult(\TYPO3\Flow\Error\Result $result) + public function setErrorResult(Result $result) { $this->errorResult = $result; } diff --git a/Classes/Flowpack/ElasticSearch/Domain/Factory/ClientFactory.php b/Classes/Flowpack/ElasticSearch/Domain/Factory/ClientFactory.php index 3cad8c0..3396229 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Factory/ClientFactory.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Factory/ClientFactory.php @@ -37,6 +37,7 @@ public function injectSettings(array $settings) * @param string $clientClassName * @throws \Flowpack\ElasticSearch\Exception * @return \Flowpack\ElasticSearch\Domain\Model\Client + * @return void */ public function create($bundle = null, $clientClassName = 'Flowpack\ElasticSearch\Domain\Model\Client') { @@ -59,12 +60,11 @@ public function create($bundle = null, $clientClassName = 'Flowpack\ElasticSearc } /** - * @param $clientsSettings - * + * @param array $clientsSettings * @return array * @throws \Flowpack\ElasticSearch\Exception */ - protected function buildClientConfigurations($clientsSettings) + protected function buildClientConfigurations(array $clientsSettings) { $clientConfigurations = array(); foreach ($clientsSettings as $clientSettings) { diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/AbstractType.php b/Classes/Flowpack/ElasticSearch/Domain/Model/AbstractType.php index 816a8e3..47b87aa 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/AbstractType.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/AbstractType.php @@ -70,8 +70,7 @@ public function getIndex() /** * Returns a document * - * @param $id - * + * @param string $id * @return \Flowpack\ElasticSearch\Domain\Model\Document */ public function findDocumentById($id) @@ -86,7 +85,7 @@ public function findDocumentById($id) } /** - * @param $id + * @param string $id * @return boolean ...whether the deletion is considered successful */ public function deleteDocumentById($id) @@ -125,10 +124,9 @@ public function search(array $searchQuery) * @param string $path * @param array $arguments * @param string $content - * * @return \Flowpack\ElasticSearch\Transfer\Response */ - public function request($method, $path = null, $arguments = array(), $content = null) + public function request($method, $path = null, array $arguments = array(), $content = null) { $path = '/' . $this->name . ($path ?: ''); diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/Client.php b/Classes/Flowpack/ElasticSearch/Domain/Model/Client.php index 3e9d422..58057e5 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/Client.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/Client.php @@ -91,10 +91,9 @@ public function findIndex($indexName) * @param string $path * @param array $arguments * @param string|array $content - * * @return \Flowpack\ElasticSearch\Transfer\Response */ - public function request($method, $path = null, $arguments = array(), $content = null) + public function request($method, $path = null, array $arguments = array(), $content = null) { return $this->requestService->request($method, $this, $path, $arguments, $content); } diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/Client/ClientConfiguration.php b/Classes/Flowpack/ElasticSearch/Domain/Model/Client/ClientConfiguration.php index 82e10b1..fe6589c 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/Client/ClientConfiguration.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/Client/ClientConfiguration.php @@ -45,6 +45,7 @@ class ClientConfiguration /** * @param string $host + * @return void */ public function setHost($host) { @@ -61,6 +62,7 @@ public function getHost() /** * @param int $port + * @return void */ public function setPort($port) { @@ -77,6 +79,7 @@ public function getPort() /** * @param string $scheme + * @return void */ public function setScheme($scheme) { diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/Document.php b/Classes/Flowpack/ElasticSearch/Domain/Model/Document.php index 7bbd742..3d6daaa 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/Document.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/Document.php @@ -19,7 +19,7 @@ class Document { /** - * @var \Flowpack\ElasticSearch\Domain\Model\AbstractType + * @var AbstractType */ protected $type; @@ -52,10 +52,10 @@ class Document protected $dirty = true; /** - * @param \Flowpack\ElasticSearch\Domain\Model\AbstractType $type + * @param AbstractType $type * @param array $data * @param string $id - * @param null $version + * @param integer $version */ public function __construct(AbstractType $type, array $data = null, $id = null, $version = null) { @@ -68,6 +68,8 @@ public function __construct(AbstractType $type, array $data = null, $id = null, /** * When cloning (locally), the cloned object doesn't represent a stored one anymore, * so reset id, version and the dirty state. + * + * @return void */ public function __clone() { @@ -81,10 +83,9 @@ public function __clone() * @param string $path * @param array $arguments * @param string $content - * * @return \Flowpack\ElasticSearch\Transfer\Response */ - protected function request($method, $path = null, $arguments = array(), $content = null) + protected function request($method, $path = null, array $arguments = array(), $content = null) { return $this->type->request($method, $path, $arguments, $content); } @@ -114,6 +115,7 @@ public function store() /** * @param boolean $dirty + * @return void */ protected function setDirty($dirty = true) { @@ -148,8 +150,9 @@ public function getData() /** * @param array $data + * @return void */ - public function setData($data) + public function setData(array $data) { $this->data = $data; $this->setDirty(); @@ -168,7 +171,6 @@ public function getId() * * @param string $fieldName * @param boolean $silent - * * @throws \Flowpack\ElasticSearch\Exception * @return mixed */ @@ -182,7 +184,7 @@ public function getField($fieldName, $silent = false) } /** - * @return \Flowpack\ElasticSearch\Domain\Model\AbstractType the type of this Document + * @return AbstractType the type of this Document */ public function getType() { diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/GenericType.php b/Classes/Flowpack/ElasticSearch/Domain/Model/GenericType.php index 2457e22..a8814ef 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/GenericType.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/GenericType.php @@ -19,7 +19,7 @@ class GenericType extends AbstractType { /** - * @param \Flowpack\ElasticSearch\Domain\Model\Index $index + * @param Index $index * @param string $name */ public function __construct(Index $index, $name) diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/Index.php b/Classes/Flowpack/ElasticSearch/Domain/Model/Index.php index 9231e29..b5a1147 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/Index.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/Index.php @@ -96,7 +96,6 @@ public function injectSettings(array $settings) /** * @param $name * @param Client $client $client - * * @throws \Flowpack\ElasticSearch\Exception */ public function __construct($name, Client $client = null) @@ -113,7 +112,7 @@ public function __construct($name, Client $client = null) } /** - * @param $typeName + * @param string $typeName * @return \Flowpack\ElasticSearch\Domain\Model\AbstractType */ public function findType($typeName) @@ -123,7 +122,6 @@ public function findType($typeName) /** * @param array $types - * * @return TypeGroup */ public function findTypeGroup(array $types) @@ -189,11 +187,10 @@ public function refresh() * @param array $arguments * @param string $content * @param boolean $prefixIndex - * - * @throws \Flowpack\ElasticSearch\Exception * @return \Flowpack\ElasticSearch\Transfer\Response + * @throws \Flowpack\ElasticSearch\Exception */ - public function request($method, $path = null, $arguments = array(), $content = null, $prefixIndex = true) + public function request($method, $path = null, array $arguments = array(), $content = null, $prefixIndex = true) { if ($this->client === null) { throw new Exception('The client of the index "' . $this->name . '" is not set, hence no requests can be done.'); @@ -218,6 +215,7 @@ public function getName() /** * @param Client $client + * @return void */ public function setClient($client) { @@ -225,7 +223,8 @@ public function setClient($client) } /** - * @param $settingsKey + * @param string $settingsKey + * @return void */ public function setSettingsKey($settingsKey) { diff --git a/Classes/Flowpack/ElasticSearch/Domain/Model/Mapping.php b/Classes/Flowpack/ElasticSearch/Domain/Model/Mapping.php index df03a2c..7e9cacd 100644 --- a/Classes/Flowpack/ElasticSearch/Domain/Model/Mapping.php +++ b/Classes/Flowpack/ElasticSearch/Domain/Model/Mapping.php @@ -20,7 +20,7 @@ class Mapping { /** - * @var \Flowpack\ElasticSearch\Domain\Model\AbstractType + * @var AbstractType */ protected $type; @@ -45,7 +45,7 @@ class Mapping protected $fullMapping = array(); /** - * @param \Flowpack\ElasticSearch\Domain\Model\AbstractType $type + * @param AbstractType $type */ public function __construct(AbstractType $type) { @@ -60,7 +60,7 @@ public function __construct(AbstractType $type) */ public function getPropertyByPath($path) { - return \TYPO3\Flow\Utility\Arrays::getValueByPath($this->properties, $path); + return Arrays::getValueByPath($this->properties, $path); } /** @@ -72,7 +72,7 @@ public function getPropertyByPath($path) */ public function setPropertyByPath($path, $value) { - $this->properties = \TYPO3\Flow\Utility\Arrays::setValueByPath($this->properties, $path, $value); + $this->properties = Arrays::setValueByPath($this->properties, $path, $value); } /** @@ -84,7 +84,7 @@ public function getProperties() } /** - * @return \Flowpack\ElasticSearch\Domain\Model\AbstractType + * @return AbstractType */ public function getType() { @@ -106,6 +106,8 @@ public function asArray() /** * Sets this mapping to the server + * + * @return \Flowpack\ElasticSearch\Transfer\Response */ public function apply() { @@ -126,8 +128,9 @@ public function getDynamicTemplates() /** * Dynamic templates allow to define mapping templates * - * @param $dynamicTemplateName + * @param string $dynamicTemplateName * @param array $mappingConfiguration + * @return void */ public function addDynamicTemplate($dynamicTemplateName, array $mappingConfiguration) { @@ -142,6 +145,7 @@ public function addDynamicTemplate($dynamicTemplateName, array $mappingConfigura * It can be used to specify arbitrary ElasticSearch mapping options, like f.e. configuring the _all field. * * @param array $fullMapping + * @return void */ public function setFullMapping(array $fullMapping) { @@ -149,7 +153,8 @@ public function setFullMapping(array $fullMapping) } /** - * see {@link setFullMapping} for documentation + * See {@link setFullMapping} for documentation + * * @return array */ public function getFullMapping() diff --git a/Classes/Flowpack/ElasticSearch/Indexer/Object/IndexInformer.php b/Classes/Flowpack/ElasticSearch/Indexer/Object/IndexInformer.php index 10a1c3e..52b7908 100644 --- a/Classes/Flowpack/ElasticSearch/Indexer/Object/IndexInformer.php +++ b/Classes/Flowpack/ElasticSearch/Indexer/Object/IndexInformer.php @@ -40,6 +40,7 @@ class IndexInformer protected $indexAnnotations = array(); /** + * @return void */ public function initializeObject() { @@ -112,18 +113,18 @@ public function getClassProperties($className) * The annotation contains the class's annotation, while properties contains each property that has to be indexed. * Each property might either have TRUE as value, or also an annotation instance, if given. * - * @throws \Flowpack\ElasticSearch\Exception * @param ObjectManagerInterface $objectManager * @return array + * @throws \Flowpack\ElasticSearch\Exception */ public static function buildIndexClassesAndProperties($objectManager) { /** @var ReflectionService $reflectionService */ - $reflectionService = $objectManager->get('TYPO3\Flow\Reflection\ReflectionService'); + $reflectionService = $objectManager->get(\TYPO3\Flow\Reflection\ReflectionService::class); $indexAnnotations = array(); - $annotationClassName = 'Flowpack\ElasticSearch\Annotations\Indexable'; + $annotationClassName = \Flowpack\ElasticSearch\Annotations\Indexable::class; foreach ($reflectionService->getClassNamesByAnnotation($annotationClassName) as $className) { if ($reflectionService->isClassAbstract($className)) { throw new \Flowpack\ElasticSearch\Exception(sprintf('The class with name "%s" is annotated with %s, but is abstract. Indexable classes must not be abstract.', $className, $annotationClassName), 1339595182); diff --git a/Classes/Flowpack/ElasticSearch/Indexer/Object/ObjectIndexer.php b/Classes/Flowpack/ElasticSearch/Indexer/Object/ObjectIndexer.php index 6db2c40..2e5bea1 100644 --- a/Classes/Flowpack/ElasticSearch/Indexer/Object/ObjectIndexer.php +++ b/Classes/Flowpack/ElasticSearch/Indexer/Object/ObjectIndexer.php @@ -12,10 +12,13 @@ */ use Doctrine\ORM\Mapping as ORM; +use Flowpack\ElasticSearch\Annotations\Transform as TransformAnnotation; use Flowpack\ElasticSearch\Domain\Model\Client; use Flowpack\ElasticSearch\Domain\Model\Document; use Flowpack\ElasticSearch\Domain\Model\GenericType; use TYPO3\Flow\Annotations as Flow; +use TYPO3\Flow\Reflection\ObjectAccess; +use TYPO3\Flow\Utility\TypeHandling; /** * This serves functionality for indexing objects @@ -46,7 +49,7 @@ class ObjectIndexer /** * @Flow\Inject - * @var \Flowpack\ElasticSearch\Indexer\Object\IndexInformer + * @var IndexInformer */ protected $indexInformer; @@ -59,7 +62,7 @@ class ObjectIndexer /** * The client will be injected via Object settings, but however, each member method is able to expect a specific client. * - * @var \Flowpack\ElasticSearch\Domain\Model\Client + * @var Client */ protected $client; @@ -68,8 +71,7 @@ class ObjectIndexer * * @param object $object * @param string $signalInformation Signal information, if called from a signal - * @param \Flowpack\ElasticSearch\Domain\Model\Client $client - * + * @param Client $client * @return void */ public function indexObject($object, $signalInformation = null, Client $client = null) @@ -88,14 +90,13 @@ public function indexObject($object, $signalInformation = null, Client $client = /** * Returns a multidimensional array with the indexable, probably transformed values of an object * - * @param $object - * + * @param object $object * @return array */ protected function getIndexablePropertiesAndValuesFromObject($object) { - $className = $this->reflectionService->getClassNameByObject($object); - $data = array(); + $className = TypeHandling::getTypeForValue($object); + $data = []; foreach ($this->indexInformer->getClassProperties($className) as $propertyName) { $value = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, $propertyName); if (($transformAnnotation = $this->reflectionService->getPropertyAnnotation($className, $propertyName, 'Flowpack\ElasticSearch\Annotations\Transform')) !== null) { @@ -108,9 +109,10 @@ protected function getIndexablePropertiesAndValuesFromObject($object) } /** - * @param $object + * @param object $object * @param string $signalInformation Signal information, if called from a signal - * @param \Flowpack\ElasticSearch\Domain\Model\Client $client + * @param Client $client + * @return void */ public function removeObject($object, $signalInformation = null, Client $client = null) { @@ -126,9 +128,8 @@ public function removeObject($object, $signalInformation = null, Client $client * Returns if, and what, treatment an object requires regarding the index state, * i.e. it checks the given object against the index and tells whether deletion, update or creation is required. * - * @param $object - * @param \Flowpack\ElasticSearch\Domain\Model\Client $client - * + * @param object $object + * @param Client $client * @return string one of this' ACTION_TYPE_* constants or NULL if no action is required */ public function objectIndexActionRequired($object, Client $client = null) @@ -156,9 +157,8 @@ public function objectIndexActionRequired($object, Client $client = null) /** * Returns the ElasticSearch type for a specific object, by its annotation * - * @param $object - * @param \Flowpack\ElasticSearch\Domain\Model\Client $client - * + * @param object $object + * @param Client $client * @return \Flowpack\ElasticSearch\Domain\Model\GenericType */ protected function getIndexTypeForObject($object, Client $client = null) @@ -180,7 +180,7 @@ protected function getIndexTypeForObject($object, Client $client = null) /** * Returns the currently used client, used for functional testing * - * @return \Flowpack\ElasticSearch\Domain\Model\Client + * @return Client */ public function getClient() { diff --git a/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/DateTransformer.php b/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/DateTransformer.php index 03989ee..160ad66 100644 --- a/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/DateTransformer.php +++ b/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/DateTransformer.php @@ -31,7 +31,6 @@ public function getTargetMappingType() /** * @param \DateTime $source * @param \Flowpack\ElasticSearch\Annotations\Transform $annotation - * * @return string */ public function transformByAnnotation($source, \Flowpack\ElasticSearch\Annotations\Transform $annotation) diff --git a/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/TransformerFactory.php b/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/TransformerFactory.php index 8fb5f5c..5b2ccdb 100644 --- a/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/TransformerFactory.php +++ b/Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/TransformerFactory.php @@ -27,9 +27,8 @@ class TransformerFactory /** * @param string $annotatedTransformer Either a full qualified class name or a shortened one which is seeked in the current package. - * - * @throws \Flowpack\ElasticSearch\Exception * @return \Flowpack\ElasticSearch\Indexer\Object\Transform\TransformerInterface + * @throws \Flowpack\ElasticSearch\Exception */ public function create($annotatedTransformer) { diff --git a/Classes/Flowpack/ElasticSearch/Mapping/BackendMappingBuilder.php b/Classes/Flowpack/ElasticSearch/Mapping/BackendMappingBuilder.php index a54f8ab..59f1188 100644 --- a/Classes/Flowpack/ElasticSearch/Mapping/BackendMappingBuilder.php +++ b/Classes/Flowpack/ElasticSearch/Mapping/BackendMappingBuilder.php @@ -23,7 +23,7 @@ class BackendMappingBuilder { /** - * @var \Flowpack\ElasticSearch\Domain\Model\Client + * @var Model\Client */ protected $client; @@ -44,8 +44,8 @@ class BackendMappingBuilder /** * Builds a Mapping collection from the annotation sources that are present * - * @throws \Flowpack\ElasticSearch\Exception * @return \Flowpack\ElasticSearch\Mapping\MappingCollection<\Flowpack\ElasticSearch\Domain\Model\Mapping> + * @throws \Flowpack\ElasticSearch\Exception */ public function buildMappingInformation() { @@ -86,7 +86,8 @@ public function buildMappingInformation() } /** - * @param \Flowpack\ElasticSearch\Domain\Model\Client $client + * @param Model\Client $client + * @return void */ public function setClient(Model\Client $client) { @@ -94,8 +95,8 @@ public function setClient(Model\Client $client) } /** - * @throws \Flowpack\ElasticSearch\Exception * @return array + * @throws \Flowpack\ElasticSearch\Exception */ public function getIndicesWithoutTypeInformation() { diff --git a/Classes/Flowpack/ElasticSearch/Mapping/EntityMappingBuilder.php b/Classes/Flowpack/ElasticSearch/Mapping/EntityMappingBuilder.php index d4a7945..058dc7f 100644 --- a/Classes/Flowpack/ElasticSearch/Mapping/EntityMappingBuilder.php +++ b/Classes/Flowpack/ElasticSearch/Mapping/EntityMappingBuilder.php @@ -11,6 +11,7 @@ * source code. */ +use Flowpack\ElasticSearch\Annotations\Indexable as IndexableAnnotation; use Flowpack\ElasticSearch\Annotations\Mapping as MappingAnnotation; use Flowpack\ElasticSearch\Domain\Model\Mapping; use TYPO3\Flow\Annotations as Flow; @@ -63,10 +64,10 @@ public function buildMappingInformation() /** * @param string $className - * @param \Flowpack\ElasticSearch\Annotations\Indexable $annotation + * @param IndexableAnnotation $annotation * @return Mapping */ - protected function buildMappingFromClassAndAnnotation($className, \Flowpack\ElasticSearch\Annotations\Indexable $annotation) + protected function buildMappingFromClassAndAnnotation($className, IndexableAnnotation $annotation) { $index = new \Flowpack\ElasticSearch\Domain\Model\Index($annotation->indexName); $type = new \Flowpack\ElasticSearch\Domain\Model\GenericType($index, $annotation->typeName); @@ -82,9 +83,8 @@ protected function buildMappingFromClassAndAnnotation($className, \Flowpack\Elas * @param Mapping $mapping * @param string $className * @param string $propertyName - * - * @throws \Flowpack\ElasticSearch\Exception * @return void + * @throws \Flowpack\ElasticSearch\Exception */ protected function augmentMappingByProperty(Mapping $mapping, $className, $propertyName) { @@ -106,6 +106,7 @@ protected function augmentMappingByProperty(Mapping $mapping, $className, $prope if ($annotation instanceof MappingAnnotation) { $mapping->setPropertyByPath($propertyName, $this->processMappingAnnotation($annotation, $mapping->getPropertyByPath($propertyName))); if ($annotation->getFields()) { + $multiFields = []; foreach ($annotation->getFields() as $multiFieldAnnotation) { $multiFieldIndexName = trim($multiFieldAnnotation->index_name); if ($multiFieldIndexName === '') { @@ -127,7 +128,7 @@ protected function augmentMappingByProperty(Mapping $mapping, $className, $prope * @param array $propertyMapping * @return array */ - protected function processMappingAnnotation(MappingAnnotation $annotation, $propertyMapping = array()) + protected function processMappingAnnotation(MappingAnnotation $annotation, array $propertyMapping = array()) { foreach ($annotation->getPropertiesArray() as $mappingDirective => $directiveValue) { if ($directiveValue === null) { diff --git a/Classes/Flowpack/ElasticSearch/Mapping/MappingCollection.php b/Classes/Flowpack/ElasticSearch/Mapping/MappingCollection.php index fd8dbea..816ee4e 100644 --- a/Classes/Flowpack/ElasticSearch/Mapping/MappingCollection.php +++ b/Classes/Flowpack/ElasticSearch/Mapping/MappingCollection.php @@ -12,6 +12,7 @@ */ use Doctrine\ORM\Mapping as ORM; +use Flowpack\ElasticSearch\Domain\Model\Mapping; use TYPO3\Flow\Annotations as Flow; /** @@ -52,8 +53,8 @@ public function diffAgainstCollection(MappingCollection $complementCollection) { $returnMappings = new \Flowpack\ElasticSearch\Mapping\MappingCollection(); foreach ($this as $entityMapping) { - /** @var $entityMapping \Flowpack\ElasticSearch\Domain\Model\Mapping */ - $mapping = new \Flowpack\ElasticSearch\Domain\Model\Mapping(clone $entityMapping->getType()); + /** @var $entityMapping Mapping */ + $mapping = new Mapping(clone $entityMapping->getType()); $saveMapping = false; foreach ($entityMapping->getProperties() as $propertyName => $propertySettings) { foreach ($propertySettings as $entitySettingKey => $entitySettingValue) { @@ -75,16 +76,15 @@ public function diffAgainstCollection(MappingCollection $complementCollection) /** * Tells whether a member of this collection has a specific index/type/property settings value * - * @param \Flowpack\ElasticSearch\Domain\Model\Mapping $inquirerMapping + * @param Mapping $inquirerMapping * @param string $propertyName - * @param $settingKey - * + * @param string $settingKey * @return mixed */ - public function getMappingSetting(\Flowpack\ElasticSearch\Domain\Model\Mapping $inquirerMapping, $propertyName, $settingKey) + public function getMappingSetting(Mapping $inquirerMapping, $propertyName, $settingKey) { foreach ($this as $memberMapping) { - /** @var $memberMapping \Flowpack\ElasticSearch\Domain\Model\Mapping */ + /** @var $memberMapping Mapping */ if ($inquirerMapping->getType()->getName() === $memberMapping->getType()->getName() && $inquirerMapping->getType()->getIndex()->getName() === $memberMapping->getType()->getIndex()->getName()) { return $memberMapping->getPropertyByPath(array($propertyName, $settingKey)); @@ -96,6 +96,7 @@ public function getMappingSetting(\Flowpack\ElasticSearch\Domain\Model\Mapping $ /** * @param \Flowpack\ElasticSearch\Domain\Model\Client $client + * @return void */ public function setClient(\Flowpack\ElasticSearch\Domain\Model\Client $client) { diff --git a/Classes/Flowpack/ElasticSearch/Package.php b/Classes/Flowpack/ElasticSearch/Package.php index 47f684f..73d0885 100644 --- a/Classes/Flowpack/ElasticSearch/Package.php +++ b/Classes/Flowpack/ElasticSearch/Package.php @@ -11,6 +11,9 @@ * source code. */ +use Flowpack\ElasticSearch\Indexer\Object\ObjectIndexer; +use Flowpack\ElasticSearch\Indexer\Object\Signal\SignalEmitter; +use TYPO3\Flow\Configuration\ConfigurationManager; use TYPO3\Flow\Package\Package as BasePackage; /** @@ -19,7 +22,7 @@ class Package extends BasePackage { /** - * @var \TYPO3\Flow\Configuration\ConfigurationManager + * @var ConfigurationManager */ protected $configurationManager; @@ -27,14 +30,13 @@ class Package extends BasePackage * Invokes custom PHP code directly after the package manager has been initialized. * * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap - * * @return void */ public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap) { $dispatcher = $bootstrap->getSignalSlotDispatcher(); $package = $this; - $dispatcher->connect('TYPO3\Flow\Core\Booting\Sequence', 'afterInvokeStep', function (\TYPO3\Flow\Core\Booting\Step $step) use ($package, $bootstrap) { + $dispatcher->connect(\TYPO3\Flow\Core\Booting\Sequence::class, 'afterInvokeStep', function (\TYPO3\Flow\Core\Booting\Step $step) use ($package, $bootstrap) { if ($step->getIdentifier() === 'typo3.flow:objectmanagement:runtime') { $package->prepareRealtimeIndexing($bootstrap); } @@ -43,15 +45,17 @@ public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap) /** * @param \TYPO3\Flow\Core\Bootstrap $bootstrap + * @return void */ public function prepareRealtimeIndexing(\TYPO3\Flow\Core\Bootstrap $bootstrap) { - $this->configurationManager = $bootstrap->getObjectManager()->get('TYPO3\Flow\Configuration\ConfigurationManager'); - $settings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->getPackageKey()); + $this->configurationManager = $bootstrap->getObjectManager()->get(ConfigurationManager::class); + $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->getPackageKey()); + if (isset($settings['realtimeIndexing']['enabled']) && $settings['realtimeIndexing']['enabled'] === true) { - $bootstrap->getSignalSlotDispatcher()->connect('Flowpack\ElasticSearch\Indexer\Object\Signal\SignalEmitter', 'objectUpdated', 'Flowpack\ElasticSearch\Indexer\Object\ObjectIndexer', 'indexObject'); - $bootstrap->getSignalSlotDispatcher()->connect('Flowpack\ElasticSearch\Indexer\Object\Signal\SignalEmitter', 'objectPersisted', 'Flowpack\ElasticSearch\Indexer\Object\ObjectIndexer', 'indexObject'); - $bootstrap->getSignalSlotDispatcher()->connect('Flowpack\ElasticSearch\Indexer\Object\Signal\SignalEmitter', 'objectRemoved', 'Flowpack\ElasticSearch\Indexer\Object\ObjectIndexer', 'removeObject'); + $bootstrap->getSignalSlotDispatcher()->connect(SignalEmitter::class, 'objectUpdated', ObjectIndexer::class, 'indexObject'); + $bootstrap->getSignalSlotDispatcher()->connect(SignalEmitter::class, 'objectPersisted', ObjectIndexer::class, 'indexObject'); + $bootstrap->getSignalSlotDispatcher()->connect(SignalEmitter::class, 'objectRemoved', ObjectIndexer::class, 'removeObject'); } } } diff --git a/Classes/Flowpack/ElasticSearch/Transfer/Exception.php b/Classes/Flowpack/ElasticSearch/Transfer/Exception.php index f7ca9ac..b91e175 100644 --- a/Classes/Flowpack/ElasticSearch/Transfer/Exception.php +++ b/Classes/Flowpack/ElasticSearch/Transfer/Exception.php @@ -27,7 +27,13 @@ class Exception extends \Flowpack\ElasticSearch\Exception protected $request; /** + * Exception constructor. * + * @param string $message + * @param integer $code + * @param \TYPO3\Flow\Http\Response $response + * @param \TYPO3\Flow\Http\Request $request + * @param \Exception $previous */ public function __construct($message, $code, \TYPO3\Flow\Http\Response $response, \TYPO3\Flow\Http\Request $request = null, \Exception $previous = null) { diff --git a/Classes/Flowpack/ElasticSearch/Transfer/RequestService.php b/Classes/Flowpack/ElasticSearch/Transfer/RequestService.php index 875260b..a9afd80 100644 --- a/Classes/Flowpack/ElasticSearch/Transfer/RequestService.php +++ b/Classes/Flowpack/ElasticSearch/Transfer/RequestService.php @@ -18,6 +18,7 @@ /** * Handles the requests + * * @Flow\scope("singleton") */ class RequestService @@ -58,8 +59,7 @@ public function initializeObject() * @param string $path * @param array $arguments * @param string|array $content - * - * @return \Flowpack\ElasticSearch\Transfer\Response + * @return Response */ public function request($method, \Flowpack\ElasticSearch\Domain\Model\Client $client, $path = null, $arguments = array(), $content = null) { diff --git a/Classes/Flowpack/ElasticSearch/Transfer/Response.php b/Classes/Flowpack/ElasticSearch/Transfer/Response.php index 83151f7..e4c427c 100644 --- a/Classes/Flowpack/ElasticSearch/Transfer/Response.php +++ b/Classes/Flowpack/ElasticSearch/Transfer/Response.php @@ -31,7 +31,6 @@ class Response /** * @param \TYPO3\Flow\Http\Response $response * @param \TYPO3\Flow\Http\Request $request - * * @throws \Flowpack\ElasticSearch\Transfer\Exception * @throws \Flowpack\ElasticSearch\Transfer\Exception\ApiException */ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bdeff91 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Neos project contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Tests/Functional/Domain/AbstractTest.php b/Tests/Functional/Domain/AbstractTest.php index 7d2cf45..506199a 100644 --- a/Tests/Functional/Domain/AbstractTest.php +++ b/Tests/Functional/Domain/AbstractTest.php @@ -11,12 +11,14 @@ * source code. */ +use Flowpack\ElasticSearch\Domain\Factory\ClientFactory; + /** */ abstract class AbstractTest extends \TYPO3\Flow\Tests\FunctionalTestCase { /** - * @var \Flowpack\ElasticSearch\Domain\Factory\ClientFactory + * @var ClientFactory */ protected $clientFactory; @@ -37,7 +39,7 @@ final public function setUp() { parent::setUp(); - $this->clientFactory = $this->objectManager->get('Flowpack\ElasticSearch\Domain\Factory\ClientFactory'); + $this->clientFactory = $this->objectManager->get(ClientFactory::class); $client = $this->clientFactory->create(); $this->testingIndex = $client->findIndex('typo3_elasticsearch_functionaltests'); diff --git a/Tests/Functional/Domain/DocumentTest.php b/Tests/Functional/Domain/DocumentTest.php index 973f9cc..5aea965 100644 --- a/Tests/Functional/Domain/DocumentTest.php +++ b/Tests/Functional/Domain/DocumentTest.php @@ -11,6 +11,7 @@ * source code. */ +use Flowpack\ElasticSearch\Domain\Model\Document; use \Flowpack\ElasticSearch\Tests\Functional\Fixtures\TwitterType; /** @@ -40,7 +41,7 @@ public function simpleDocumentDataProvider() */ public function idOfFreshNewDocumentIsPopulatedAfterStoring(array $data = null) { - $document = new \Flowpack\ElasticSearch\Domain\Model\Document(new TwitterType($this->testingIndex), $data); + $document = new Document(new TwitterType($this->testingIndex), $data); $this->assertNull($document->getId()); $document->store(); $this->assertRegExp('/\w+/', $document->getId()); @@ -52,7 +53,7 @@ public function idOfFreshNewDocumentIsPopulatedAfterStoring(array $data = null) */ public function versionOfFreshNewDocumentIsCreatedAfterStoringAndIncreasedAfterSubsequentStoring(array $data = null) { - $document = new \Flowpack\ElasticSearch\Domain\Model\Document(new TwitterType($this->testingIndex), $data); + $document = new Document(new TwitterType($this->testingIndex), $data); $this->assertNull($document->getVersion()); $document->store(); $idAfterFirstStoring = $document->getId(); @@ -69,7 +70,7 @@ public function versionOfFreshNewDocumentIsCreatedAfterStoringAndIncreasedAfterS public function existingIdOfDocumentIsNotModifiedAfterStoring(array $data) { $id = '42-1010-42'; - $document = new \Flowpack\ElasticSearch\Domain\Model\Document(new TwitterType($this->testingIndex), $data, $id); + $document = new Document(new TwitterType($this->testingIndex), $data, $id); $document->store(); $this->assertSame($id, $document->getId()); } diff --git a/Tests/Functional/Fixtures/Tweet.php b/Tests/Functional/Fixtures/Tweet.php index c0a0403..860aa39 100644 --- a/Tests/Functional/Fixtures/Tweet.php +++ b/Tests/Functional/Fixtures/Tweet.php @@ -18,7 +18,7 @@ * An object for the "twitter" index, representing a "tweet" document. * * @Flow\Entity - * @ElasticSearch\Indexable(indexName="flow3_elasticsearch_functionaltests_twitter", typeName="tweet") + * @ElasticSearch\Indexable(indexName="flow_elasticsearch_functionaltests_twitter", typeName="tweet") */ class Tweet { diff --git a/Tests/Functional/Indexer/Object/IndexInformerTest.php b/Tests/Functional/Indexer/Object/IndexInformerTest.php index 43589ba..d4e1815 100644 --- a/Tests/Functional/Indexer/Object/IndexInformerTest.php +++ b/Tests/Functional/Indexer/Object/IndexInformerTest.php @@ -11,12 +11,16 @@ * source code. */ +use Flowpack\ElasticSearch\Annotations\Indexable as IndexableAnnotation; +use Flowpack\ElasticSearch\Indexer\Object\IndexInformer; +use Flowpack\ElasticSearch\Tests\Functional\Fixtures; + /** */ class IndexInformerTest extends \TYPO3\Flow\Tests\FunctionalTestCase { /** - * @var \Flowpack\ElasticSearch\Indexer\Object\IndexInformer + * @var IndexInformer */ protected $informer; @@ -25,7 +29,7 @@ class IndexInformerTest extends \TYPO3\Flow\Tests\FunctionalTestCase public function setUp() { parent::setUp(); - $this->informer = $this->objectManager->get('Flowpack\ElasticSearch\Indexer\Object\IndexInformer'); + $this->informer = $this->objectManager->get(IndexInformer::class); } /** @@ -33,8 +37,8 @@ public function setUp() */ public function classAnnotationTest() { - $actual = $this->informer->getClassAnnotation('Flowpack\ElasticSearch\Tests\Functional\Fixtures\JustFewPropertiesToIndex'); - $this->assertInstanceOf('Flowpack\ElasticSearch\Annotations\Indexable', $actual); + $actual = $this->informer->getClassAnnotation(Fixtures\JustFewPropertiesToIndex::class); + $this->assertInstanceOf(IndexableAnnotation::class, $actual); $this->assertSame('dummyindex', $actual->indexName); $this->assertSame('sampletype', $actual->typeName); } @@ -44,7 +48,7 @@ public function classAnnotationTest() */ public function classWithOnlyOnePropertyAnnotatedHasOnlyThisPropertyToBeIndexed() { - $actual = $this->informer->getClassProperties('Flowpack\ElasticSearch\Tests\Functional\Fixtures\JustFewPropertiesToIndex'); + $actual = $this->informer->getClassProperties(Fixtures\JustFewPropertiesToIndex::class); $this->assertCount(1, $actual); } @@ -53,7 +57,7 @@ public function classWithOnlyOnePropertyAnnotatedHasOnlyThisPropertyToBeIndexed( */ public function classWithNoPropertyAnnotatedHasAllPropertiesToBeIndexed() { - $actual = $this->informer->getClassProperties('Flowpack\ElasticSearch\Tests\Functional\Fixtures\Tweet'); + $actual = $this->informer->getClassProperties(Fixtures\Tweet::class); $this->assertGreaterThan(1, $actual); } } diff --git a/Tests/Functional/Indexer/Object/ObjectIndexerTest.php b/Tests/Functional/Indexer/Object/ObjectIndexerTest.php index 35a9f82..28e0b25 100644 --- a/Tests/Functional/Indexer/Object/ObjectIndexerTest.php +++ b/Tests/Functional/Indexer/Object/ObjectIndexerTest.php @@ -11,8 +11,11 @@ * source code. */ +use Flowpack\ElasticSearch\Domain\Model\Document; +use Flowpack\ElasticSearch\Indexer\Object\ObjectIndexer; use Flowpack\ElasticSearch\Tests\Functional\Fixtures\TweetRepository; use Flowpack\ElasticSearch\Tests\Functional\Fixtures\Tweet; +use TYPO3\Flow\Utility\Algorithms; /** */ @@ -39,7 +42,7 @@ public function setUp() { parent::setUp(); $this->testEntityRepository = new TweetRepository(); - $this->testClient = $this->objectManager->get('Flowpack\ElasticSearch\Indexer\Object\ObjectIndexer')->getClient(); + $this->testClient = $this->objectManager->get(ObjectIndexer::class)->getClient(); } /** @@ -51,7 +54,7 @@ public function persistingNewObjectTriggersIndexing() $documentId = $this->persistenceManager->getIdentifierByObject($testEntity); $resultDocument = $this->testClient - ->findIndex('flow3_elasticsearch_functionaltests_twitter') + ->findIndex('flow_elasticsearch_functionaltests_twitter') ->findType('tweet') ->findDocumentById($documentId); $resultData = $resultDocument->getData(); @@ -69,7 +72,7 @@ public function updatingExistingObjectTriggersReindexing() $identifier = $this->persistenceManager->getIdentifierByObject($testEntity); $initialVersion = $this->testClient - ->findIndex('flow3_elasticsearch_functionaltests_twitter') + ->findIndex('flow_elasticsearch_functionaltests_twitter') ->findType('tweet') ->findDocumentById($identifier) ->getVersion(); @@ -82,7 +85,7 @@ public function updatingExistingObjectTriggersReindexing() $this->persistenceManager->clearState(); $changedDocument = $this->testClient - ->findIndex('flow3_elasticsearch_functionaltests_twitter') + ->findIndex('flow_elasticsearch_functionaltests_twitter') ->findType('tweet') ->findDocumentById($identifier); @@ -99,10 +102,10 @@ public function removingObjectTriggersIndexRemoval() $identifier = $this->persistenceManager->getIdentifierByObject($testEntity); $initialDocument = $this->testClient - ->findIndex('flow3_elasticsearch_functionaltests_twitter') + ->findIndex('flow_elasticsearch_functionaltests_twitter') ->findType('tweet') ->findDocumentById($identifier); - $this->assertInstanceOf('Flowpack\ElasticSearch\Domain\Model\Document', $initialDocument); + $this->assertInstanceOf(Document::class, $initialDocument); $persistedTestEntity = $this->testEntityRepository->findByIdentifier($identifier); $this->testEntityRepository->remove($persistedTestEntity); @@ -110,7 +113,7 @@ public function removingObjectTriggersIndexRemoval() $this->persistenceManager->clearState(); $foundDocument = $this->testClient - ->findIndex('flow3_elasticsearch_functionaltests_twitter') + ->findIndex('flow_elasticsearch_functionaltests_twitter') ->findType('tweet') ->findDocumentById($identifier); $this->assertNull($foundDocument); @@ -122,8 +125,8 @@ protected function createAndPersistTestEntity() { $testEntity = new Tweet(); $testEntity->setDate(new \DateTime()); - $testEntity->setMessage('This is a test message ' . \TYPO3\Flow\Utility\Algorithms::generateRandomString(8)); - $testEntity->setUsername('Zak McKracken' . \TYPO3\Flow\Utility\Algorithms::generateRandomString(8)); + $testEntity->setMessage('This is a test message ' . Algorithms::generateRandomString(8)); + $testEntity->setUsername('Zak McKracken' . Algorithms::generateRandomString(8)); $this->testEntityRepository->add($testEntity); $this->persistenceManager->persistAll(); diff --git a/Tests/Functional/Mapping/MappingBuilderTest.php b/Tests/Functional/Mapping/MappingBuilderTest.php index 62b8ce6..b3cb782 100644 --- a/Tests/Functional/Mapping/MappingBuilderTest.php +++ b/Tests/Functional/Mapping/MappingBuilderTest.php @@ -11,12 +11,15 @@ * source code. */ +use Flowpack\ElasticSearch\Domain\Model\Mapping; +use Flowpack\ElasticSearch\Mapping\EntityMappingBuilder; + /** */ class MappingBuilderTest extends \TYPO3\Flow\Tests\FunctionalTestCase { /** - * @var \Flowpack\ElasticSearch\Mapping\EntityMappingBuilder + * @var EntityMappingBuilder */ protected $mappingBuilder; @@ -25,7 +28,7 @@ class MappingBuilderTest extends \TYPO3\Flow\Tests\FunctionalTestCase public function setUp() { parent::setUp(); - $this->mappingBuilder = $this->objectManager->get('Flowpack\ElasticSearch\Mapping\EntityMappingBuilder'); + $this->mappingBuilder = $this->objectManager->get(EntityMappingBuilder::class); } /** @@ -35,6 +38,6 @@ public function basicTest() { $information = $this->mappingBuilder->buildMappingInformation(); $this->assertGreaterThanOrEqual(2, count($information)); - $this->assertInstanceOf('Flowpack\ElasticSearch\Domain\Model\Mapping', $information[0]); + $this->assertInstanceOf(Mapping::class, $information[0]); } } diff --git a/composer.json b/composer.json index 5867563..37ad55f 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "flowpack/elasticsearch", "type": "typo3-flow-package", + "license": "MIT", "description": "This package provides wrapper functionality for the elasticsearch engine.", "require": { "ext-curl": "*",