mirror of
https://github.com/jbcr/SyliusElasticsearchPlugin.git
synced 2026-03-24 00:42:08 +01:00
Fix behat and unit tests
This commit is contained in:
@@ -233,12 +233,13 @@ $ bin/console debug:container --parameters | grep bitbag
|
||||
```bash
|
||||
$ composer install
|
||||
$ cd tests/Application
|
||||
$ yarn install
|
||||
$ yarn build
|
||||
$ bin/console assets:install public -e test
|
||||
$ bin/console doctrine:database:create -e test
|
||||
$ bin/console doctrine:schema:create -e test
|
||||
$ bin/console server:run 127.0.0.1:8080 -d public -e test
|
||||
$ elasticsearch
|
||||
// run elasticsearch
|
||||
$ bin/console sylius:fixtures:load -e test
|
||||
$ symfony server:run 127.0.0.1:8080 -d public -e test
|
||||
$ bin/console assets:install public -e test
|
||||
$ open http://localhost:8080
|
||||
$ vendor/bin/behat
|
||||
$ vendor/bin/phpspec run
|
||||
|
||||
@@ -11,8 +11,6 @@ default:
|
||||
clean_start: false
|
||||
screenshot: true
|
||||
|
||||
|
||||
|
||||
Behat\MinkExtension:
|
||||
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
|
||||
base_url: "https://127.0.0.1:8080/"
|
||||
|
||||
@@ -15,6 +15,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AttributeBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Component\Locale\Context\LocaleContextInterface;
|
||||
@@ -44,8 +45,9 @@ final class AttributeBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use BitBag\SyliusElasticsearchPlugin\Repository\TaxonRepositoryInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AttributeTaxonsBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -38,8 +39,9 @@ final class AttributeTaxonsBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ChannelPricingBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -40,8 +41,9 @@ final class ChannelPricingBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace spec\BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ChannelsBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -36,8 +37,9 @@ final class ChannelsBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\OptionBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -40,8 +41,9 @@ final class OptionBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\OptionTaxonsBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
@@ -45,8 +46,9 @@ final class OptionTaxonsBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace spec\BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ProductCreatedAtPropertyBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -34,8 +35,9 @@ final class ProductCreatedAtPropertyBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ProductDescriptionBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -29,8 +30,9 @@ final class ProductDescriptionBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ProductNameBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -37,8 +38,9 @@ final class ProductNameBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ProductShortDescriptionBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -29,8 +30,9 @@ final class ProductShortDescriptionBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\ProductTaxonsBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -35,8 +36,9 @@ final class ProductTaxonsBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\AbstractBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\PropertyBuilderInterface;
|
||||
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\SoldUnitsPropertyBuilder;
|
||||
use BitBag\SyliusElasticsearchPlugin\Repository\OrderItemRepositoryInterface;
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\PostTransformEvent;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
@@ -37,8 +38,9 @@ final class SoldUnitsPropertyBuilderSpec extends ObjectBehavior
|
||||
$this->shouldHaveType(PropertyBuilderInterface::class);
|
||||
}
|
||||
|
||||
function it_consumes_event(PostTransformEvent $event): void
|
||||
function it_consumes_event(Document $document, $object): void
|
||||
{
|
||||
$event = new PostTransformEvent($document->getWrappedObject(), [], $object->getWrappedObject());
|
||||
$this->consumeEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\BitBag\SyliusElasticsearchPlugin\Behat\Service;
|
||||
|
||||
use FOS\ElasticaBundle\Event\IndexPopulateEvent;
|
||||
use FOS\ElasticaBundle\Event\TypePopulateEvent;
|
||||
use FOS\ElasticaBundle\Event\PostIndexPopulateEvent;
|
||||
use FOS\ElasticaBundle\Event\PreIndexPopulateEvent;
|
||||
use FOS\ElasticaBundle\Index\IndexManager;
|
||||
use FOS\ElasticaBundle\Index\Resetter;
|
||||
use FOS\ElasticaBundle\Index\ResetterInterface;
|
||||
use FOS\ElasticaBundle\Persister\PagerPersisterInterface;
|
||||
use FOS\ElasticaBundle\Persister\PagerPersisterRegistry;
|
||||
use FOS\ElasticaBundle\Provider\PagerProviderRegistry;
|
||||
@@ -36,7 +36,7 @@ final class Populate
|
||||
/** @var PagerPersisterInterface */
|
||||
private $pagerPersister;
|
||||
|
||||
/** @var Resetter */
|
||||
/** @var ResetterInterface */
|
||||
private $resetter;
|
||||
|
||||
public function __construct(
|
||||
@@ -44,7 +44,7 @@ final class Populate
|
||||
IndexManager $indexManager,
|
||||
PagerProviderRegistry $pagerProviderRegistry,
|
||||
PagerPersisterRegistry $pagerPersisterRegistry,
|
||||
Resetter $resetter
|
||||
ResetterInterface $resetter
|
||||
) {
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->indexManager = $indexManager;
|
||||
@@ -65,52 +65,27 @@ final class Populate
|
||||
];
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
$event = new IndexPopulateEvent($index, true, $options);
|
||||
$this->dispatcher->dispatch($event, IndexPopulateEvent::PRE_INDEX_POPULATE);
|
||||
$event = new PreIndexPopulateEvent($index, true, $options);
|
||||
$this->dispatcher->dispatch($event);
|
||||
|
||||
if ($event->isReset()) {
|
||||
$this->resetter->resetIndex($index, true);
|
||||
}
|
||||
|
||||
$types = array_keys($this->pagerProviderRegistry->getIndexProviders($index));
|
||||
foreach ($types as $type) {
|
||||
$this->populateIndexType($index, $type, false, $event->getOptions());
|
||||
}
|
||||
$provider = $this->pagerProviderRegistry->getProvider($index);
|
||||
|
||||
$this->dispatcher->dispatch($event, IndexPopulateEvent::POST_INDEX_POPULATE);
|
||||
$pager = $provider->provide($options);
|
||||
$options['indexName'] = $index;
|
||||
|
||||
$this->pagerPersister->insert($pager, $options);
|
||||
|
||||
$event = new PostIndexPopulateEvent($index, true, $options);
|
||||
$this->dispatcher->dispatch($event);
|
||||
|
||||
$this->refreshIndex($index);
|
||||
}
|
||||
}
|
||||
|
||||
private function populateIndexType(
|
||||
string $index,
|
||||
string $type,
|
||||
bool $reset,
|
||||
array $options
|
||||
): void
|
||||
{
|
||||
$event = new TypePopulateEvent($index, $type, $reset, $options);
|
||||
$this->dispatcher->dispatch($event, TypePopulateEvent::PRE_TYPE_POPULATE);
|
||||
|
||||
if ($event->isReset()) {
|
||||
$this->resetter->resetIndexType($index, $type);
|
||||
}
|
||||
|
||||
$provider = $this->pagerProviderRegistry->getProvider($index, $type);
|
||||
|
||||
$pager = $provider->provide($options);
|
||||
|
||||
$options['indexName'] = $index;
|
||||
$options['typeName'] = $type;
|
||||
|
||||
$this->pagerPersister->insert($pager, $options);
|
||||
|
||||
$this->dispatcher->dispatch($event, TypePopulateEvent::POST_TYPE_POPULATE);
|
||||
|
||||
$this->refreshIndex($index);
|
||||
}
|
||||
|
||||
private function refreshIndex(string $index): void
|
||||
{
|
||||
$this->indexManager->getIndex($index)->refresh();
|
||||
|
||||
Reference in New Issue
Block a user