Skip to content

Commit

Permalink
Updated test enviroment and CI for Sylius v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
techbech committed Nov 6, 2018
1 parent 905f8ed commit 6fe6b8f
Show file tree
Hide file tree
Showing 83 changed files with 961 additions and 152 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -5,7 +5,6 @@ dist: trusty
sudo: false

php:
- 7.1
- 7.2

cache:
Expand All @@ -19,7 +18,6 @@ env:
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build
matrix:
- SYMFONY_VERSION="3.4.*"
- SYMFONY_VERSION="4.1.*"

before_install:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -118,6 +118,9 @@ You need to override the template displaying the product form and add a `form_ro

If you haven't overridden the template yet, you can just copy the template from `vendor/loevgaard/sylius-brand-plugin/src/Resources/views/SyliusAdminBundle` to `app/Resources/SyliusAdminBundle/views/`

## Installation and usage for plugin development
[Find more information here](install-dev.md)

## Contribute by translating
We use the same service as Sylius for translating, namely [Crowdin](https://crowdin.com/project/sylius-brand-plugin). You can help out by translating this project into your mother tongue ;)

Expand Down
9 changes: 6 additions & 3 deletions behat.yml.dist
Expand Up @@ -10,10 +10,13 @@ default:
- tests/Behat/Resources/services.xml

FriendsOfBehat\SymfonyExtension:
env_file: tests/Application/.env.test
kernel:
class: AppKernel
path: tests/Application/app/AppKernel.php
bootstrap: vendor/autoload.php
env: test
debug: true
class: Tests\Loevgaard\SyliusBrandPlugin\Application\Kernel
path: tests/Application/Kernel.php
bootstrap: ~

Lakion\Behat\MinkDebugExtension:
directory: etc/build
Expand Down
25 changes: 16 additions & 9 deletions composer.json
Expand Up @@ -4,8 +4,8 @@
"description": "A Sylius plugin for handling brands",
"license": "MIT",
"require": {
"php": "^7.1",
"sylius/sylius": "~1.3.0"
"php": "^7.2",
"sylius/sylius": "~1.3.0@dev"
},
"require-dev": {
"behat/behat": "^3.4",
Expand All @@ -19,10 +19,20 @@
"friends-of-behat/symfony-extension": "^1.2.1",
"friends-of-behat/variadic-extension": "^1.1",
"lakion/mink-debug-extension": "^1.2.3",
"phpspec/phpspec": "^4.0",
"phpstan/phpstan-shim": "^0.10.0",
"phpspec/phpspec": "^5.0",
"phpstan/phpstan-doctrine": "^0.10",
"phpstan/phpstan-shim": "^0.10",
"phpstan/phpstan-symfony": "^0.10",
"phpstan/phpstan-webmozart-assert": "^0.10",
"phpunit/phpunit": "^6.5",
"sylius-labs/coding-standard": "^2.0"
"sensiolabs/security-checker": "^5.0",
"sylius-labs/coding-standard": "^2.0",
"symfony/browser-kit": "^3.4|^4.1",
"symfony/debug-bundle": "^3.4|^4.1",
"symfony/dotenv": "^3.4|^4.1",
"symfony/intl": "^3.4|^4.1",
"symfony/web-profiler-bundle": "^3.4|^4.1",
"symfony/web-server-bundle": "^3.4|^4.1"
},
"prefer-stable": true,
"autoload": {
Expand All @@ -31,12 +41,9 @@
"Tests\\Loevgaard\\SyliusBrandPlugin\\": "tests/"
}
},
"autoload-dev": {
"classmap": ["tests/Application/app/AppKernel.php"]
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.3-dev"
}
},
"config": {
Expand Down
86 changes: 86 additions & 0 deletions install-dev.md
@@ -0,0 +1,86 @@
<p align="center">
<a href="https://sylius.com" target="_blank">
<img src="https://demo.sylius.com/assets/shop/img/logo.png" />
</a>
</p>

<h1 align="center">Plugin Skeleton</h1>

<p align="center">Skeleton for starting Sylius plugins.</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 build)
$ (cd tests/Application && bin/console assets:install public -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
$ vendor/bin/phpunit
```

- PHPSpec

```bash
$ vendor/bin/phpspec run
```

- Behat (non-JS scenarios)

```bash
$ vendor/bin/behat --tags="~@javascript"
```

- Behat (JS scenarios)

1. Download [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)

2. Download [Selenium Standalone Server](https://www.seleniumhq.org/download/).

2. Run Selenium server with previously downloaded Chromedriver:

```bash
$ java -Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone.jar
```
3. Run test application's webserver on `localhost:8080`:

```bash
$ (cd tests/Application && bin/console server:run localhost:8080 -d public -e test)
```

4. Run Behat:

```bash
$ vendor/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 public -e test)
```

- Using `dev` environment:

```bash
$ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
$ (cd tests/Application && bin/console server:run -d public -e dev)
```
5 changes: 0 additions & 5 deletions tests/Application/.babelrc
Expand Up @@ -10,11 +10,6 @@
"plugins": [
["transform-object-rest-spread", {
"useBuiltIns": true
}],
["transform-runtime", {
"helpers": true,
"polyfill": true,
"regenerator": true
}]
]
}
23 changes: 23 additions & 0 deletions tests/Application/.env.dist
@@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=EDITME
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###
23 changes: 23 additions & 0 deletions tests/Application/.env.prod.dist
@@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=prod
APP_DEBUG=0
APP_SECRET=EDITME
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###
23 changes: 23 additions & 0 deletions tests/Application/.env.test.dist
@@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=test
APP_DEBUG=1
APP_SECRET=EDITME
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
29 changes: 18 additions & 11 deletions tests/Application/.eslintrc.js
@@ -1,13 +1,20 @@
module.exports = {
extends: 'airbnb-base',
rules: {
'function-paren-newline': ['error', 'consistent'],
'max-len': ['warn', 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
},
extends: 'airbnb-base',
env: {
node: true,
},
rules: {
'object-shorthand': ['error', 'always', {
avoidQuotes: true,
avoidExplicitReturnArrows: true,
}],
'function-paren-newline': ['error', 'consistent'],
'max-len': ['warn', 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
},
};
23 changes: 16 additions & 7 deletions tests/Application/.gitignore
@@ -1,9 +1,18 @@
/node_modules/

/var/*
!/var/.gitkeep
!/var/.gitignore

/public/assets
/public/bundles
/public/css
/public/js
/public/media
!/public/media/image/.gitignore

/vendor
/node_modules

/web/*
!/web/app.php
!/web/app_dev.php
!/web/app_test.php
/.env
/.env.prod
/.env.staging
/.env.test
/.env.test_cached

0 comments on commit 6fe6b8f

Please sign in to comment.