Skip to content

Commit

Permalink
Merge pull request #12 from Setono/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
igormukhingmailcom authored Mar 5, 2020
2 parents 23ec200 + b6b00b7 commit a270bda
Show file tree
Hide file tree
Showing 89 changed files with 461 additions and 827 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
!/etc/build/.gitignore

/tests/Application/yarn.lock

/behat.yml
/phpspec.yml
5 changes: 5 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
build:
environment:
php:
version: 7.4

filter:
excluded_paths:
- spec/*
Expand Down
51 changes: 7 additions & 44 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dist: trusty
sudo: false

php:
- 7.2
- '7.3'

cache:
yarn: true
Expand All @@ -15,67 +15,30 @@ cache:

env:
global:
- APP_ENV=test
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build
matrix:
- SYMFONY_VERSION="3.4.*"
- SYMFONY_VERSION="4.1.*"

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}"

- cp tests/Application/.env.test.dist tests/Application/.env.test
- set -a && source tests/Application/.env.test && set +a

install:
- composer require "symfony/symfony:${SYMFONY_VERSION}" --no-interaction --no-update
- 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 public --env=test -vvv)
- (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- (cd tests/Application && bin/console doctrine:database:create -vvv)
- (cd tests/Application && bin/console doctrine:schema:create -vvv)
- (cd tests/Application && bin/console assets:install public -vvv)
- (cd tests/Application && bin/console cache:warmup -vvv)
- (cd tests/Application && yarn build)

# 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 public --env=test --quiet > /dev/null 2>&1 &)

script:
- composer validate --strict
- composer analyse
- composer check-style
- composer phpspec
- vendor/bin/behat --tags="@setono_sylius_trustpilot" --strict -vvv --no-interaction || vendor/bin/behat --tags="@setono_sylius_trustpilot" --strict -vvv --no-interaction --rerun

after_failure:
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"
- vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun
103 changes: 18 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ return [
### Add plugin routing to application:

```yaml
# config/routes.yaml
# config/routes/setono_sylius_trustpilot.yaml
setono_sylius_trustpilot_admin:
resource: "@SetonoSyliusTrustpilotPlugin/Resources/config/admin_routing.yaml"
prefix: /admin
Expand All @@ -48,76 +48,49 @@ Here are the plugin specific changes you need to make in order to make this plug
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusTrustpilotPlugin\Model\CustomerTrustpilotAwareInterface;
use Setono\SyliusTrustpilotPlugin\Model\CustomerTrait;
use Setono\SyliusTrustpilotPlugin\Model\CustomerTrait as TrustpilotCustomerTrait;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
/**
* @ORM\Table(name="sylius_customer")
* @ORM\Entity()
*/
class Customer extends BaseCustomer implements CustomerTrustpilotAwareInterface
{
use CustomerTrait;
use TrustpilotCustomerTrait;
}
```

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- config/doctrine/Customer.orm.xml -->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="App\Entity\Customer" table="sylius_customer">
<field name="trustpilotEnabled" column="trustpilot_enabled" type="boolean">
<options>
<option name="default">1</option>
</options>
</field>
</mapped-superclass>
</doctrine-mapping>
```

```php
<?php
// src/Entity/Order.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusTrustpilotPlugin\Model\OrderTrustpilotAwareInterface;
use Setono\SyliusTrustpilotPlugin\Model\OrderTrait;
use Setono\SyliusTrustpilotPlugin\Model\OrderTrait as TrustpilotOrderTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;
/**
* @ORM\Table(name="sylius_order")
* @ORM\Entity()
*/
class Order extends BaseOrder implements OrderTrustpilotAwareInterface
{
use OrderTrait;
use TrustpilotOrderTrait;
}
```

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- config/doctrine/Order.orm.xml -->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="App\Entity\Order" table="sylius_order">
<field name="trustpilotEmailsSent" column="trustpilot_emails_sent" type="smallint">
<options>
<option name="default">0</option>
</options>
</field>
</mapped-superclass>
</doctrine-mapping>
```
### Add overrides configuration:

```yaml
# config/packages/_sylius.yml
# config/packages/setono_sylius_trustpilot.yml
imports:
- { resource: "@SetonoSyliusTrustpilotPlugin/Resources/config/app/_sylius.yaml" }
- { resource: "@SetonoSyliusTrustpilotPlugin/Resources/config/app/config.yaml" }
sylius_customer:
resources:
Expand Down Expand Up @@ -163,7 +136,7 @@ setono_sylius_trustpilot:
invites_limit: 0
```

### Put environment variable to `.env.dist`, `.env.*.dist` files:
### Put environment variable to `.env`

```bash
###> setono/sylius-trustpilot-plugin ###
Expand Down Expand Up @@ -239,46 +212,6 @@ Please run `composer all` to run all checks and tests before making PR or pushin
$ composer test
```

## Prepare to run plugin test app

```bash
cp tests/Application/.env.dist tests/Application/.env
# Put actual values to environment variables
nano tests/Application/.env
set -a && source tests/Application/.env && set +a
# OR (from tests/Application directory)
# set -a && source .env && set +a
```

## Play with plugin test app

- Run application:
(by default application have default config at `dev` environment
and example config from `Configure plugin` step at `prod` environment)

```bash
SYMFONY_ENV=dev
cd tests/Application && \
yarn install && \
yarn run gulp && \
bin/console assets:install public -e $SYMFONY_ENV && \
bin/console doctrine:database:drop --force -e $SYMFONY_ENV && \
bin/console doctrine:database:create -e $SYMFONY_ENV && \
bin/console doctrine:schema:create -e $SYMFONY_ENV && \
bin/console sylius:fixtures:load --no-interaction -e $SYMFONY_ENV && \
bin/console server:run -d public -e $SYMFONY_ENV
```

- Log in at `http://localhost:8000/admin`
with Sylius demo credentials:

```
Login: sylius@example.com
Password: sylius
```

[ico-version]: https://img.shields.io/packagist/v/setono/sylius-trustpilot-plugin.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/Setono/SyliusTrustpilotPlugin/master.svg?style=flat-square
Expand Down
53 changes: 39 additions & 14 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
imports:
- vendor/sylius/sylius/behat.yml.dist
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- 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
Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true

Behat\MinkExtension:
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
base_url: "http://localhost:8080/"
default_session: symfony
javascript_session: chrome
sessions:
symfony:
symfony: ~
chrome:
selenium2:
browser: chrome
capabilities:
browserName: chrome
browser: chrome
version: ""
marionette: null # https://github.com/Behat/MinkExtension/pull/311
chrome:
switches:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
extra_capabilities:
unexpectedAlertBehaviour: accept
firefox:
selenium2:
browser: firefox
show_auto: false

FriendsOfBehat\SymfonyExtension:
env_file: tests/Application/.env.test
bootstrap: tests/Application/config/bootstrap.php
kernel:
env: test
debug: true
class: Tests\Setono\SyliusTrustpilotPlugin\Application\Kernel
path: tests/Application/Kernel.php
bootstrap: ~

Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true
FriendsOfBehat\VariadicExtension: ~

FriendsOfBehat\SuiteSettingsExtension:
paths:
- "features"
Loading

0 comments on commit a270bda

Please sign in to comment.