mirror of
https://github.com/jbcr/SyliusElasticsearchPlugin.git
synced 2026-03-24 00:42:08 +01:00
init
This commit is contained in:
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/bin/*
|
||||
!/bin/.gitkeep
|
||||
|
||||
/vendor/
|
||||
/node_modules/
|
||||
/composer.lock
|
||||
|
||||
/etc/build/*
|
||||
!/etc/build/.gitkeep
|
||||
|
||||
/tests/Application/yarn.lock
|
||||
75
.travis.yml
Normal file
75
.travis.yml
Normal file
@@ -0,0 +1,75 @@
|
||||
language: php
|
||||
|
||||
dist: trusty
|
||||
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- 7.1
|
||||
- 7.2
|
||||
|
||||
cache:
|
||||
yarn: true
|
||||
directories:
|
||||
- ~/.composer/cache/files
|
||||
- $SYLIUS_CACHE_DIR
|
||||
|
||||
env:
|
||||
global:
|
||||
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
|
||||
- SYLIUS_BUILD_DIR=etc/build
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini
|
||||
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- mkdir -p "${SYLIUS_CACHE_DIR}"
|
||||
|
||||
install:
|
||||
- composer install --no-interaction --prefer-dist
|
||||
- (cd tests/Application && yarn install)
|
||||
|
||||
before_script:
|
||||
- (cd tests/Application && bin/console doctrine:database:create --env=test -vvv)
|
||||
- (cd tests/Application && bin/console doctrine:schema:create --env=test -vvv)
|
||||
- (cd tests/Application && bin/console assets:install web --env=test -vvv)
|
||||
- (cd tests/Application && yarn run gulp)
|
||||
|
||||
# Configure display
|
||||
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1680x1050x16
|
||||
- export DISPLAY=:99
|
||||
|
||||
# Download and configure ChromeDriver
|
||||
- |
|
||||
if [ ! -f $SYLIUS_CACHE_DIR/chromedriver ] || [ "$($SYLIUS_CACHE_DIR/chromedriver --version | grep -c 2.34)" = "0" ]; then
|
||||
curl http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip > chromedriver.zip
|
||||
unzip chromedriver.zip
|
||||
chmod +x chromedriver
|
||||
mv chromedriver $SYLIUS_CACHE_DIR
|
||||
fi
|
||||
|
||||
# Run ChromeDriver
|
||||
- $SYLIUS_CACHE_DIR/chromedriver > /dev/null 2>&1 &
|
||||
|
||||
# Download and configure Selenium
|
||||
- |
|
||||
if [ ! -f $SYLIUS_CACHE_DIR/selenium.jar ] || [ "$(java -jar $SYLIUS_CACHE_DIR/selenium.jar --version | grep -c 3.4.0)" = "0" ]; then
|
||||
curl http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar > selenium.jar
|
||||
mv selenium.jar $SYLIUS_CACHE_DIR
|
||||
fi
|
||||
|
||||
# Run Selenium
|
||||
- java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar > /dev/null 2>&1 &
|
||||
|
||||
# Run webserver
|
||||
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web --env=test --quiet > /dev/null 2>&1 &)
|
||||
|
||||
script:
|
||||
- composer validate --strict
|
||||
- bin/phpstan.phar analyse -c phpstan.neon -l max src/
|
||||
|
||||
- bin/phpunit
|
||||
- bin/phpspec run
|
||||
- bin/behat --strict -vvv --no-interaction || bin/behat --strict -vvv --no-interaction --rerun
|
||||
|
||||
after_failure:
|
||||
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"
|
||||
94
README.md
Normal file
94
README.md
Normal file
@@ -0,0 +1,94 @@
|
||||
<p align="center">
|
||||
<a href="http://sylius.org" target="_blank">
|
||||
<img src="http://demo.sylius.org/assets/shop/img/logo.png" />
|
||||
</a>
|
||||
</p>
|
||||
<h1 align="center">Plugin Skeleton</h1>
|
||||
<p align="center">
|
||||
<a href="https://packagist.org/packages/sylius/plugin-skeleton" title="License">
|
||||
<img src="https://img.shields.io/packagist/l/sylius/plugin-skeleton.svg" />
|
||||
</a>
|
||||
<a href="https://packagist.org/packages/sylius/plugin-skeleton" title="Version">
|
||||
<img src="https://img.shields.io/packagist/v/sylius/plugin-skeleton.svg" />
|
||||
</a>
|
||||
<a href="http://travis-ci.org/Sylius/PluginSkeleton" title="Build status">
|
||||
<img src="https://img.shields.io/travis/Sylius/PluginSkeleton/master.svg" />
|
||||
</a>
|
||||
<a href="https://scrutinizer-ci.com/g/Sylius/PluginSkeleton/" title="Scrutinizer">
|
||||
<img src="https://img.shields.io/scrutinizer/g/Sylius/PluginSkeleton.svg" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Installation
|
||||
|
||||
1. Run `composer create-project sylius/plugin-skeleton ProjectName`.
|
||||
|
||||
2. From the plugin skeleton root directory, run the following commands:
|
||||
|
||||
```bash
|
||||
$ (cd tests/Application && yarn install)
|
||||
$ (cd tests/Application && yarn run gulp)
|
||||
$ (cd tests/Application && bin/console assets:install web -e test)
|
||||
|
||||
$ (cd tests/Application && bin/console doctrine:database:create -e test)
|
||||
$ (cd tests/Application && bin/console doctrine:schema:create -e test)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Running plugin tests
|
||||
|
||||
- PHPUnit
|
||||
|
||||
```bash
|
||||
$ bin/phpunit
|
||||
```
|
||||
|
||||
- PHPSpec
|
||||
|
||||
```bash
|
||||
$ bin/phpspec run
|
||||
```
|
||||
|
||||
- Behat (non-JS scenarios)
|
||||
|
||||
```bash
|
||||
$ bin/behat --tags="~@javascript"
|
||||
```
|
||||
|
||||
- Behat (JS scenarios)
|
||||
|
||||
1. Download [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)
|
||||
|
||||
2. Run Selenium server with previously downloaded Chromedriver:
|
||||
|
||||
```bash
|
||||
$ bin/selenium-server-standalone -Dwebdriver.chrome.driver=chromedriver
|
||||
```
|
||||
3. Run test application's webserver on `localhost:8080`:
|
||||
|
||||
```bash
|
||||
$ (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web -e test)
|
||||
```
|
||||
|
||||
4. Run Behat:
|
||||
|
||||
```bash
|
||||
$ bin/behat --tags="@javascript"
|
||||
```
|
||||
|
||||
### Opening Sylius with your plugin
|
||||
|
||||
- Using `test` environment:
|
||||
|
||||
```bash
|
||||
$ (cd tests/Application && bin/console sylius:fixtures:load -e test)
|
||||
$ (cd tests/Application && bin/console server:run -d web -e test)
|
||||
```
|
||||
|
||||
- Using `dev` environment:
|
||||
|
||||
```bash
|
||||
$ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
|
||||
$ (cd tests/Application && bin/console server:run -d web -e dev)
|
||||
```
|
||||
21
behat.yml.dist
Normal file
21
behat.yml.dist
Normal file
@@ -0,0 +1,21 @@
|
||||
imports:
|
||||
- vendor/sylius/sylius/behat.yml.dist
|
||||
- tests/Behat/Resources/suites.yml
|
||||
|
||||
default:
|
||||
extensions:
|
||||
FriendsOfBehat\ContextServiceExtension:
|
||||
imports:
|
||||
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml
|
||||
- tests/Behat/Resources/services.xml
|
||||
|
||||
FriendsOfBehat\SymfonyExtension:
|
||||
kernel:
|
||||
class: AppKernel
|
||||
path: tests/Application/app/AppKernel.php
|
||||
bootstrap: vendor/autoload.php
|
||||
|
||||
Lakion\Behat\MinkDebugExtension:
|
||||
directory: etc/build
|
||||
clean_start: false
|
||||
screenshot: true
|
||||
0
bin/.gitkeep
Normal file
0
bin/.gitkeep
Normal file
49
composer.json
Normal file
49
composer.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "sylius/plugin-skeleton",
|
||||
"type": "sylius-plugin",
|
||||
"description": "Acme example plugin for Sylius.",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.1",
|
||||
|
||||
"sylius/sylius": "^1.2@dev",
|
||||
"friendsofsymfony/elastica-bundle": "^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"behat/behat": "^3.3",
|
||||
"behat/mink": "^1.7",
|
||||
"behat/mink-browserkit-driver": "^1.3",
|
||||
"behat/mink-extension": "^2.2",
|
||||
"behat/mink-selenium2-driver": "^1.3",
|
||||
"friends-of-behat/context-service-extension": "^1.0",
|
||||
"friends-of-behat/cross-container-extension": "^1.0",
|
||||
"friends-of-behat/service-container-extension": "^1.0",
|
||||
"friends-of-behat/symfony-extension": "^1.0",
|
||||
"friends-of-behat/variadic-extension": "^1.0",
|
||||
"lakion/mink-debug-extension": "^1.2.3",
|
||||
"phpspec/phpspec": "^3.2",
|
||||
"phpstan/phpstan-shim": "^0.9.2",
|
||||
"phpunit/phpunit": "^5.6",
|
||||
"se/selenium-server-standalone": "^2.52",
|
||||
"sylius-labs/coding-standard": "^1.0",
|
||||
"symplify/easy-coding-standard": "^2.4"
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"BitBag\\SyliusElasticsearchPlugin\\": "src/",
|
||||
"Tests\\BitBag\\SyliusElasticsearchPlugin\\": "tests/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": ["tests/Application/app/AppKernel.php"]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
}
|
||||
}
|
||||
2
easy-coding-standard.neon
Normal file
2
easy-coding-standard.neon
Normal file
@@ -0,0 +1,2 @@
|
||||
includes:
|
||||
- vendor/sylius-labs/coding-standard/easy-coding-standard.neon
|
||||
0
etc/build/.gitkeep
Normal file
0
etc/build/.gitkeep
Normal file
1
node_modules
Symbolic link
1
node_modules
Symbolic link
@@ -0,0 +1 @@
|
||||
tests/Application/node_modules
|
||||
4
phpspec.yml.dist
Normal file
4
phpspec.yml.dist
Normal file
@@ -0,0 +1,4 @@
|
||||
suites:
|
||||
main:
|
||||
namespace: BitBag\SyliusElasticsearchPlugin
|
||||
psr4_prefix: BitBag\SyliusElasticsearchPlugin
|
||||
11
phpstan.neon
Normal file
11
phpstan.neon
Normal file
@@ -0,0 +1,11 @@
|
||||
parameters:
|
||||
excludes_analyse:
|
||||
# Makes PHPStan crash
|
||||
- 'src/DependencyInjection/Configuration.php'
|
||||
|
||||
# Test dependencies
|
||||
- 'tests/Application/app/**.php'
|
||||
- 'tests/Application/src/**.php'
|
||||
|
||||
ignoreErrors:
|
||||
- '/Parameter #1 $configuration of method Symfony\Component\DependencyInjection\Extension\Extension::processConfiguration() expects Symfony\Component\Config\Definition\ConfigurationInterface, Symfony\Component\Config\Definition\ConfigurationInterface|null given./'
|
||||
18
phpunit.xml.dist
Normal file
18
phpunit.xml.dist
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.6/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="BitBagSyliusElasticSearchPlugin Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<php>
|
||||
<server name="KERNEL_CLASS_PATH" value="/tests/Application/AppKernel.php" />
|
||||
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
|
||||
</php>
|
||||
</phpunit>
|
||||
13
src/BitBagSyliusElasticSearchPlugin.php
Normal file
13
src/BitBagSyliusElasticSearchPlugin.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
final class BitBagSyliusElasticSearchPlugin extends Bundle
|
||||
{
|
||||
use SyliusPluginTrait;
|
||||
}
|
||||
66
src/EventListener/ProductOptionsPropertyListener.php
Normal file
66
src/EventListener/ProductOptionsPropertyListener.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file has been created by developers from BitBag.
|
||||
* Feel free to contact us once you face any issues or want to start
|
||||
* another great project.
|
||||
* You can find more information about us on https://bitbag.shop and write us
|
||||
* an email on mikolaj.krol@bitbag.pl.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
|
||||
|
||||
use Elastica\Document;
|
||||
use FOS\ElasticaBundle\Event\TransformEvent;
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
final class ProductOptionsPropertyListener implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @param TransformEvent $event
|
||||
*/
|
||||
public function addProductOptionProperty(TransformEvent $event): void
|
||||
{
|
||||
/** @var ProductInterface $product */
|
||||
$product = $event->getObject();
|
||||
$document = $event->getDocument();
|
||||
|
||||
$this->resolveProductOptions($product, $document);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
TransformEvent::POST_TRANSFORM => 'addProductOptionProperty',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProductInterface $product
|
||||
* @param Document $document
|
||||
*/
|
||||
private function resolveProductOptions(ProductInterface $product, Document $document): void
|
||||
{
|
||||
foreach ($product->getVariants() as $productVariant) {
|
||||
foreach ($productVariant->getOptionValues() as $productOptionValue) {
|
||||
$optionCode = $productOptionValue->getOption()->getCode();
|
||||
$index = 'option_' . $optionCode;
|
||||
|
||||
if (!$document->has($index)) {
|
||||
$document->set($index, []);
|
||||
}
|
||||
|
||||
$reference = $document->get($index);
|
||||
$reference[] = $productOptionValue->getValue();
|
||||
|
||||
$document->set($index, $reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
src/Resources/config/config.yml
Normal file
57
src/Resources/config/config.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
imports:
|
||||
- { resource: "@BitBagSyliusElasticSearchPlugin/Resources/config/services.yml" }
|
||||
|
||||
parameters:
|
||||
elasticsearch_host: localhost
|
||||
elasticsearch_port: 9200
|
||||
|
||||
fos_elastica:
|
||||
clients:
|
||||
default:
|
||||
host: "%elasticsearch_host%"
|
||||
port: "%elasticsearch_port%"
|
||||
indexes:
|
||||
bitbag:
|
||||
index_name: "bitbag_%kernel.environment%"
|
||||
types:
|
||||
product:
|
||||
properties:
|
||||
code: ~
|
||||
name: ~
|
||||
enabled: ~
|
||||
shortDescription: ~
|
||||
options:
|
||||
property_path: false
|
||||
# variants:
|
||||
# code: ~
|
||||
# name: ~
|
||||
# onHand: ~
|
||||
# onHold: ~
|
||||
# tracked: ~
|
||||
# optionValues:
|
||||
# type: nested
|
||||
# properties:
|
||||
# value: ~
|
||||
# channelPricings:
|
||||
# property_path: variants.first.channelPricings
|
||||
# type: nested
|
||||
# properties:
|
||||
# channelCode: ~
|
||||
# price: ~
|
||||
# channels:
|
||||
# type: nested
|
||||
# properties:
|
||||
# name: ~
|
||||
# attributes:
|
||||
# type: nested
|
||||
# properties:
|
||||
# value: ~
|
||||
# type: ~
|
||||
persistence:
|
||||
driver: orm
|
||||
model: "%sylius.model.product.class%"
|
||||
listener:
|
||||
defer: true
|
||||
logger: true
|
||||
elastica_to_model_transformer:
|
||||
ignore_missing: true
|
||||
0
src/Resources/config/routing.yml
Normal file
0
src/Resources/config/routing.yml
Normal file
5
src/Resources/config/services.yml
Normal file
5
src/Resources/config/services.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
bitbag_sylius_elasticsearch_plugin.event_listener.product_options_property:
|
||||
class: BitBag\SyliusElasticsearchPlugin\EventListener\ProductOptionsPropertyListener
|
||||
tags:
|
||||
- { name: kernel.event_subscriber }
|
||||
9
tests/Application/.gitignore
vendored
Normal file
9
tests/Application/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/node_modules/
|
||||
|
||||
/var/*
|
||||
!/var/.gitkeep
|
||||
|
||||
/web/*
|
||||
!/web/app.php
|
||||
!/web/app_dev.php
|
||||
!/web/app_test.php
|
||||
24
tests/Application/Gulpfile.js
Normal file
24
tests/Application/Gulpfile.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var gulp = require('gulp');
|
||||
var chug = require('gulp-chug');
|
||||
var argv = require('yargs').argv;
|
||||
|
||||
config = [
|
||||
'--rootPath',
|
||||
argv.rootPath || '../../../../../../../tests/Application/web/assets/',
|
||||
'--nodeModulesPath',
|
||||
argv.nodeModulesPath || '../../../../../../../tests/Application/node_modules/'
|
||||
];
|
||||
|
||||
gulp.task('admin', function() {
|
||||
gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Gulpfile.js', { read: false })
|
||||
.pipe(chug({ args: config }))
|
||||
;
|
||||
});
|
||||
|
||||
gulp.task('shop', function() {
|
||||
gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Gulpfile.js', { read: false })
|
||||
.pipe(chug({ args: config }))
|
||||
;
|
||||
});
|
||||
|
||||
gulp.task('default', ['admin', 'shop']);
|
||||
34
tests/Application/app/AppKernel.php
Normal file
34
tests/Application/app/AppKernel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Application\Kernel;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
||||
final class AppKernel extends Kernel
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function registerBundles(): array
|
||||
{
|
||||
return array_merge(parent::registerBundles(), [
|
||||
new \Sylius\Bundle\AdminBundle\SyliusAdminBundle(),
|
||||
new \Sylius\Bundle\ShopBundle\SyliusShopBundle(),
|
||||
|
||||
new \FOS\OAuthServerBundle\FOSOAuthServerBundle(), // Required by SyliusApiBundle
|
||||
new \Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle(),
|
||||
|
||||
new \FOS\ElasticaBundle\FOSElasticaBundle(),
|
||||
new \BitBag\SyliusElasticsearchPlugin\BitBagSyliusElasticSearchPlugin(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function registerContainerConfiguration(LoaderInterface $loader): void
|
||||
{
|
||||
$loader->load($this->getRootDir() . '/config/config.yml');
|
||||
}
|
||||
}
|
||||
68
tests/Application/app/config/config.yml
Normal file
68
tests/Application/app/config/config.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
parameters:
|
||||
locale: en_US
|
||||
secret: "Heron is the best animal in the world!"
|
||||
|
||||
imports:
|
||||
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" }
|
||||
|
||||
- { resource: "@BitBagSyliusElasticSearchPlugin/Resources/config/config.yml" }
|
||||
|
||||
- { resource: "../../../../vendor/sylius/sylius/app/config/security.yml" }
|
||||
|
||||
framework:
|
||||
translator: { fallbacks: ["%locale%", "en"] }
|
||||
secret: "%secret"
|
||||
router:
|
||||
resource: "%kernel.root_dir%/config/routing.yml"
|
||||
strict_requirements: "%kernel.debug%"
|
||||
form: true
|
||||
csrf_protection: true
|
||||
validation: { enable_annotations: true }
|
||||
templating: { engines: ["twig"] }
|
||||
default_locale: "%locale%"
|
||||
trusted_proxies: ~
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
||||
test: ~
|
||||
|
||||
monolog:
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
firephp:
|
||||
type: firephp
|
||||
level: info
|
||||
|
||||
swiftmailer:
|
||||
disable_delivery: true
|
||||
logging: true
|
||||
spool:
|
||||
type: file
|
||||
path: "%kernel.cache_dir%/spool"
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: "pdo_sqlite"
|
||||
path: "%kernel.root_dir%/../var/db.sql"
|
||||
charset: UTF8
|
||||
|
||||
fos_rest:
|
||||
exception: ~
|
||||
view:
|
||||
formats:
|
||||
json: true
|
||||
xml: true
|
||||
empty_content: 204
|
||||
format_listener:
|
||||
rules:
|
||||
- { path: '^/api', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
|
||||
- { path: '^/', stop: true }
|
||||
|
||||
sylius_theme:
|
||||
sources:
|
||||
test: ~
|
||||
6
tests/Application/app/config/config_dev.yml
Normal file
6
tests/Application/app/config/config_dev.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
imports:
|
||||
- { resource: "config.yml" }
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
path: "%kernel.root_dir%/../var/db_dev.sql"
|
||||
13
tests/Application/app/config/config_prod.yml
Normal file
13
tests/Application/app/config/config_prod.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
imports:
|
||||
- { resource: "config.yml" }
|
||||
|
||||
monolog:
|
||||
handlers:
|
||||
main:
|
||||
type: fingers_crossed
|
||||
action_level: error
|
||||
handler: nested
|
||||
nested:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
6
tests/Application/app/config/config_test.yml
Normal file
6
tests/Application/app/config/config_test.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
imports:
|
||||
- { resource: "config.yml" }
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
path: "%kernel.root_dir%/../var/db_test.sql"
|
||||
7
tests/Application/app/config/routing.yml
Normal file
7
tests/Application/app/config/routing.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
sylius:
|
||||
resource: "../../../../vendor/sylius/sylius/app/config/routing.yml"
|
||||
|
||||
# Put your own routes here
|
||||
|
||||
bitbag_sylius_elasticsearch_plugin:
|
||||
resource: "@BitBagSyliusElasticSearchPlugin/Resources/config/routing.yml"
|
||||
27
tests/Application/bin/console
Executable file
27
tests/Application/bin/console
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
|
||||
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
|
||||
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
||||
// for more information
|
||||
//umask(0000);
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$input = new ArgvInput();
|
||||
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
|
||||
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
|
||||
|
||||
if ($debug) {
|
||||
Debug::enable();
|
||||
}
|
||||
|
||||
$kernel = new AppKernel($env, $debug);
|
||||
$application = new Application($kernel);
|
||||
$application->run($input);
|
||||
32
tests/Application/package.json
Normal file
32
tests/Application/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"jquery": "^3.2.0",
|
||||
"lightbox2": "^2.9.0",
|
||||
"semantic-ui-css": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-chug": "^0.5",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"gulp-debug": "^2.1.2",
|
||||
"gulp-if": "^2.0.0",
|
||||
"gulp-livereload": "^3.8.1",
|
||||
"gulp-order": "^1.1.1",
|
||||
"gulp-sass": "^2.3.0",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"gulp-uglify": "^1.5.1",
|
||||
"gulp-uglifycss": "^1.0.5",
|
||||
"merge-stream": "^1.0.0",
|
||||
"node-sass": "^4.5.3",
|
||||
"yargs": "^6.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"gulp": "gulp"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Sylius/Sylius.git"
|
||||
},
|
||||
"author": "Paweł Jędrzejewski",
|
||||
"license": "MIT"
|
||||
}
|
||||
0
tests/Application/var/.gitkeep
Normal file
0
tests/Application/var/.gitkeep
Normal file
16
tests/Application/web/app.php
Normal file
16
tests/Application/web/app.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$kernel = new AppKernel('prod', false);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
19
tests/Application/web/app_dev.php
Normal file
19
tests/Application/web/app_dev.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
Debug::enable();
|
||||
|
||||
$kernel = new AppKernel('dev', true);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
19
tests/Application/web/app_test.php
Normal file
19
tests/Application/web/app_test.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
Debug::enable();
|
||||
|
||||
$kernel = new AppKernel('test', true);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
80
tests/Behat/Context/Ui/Shop/WelcomeContext.php
Normal file
80
tests/Behat/Context/Ui/Shop/WelcomeContext.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\BitBag\SyliusElasticsearchPlugin\Behat\Context\Ui\Shop;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Tests\BitBag\SyliusElasticsearchPlugin\Behat\Page\Shop\WelcomePageInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class WelcomeContext implements Context
|
||||
{
|
||||
/**
|
||||
* @var WelcomePageInterface
|
||||
*/
|
||||
private $staticWelcomePage;
|
||||
|
||||
/**
|
||||
* @var WelcomePageInterface
|
||||
*/
|
||||
private $dynamicWelcomePage;
|
||||
|
||||
/**
|
||||
* @param WelcomePageInterface $staticWelcomePage
|
||||
* @param WelcomePageInterface $dynamicWelcomePage
|
||||
*/
|
||||
public function __construct(WelcomePageInterface $staticWelcomePage, WelcomePageInterface $dynamicWelcomePage)
|
||||
{
|
||||
$this->staticWelcomePage = $staticWelcomePage;
|
||||
$this->dynamicWelcomePage = $dynamicWelcomePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @When a customer with an unknown name visits static welcome page
|
||||
*/
|
||||
public function customerWithUnknownNameVisitsStaticWelcomePage(): void
|
||||
{
|
||||
$this->staticWelcomePage->open();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When a customer named :name visits static welcome page
|
||||
*/
|
||||
public function namedCustomerVisitsStaticWelcomePage(string $name): void
|
||||
{
|
||||
$this->staticWelcomePage->open(['name' => $name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then they should be statically greeted with :greeting
|
||||
*/
|
||||
public function theyShouldBeStaticallyGreetedWithGreeting(string $greeting): void
|
||||
{
|
||||
Assert::same($this->staticWelcomePage->getGreeting(), $greeting);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When a customer with an unknown name visits dynamic welcome page
|
||||
*/
|
||||
public function customerWithUnknownNameVisitsDynamicWelcomePage(): void
|
||||
{
|
||||
$this->dynamicWelcomePage->open();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When a customer named :name visits dynamic welcome page
|
||||
*/
|
||||
public function namedCustomerVisitsDynamicWelcomePage(string $name): void
|
||||
{
|
||||
$this->dynamicWelcomePage->open(['name' => $name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then they should be dynamically greeted with :greeting
|
||||
*/
|
||||
public function theyShouldBeDynamicallyGreetedWithGreeting(string $greeting): void
|
||||
{
|
||||
Assert::same($this->dynamicWelcomePage->getGreeting(), $greeting);
|
||||
}
|
||||
}
|
||||
44
tests/Behat/Page/Shop/DynamicWelcomePage.php
Normal file
44
tests/Behat/Page/Shop/DynamicWelcomePage.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\BitBag\SyliusElasticsearchPlugin\Behat\Page\Shop;
|
||||
|
||||
use Sylius\Behat\Page\SymfonyPage;
|
||||
|
||||
class DynamicWelcomePage extends SymfonyPage implements WelcomePageInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getGreeting(): string
|
||||
{
|
||||
return $this->getSession()->getPage()->waitFor(3, function (): string {
|
||||
$greeting = $this->getElement('greeting')->getText();
|
||||
|
||||
if ('Loading...' === $greeting) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $greeting;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteName(): string
|
||||
{
|
||||
return 'acme_sylius_example_dynamic_welcome';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefinedElements(): array
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'greeting' => '#greeting',
|
||||
]);
|
||||
}
|
||||
}
|
||||
36
tests/Behat/Page/Shop/StaticWelcomePage.php
Normal file
36
tests/Behat/Page/Shop/StaticWelcomePage.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\BitBag\SyliusElasticsearchPlugin\Behat\Page\Shop;
|
||||
|
||||
use Sylius\Behat\Page\SymfonyPage;
|
||||
|
||||
class StaticWelcomePage extends SymfonyPage implements WelcomePageInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getGreeting(): string
|
||||
{
|
||||
return $this->getElement('greeting')->getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteName(): string
|
||||
{
|
||||
return 'acme_sylius_example_static_welcome';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefinedElements(): array
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'greeting' => '#greeting',
|
||||
]);
|
||||
}
|
||||
}
|
||||
15
tests/Behat/Page/Shop/WelcomePageInterface.php
Normal file
15
tests/Behat/Page/Shop/WelcomePageInterface.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\BitBag\SyliusElasticsearchPlugin\Behat\Page\Shop;
|
||||
|
||||
use Sylius\Behat\Page\PageInterface;
|
||||
|
||||
interface WelcomePageInterface extends PageInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGreeting(): string;
|
||||
}
|
||||
16
tests/Behat/Resources/services.xml
Normal file
16
tests/Behat/Resources/services.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<services>
|
||||
<!-- Put your Behat services here -->
|
||||
|
||||
<service id="acme_sylius_example.context.ui.shop.welcome" class="Tests\BitBag\SyliusElasticsearchPlugin\Behat\Context\Ui\Shop\WelcomeContext">
|
||||
<argument type="service" id="acme_sylius_example.page.shop.static_welcome" />
|
||||
<argument type="service" id="acme_sylius_example.page.shop.dynamic_welcome" />
|
||||
<tag name="fob.context_service" />
|
||||
</service>
|
||||
|
||||
<service id="acme_sylius_example.page.shop.static_welcome" class="Tests\BitBag\SyliusElasticsearchPlugin\Behat\Page\Shop\StaticWelcomePage" parent="sylius.behat.symfony_page" public="false" />
|
||||
<service id="acme_sylius_example.page.shop.dynamic_welcome" class="Tests\BitBag\SyliusElasticsearchPlugin\Behat\Page\Shop\DynamicWelcomePage" parent="sylius.behat.symfony_page" public="false" />
|
||||
</services>
|
||||
</container>
|
||||
10
tests/Behat/Resources/suites.yml
Normal file
10
tests/Behat/Resources/suites.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
# Put your Behat suites definitions here
|
||||
|
||||
default:
|
||||
suites:
|
||||
greeting_customer:
|
||||
contexts_services:
|
||||
- acme_sylius_example.context.ui.shop.welcome
|
||||
|
||||
filters:
|
||||
tags: "@greeting_customer"
|
||||
Reference in New Issue
Block a user