Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed travis tests #117

Merged
merged 2 commits into from Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Behat/SearchManagerContext.php
Expand Up @@ -171,7 +171,7 @@ private function doIndexTheFollowingObjects($className, PyStringNode $string)
foreach ($objectsData as $objectData) {
$object = new $this->entityClasses[$className]();
foreach ($objectData as $key => $value) {
if (is_string($value) && ($date = \DateTime::createFromFormat('Y-m-d', $value)) !== false) {
if (is_string($value) && false !== ($date = \DateTime::createFromFormat('Y-m-d', $value))) {
$value = $date;
}
$object->$key = $value;
Expand Down
4 changes: 2 additions & 2 deletions Command/ReindexCommand.php
Expand Up @@ -98,7 +98,7 @@ public function execute(InputInterface $input, OutputInterface $output)

$startTime = microtime(true);

if ($this->env !== 'prod') {
if ('prod' !== $this->env) {
$output->writeln(
$formatterHelper->formatBlock(
sprintf(
Expand Down Expand Up @@ -197,7 +197,7 @@ private function reindexClass(
while (true) {
$objects = $provider->provide($classFqn, $offset, $batchSize);

if (count($objects) === 0) {
if (0 === count($objects)) {
$provider->cleanUp($classFqn);
$this->resumeManager->setCheckpoint($providerName, $classFqn, $count);
$progress->finish();
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Compiler/ConverterPass.php
Expand Up @@ -21,6 +21,7 @@
class ConverterPass implements CompilerPassInterface
{
const SERVICE_ID = 'massive_search.converter';

const TAG_NAME = 'massive_search.converter';

/**
Expand Down
6 changes: 6 additions & 0 deletions Search/Adapter/ElasticSearchAdapter.php
Expand Up @@ -28,13 +28,19 @@
class ElasticSearchAdapter implements AdapterInterface
{
const ID_FIELDNAME = '__id';

const INDEX_FIELDNAME = '__index';

const CLASS_TAG = '__class';

const URL_FIELDNAME = '__url';

const TITLE_FIELDNAME = '__title';

const DESCRIPTION_FIELDNAME = '__description';

const LOCALE_FIELDNAME = '__locale';

const IMAGE_URL = '__image_url';

/**
Expand Down
1 change: 1 addition & 0 deletions Search/Adapter/TestAdapter.php
Expand Up @@ -23,6 +23,7 @@
class TestAdapter implements AdapterInterface
{
protected $documents = [];

protected $factory;

public function __construct(Factory $factory)
Expand Down
11 changes: 9 additions & 2 deletions Search/Adapter/ZendLuceneAdapter.php
Expand Up @@ -33,14 +33,21 @@
class ZendLuceneAdapter implements AdapterInterface
{
const ID_FIELDNAME = '__id';

const INDEX_FIELDNAME = '__index';

const CLASS_TAG = '__class';

const AGGREGATED_INDEXED_CONTENT = '__content';

const URL_FIELDNAME = '__url';

const TITLE_FIELDNAME = '__title';

const LOCALE_FIELDNAME = '__locale';

const DESCRIPTION_FIELDNAME = '__description';

const IMAGE_URL = '__image_url';

/**
Expand Down Expand Up @@ -114,13 +121,13 @@ public function index(Document $document, $indexName)
$type = $field->getType();
$value = $field->getValue();

if ($type === Field::TYPE_NULL) {
if (Field::TYPE_NULL === $type) {
continue;
}

// Zend Lucene does not support "types". We should allow other "types" once they
// are properly implemented in at least one other adapter.
if ($type !== Field::TYPE_STRING && $type !== Field::TYPE_ARRAY) {
if (Field::TYPE_STRING !== $type && Field::TYPE_ARRAY !== $type) {
throw new \InvalidArgumentException(
sprintf(
'Search field type "%s" is not known. Known types are: %s',
Expand Down
3 changes: 0 additions & 3 deletions Search/AdapterInterface.php
Expand Up @@ -63,9 +63,6 @@ public function getStatus();
*/
public function listIndexes();

/**
* {@inheritdoc}
*/
public function flush(array $indexNames);

/**
Expand Down
2 changes: 1 addition & 1 deletion Search/Decorator/LocalizationDecorator.php
Expand Up @@ -86,7 +86,7 @@ public function isVariant($indexName, $decoratedIndexName, array $options = [])
*/
private function removeLocale($decoratedIndexName)
{
if (preg_match('/(.*)(-.*-i18n)/', $decoratedIndexName, $matches) === 0) {
if (0 === preg_match('/(.*)(-.*-i18n)/', $decoratedIndexName, $matches)) {
return $decoratedIndexName;
}

Expand Down
2 changes: 1 addition & 1 deletion Search/Decorator/PrefixDecorator.php
Expand Up @@ -82,7 +82,7 @@ public function isVariant($indexName, $decoratedIndexName, array $options = [])
*/
private function removePrefix($decoratedIndexName)
{
if (strpos($decoratedIndexName, $this->prefix . '_') === 0) {
if (0 === strpos($decoratedIndexName, $this->prefix . '_')) {
$decoratedIndexName = substr($decoratedIndexName, strlen($this->prefix) + 1);

return $decoratedIndexName;
Expand Down
1 change: 1 addition & 0 deletions Search/Event/HitEvent.php
Expand Up @@ -18,6 +18,7 @@
class HitEvent extends Event
{
protected $hit;

protected $metadata;

public function __construct(QueryHit $hit, ClassMetadata $metadata)
Expand Down
Expand Up @@ -69,7 +69,7 @@ function ($elements, $expression) {
throw new \Exception('Map function does not support compilation');
},
function (array $values, $elements, $expression) {
if (count($elements) === 0) {
if (0 === count($elements)) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion Search/Metadata/Driver/XmlDriver.php
Expand Up @@ -64,7 +64,7 @@ public function loadMetadataFromFile(\ReflectionClass $class, $file)
));
}

if (count($xml->children()) == 0) {
if (0 == count($xml->children())) {
throw new \InvalidArgumentException(sprintf('No mapping in file "%s"', $file));
}

Expand Down
1 change: 0 additions & 1 deletion Search/Metadata/Provider/DefaultProvider.php
Expand Up @@ -13,7 +13,6 @@

use Massive\Bundle\SearchBundle\Search\Document;
use Massive\Bundle\SearchBundle\Search\Metadata\ProviderInterface;
use Metadata\MetadataFactory;
use Metadata\MetadataFactoryInterface;

/**
Expand Down
8 changes: 4 additions & 4 deletions Search/ObjectToDocumentConverter.php
Expand Up @@ -153,7 +153,7 @@ private function populateDocument($document, $object, $fieldMapping, $prefix = '
$mapping
);

if ($mapping['type'] == 'complex') {
if ('complex' == $mapping['type']) {
if (!isset($mapping['mapping'])) {
throw new \InvalidArgumentException(
sprintf(
Expand Down Expand Up @@ -185,7 +185,7 @@ private function populateDocument($document, $object, $fieldMapping, $prefix = '
$type = $mapping['type'];
$value = $this->fieldEvaluator->getValue($object, $mapping['field']);

if ($type !== Field::TYPE_STRING && $type !== Field::TYPE_ARRAY) {
if (Field::TYPE_STRING !== $type && Field::TYPE_ARRAY !== $type) {
$value = $this->converterManager->convert($value, $type);

if (is_null($value)) {
Expand All @@ -197,7 +197,7 @@ private function populateDocument($document, $object, $fieldMapping, $prefix = '
}
}

if ($value !== null && false === is_scalar($value) && false === is_array($value)) {
if (null !== $value && false === is_scalar($value) && false === is_array($value)) {
throw new \InvalidArgumentException(
sprintf(
'Search field "%s" resolved to not supported type "%s". Only scalar (single) or array values can be indexed.',
Expand All @@ -207,7 +207,7 @@ private function populateDocument($document, $object, $fieldMapping, $prefix = '
);
}

if ($mapping['type'] !== 'complex') {
if ('complex' !== $mapping['type']) {
$document->addField(
$this->factory->createField(
$prefix . $fieldName,
Expand Down
2 changes: 2 additions & 0 deletions Search/QueryHit.php
Expand Up @@ -17,7 +17,9 @@
class QueryHit implements \JsonSerializable
{
protected $document;

protected $score;

protected $id;

/**
Expand Down
5 changes: 5 additions & 0 deletions Search/SearchEvents.php
Expand Up @@ -17,9 +17,14 @@
class SearchEvents
{
const SEARCH = 'massive_search.search';

const HIT = 'massive_search.hit';

const PRE_INDEX = 'massive_search.pre_index';

const INDEX_REBUILD = 'massive_search.index_rebuild';

const INDEX = 'massive_search.index';

const DEINDEX = 'massive_search.deindex';
}
1 change: 1 addition & 0 deletions Search/SearchQuery.php
Expand Up @@ -18,6 +18,7 @@ class SearchQuery
{
// constants for search order
const SORT_ASC = 'asc';

const SORT_DESC = 'desc';

/**
Expand Down
6 changes: 6 additions & 0 deletions Tests/Resources/TestBundle/EntityDist/Car.php
Expand Up @@ -14,10 +14,16 @@
class Car
{
public $id;

public $title;

public $body;

public $numberOfWheels;

public $cost;

public $date;

public $image;
}
3 changes: 3 additions & 0 deletions Tests/Resources/TestBundle/EntityDist/Contact.php
Expand Up @@ -14,7 +14,10 @@
class Contact
{
public $id;

public $title;

public $emails;

public $addresses;
}
3 changes: 3 additions & 0 deletions Tests/Resources/TestBundle/EventSubscriber/TestSubscriber.php
Expand Up @@ -19,10 +19,13 @@
class TestSubscriber implements EventSubscriberInterface
{
public $hitDocument;

public $documentReflection;

public $nbHits = 0;

public $preIndexDocument;

public $preIndexMetadata;

public static function getSubscribedEvents()
Expand Down
6 changes: 6 additions & 0 deletions Tests/Resources/TestBundle/Product.php
Expand Up @@ -14,11 +14,17 @@
class Product
{
public $id;

public $title;

public $body;

public $date;

public $url;

public $locale;

public $image;

public function getId()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Search/Metadata/ClassMetadataTest.php
Expand Up @@ -33,7 +33,7 @@ public function setUp()
}

/**
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Context name "foo_context" has already been registered
*/
public function testAddIndexExisting()
Expand Down
1 change: 0 additions & 1 deletion Tests/Unit/Search/Metadata/FieldEvaluatorTest.php
Expand Up @@ -19,7 +19,6 @@
use Massive\Bundle\SearchBundle\Search\ObjectToDocumentConverter;
use Massive\Bundle\SearchBundle\Tests\Resources\TestBundle\Product;
use Prophecy\Argument;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

class FieldEvaluatorTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Expand Up @@ -16,7 +16,6 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Massive\Bundle\SearchBundle\Search\Metadata\ClassMetadata as SearchClassMetadata;
use Massive\Bundle\SearchBundle\Search\Reindex\Provider\DoctrineOrmProvider;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Search/SearchManagerTest.php
Expand Up @@ -121,7 +121,7 @@ public function testIndexNonObject()
}

/**
* @expectedException Massive\Bundle\SearchBundle\Search\Exception\MetadataNotFoundException
* @expectedException \Massive\Bundle\SearchBundle\Search\Exception\MetadataNotFoundException
* @expectedExceptionMessage There is no search mapping
*/
public function testIndexNoMetadata()
Expand Down
2 changes: 1 addition & 1 deletion Tests/travis.php.ini
@@ -1 +1 @@
memory_limit = 2048M
memory_limit = 4096M