Skip to content

Commit

Permalink
Bootstrap with PluginSkeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Jun 15, 2018
1 parent 9c36543 commit 78504bd
Show file tree
Hide file tree
Showing 46 changed files with 1,090 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/bin/*
!/bin/.gitkeep

/vendor/
/node_modules/
/composer.lock

/etc/build/*
!/etc/build/.gitkeep

/tests/Application/yarn.lock
79 changes: 79 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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
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}"

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 web --env=test -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 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"
95 changes: 94 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,94 @@
# InvoicingPlugin
<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 changes: 21 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -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
Empty file added bin/.gitkeep
Empty file.
47 changes: 47 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "sylius/plugin-skeleton",
"type": "sylius-plugin",
"description": "Acme example plugin for Sylius.",
"license": "MIT",
"require": {
"php": "^7.1",

"sylius/sylius": "~1.2.0",
"symfony/symfony": "^3.4|^4.1"
},
"require-dev": {
"behat/behat": "^3.4",
"behat/mink": "^1.7@dev",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/context-service-extension": "^1.2",
"friends-of-behat/cross-container-extension": "^1.1",
"friends-of-behat/service-container-extension": "^1.0",
"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.9.2",
"phpunit/phpunit": "^6.5",
"sylius-labs/coding-standard": "^2.0"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"Acme\\SyliusExamplePlugin\\": "src/",
"Tests\\Acme\\SyliusExamplePlugin\\": "tests/"
}
},
"autoload-dev": {
"classmap": ["tests/Application/app/AppKernel.php"]
},
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"config": {
"bin-dir": "bin"
}
}
2 changes: 2 additions & 0 deletions easy-coding-standard.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- vendor/sylius-labs/coding-standard/easy-coding-standard.neon
Empty file added etc/build/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions features/dynamically_greeting_a_customer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@greeting_customer @javascript
Feature: Dynamically greeting a customer
In order to provide an ultimate customer experience
As a Store Owner
I want to welcome new customers dynamically

Scenario: Dynamically greeting a customer with an unknown name
When a customer with an unknown name visits dynamic welcome page
Then they should be dynamically greeted with "Hello!"

Scenario: Dynamically greeting a customer with a known name
When a customer named "Krzysztof" visits dynamic welcome page
Then they should be dynamically greeted with "Hello, Krzysztof!"

Scenario: Dynamically greeting Lionel Richie
When a customer named "Lionel Richie" visits dynamic welcome page
Then they should be dynamically greeted with "Hello, is it me you're looking for?"
54 changes: 54 additions & 0 deletions features/running_a_sylius_feature.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Sylius/Sylius:features/product/managing_products/adding_products_with_text_attribute.feature

@managing_products
Feature: Adding a new product with text attribute
In order to extend my merchandise with more complex products
As an Administrator
I want to add a new product with text attribute to the shop

Background:
Given the store operates on a single channel in "United States"
And the store has a text product attribute "Gun caliber"
And the store has a text product attribute "Overall length"
And I am logged in as an administrator

@ui @javascript
Scenario: Adding a text attribute to product
Given I want to create a new simple product
When I specify its code as "44_MAGNUM"
And I name it "44 Magnum" in "English (United States)"
And I set its price to "$100.00" for "United States" channel
And I set its "Gun caliber" attribute to "11 mm" in "English (United States)"
And I add it
Then I should be notified that it has been successfully created
And the product "44 Magnum" should appear in the store
And attribute "Gun caliber" of product "44 Magnum" should be "11 mm"

@ui @javascript
Scenario: Adding multiple text attributes to product
Given I want to create a new simple product
When I specify its code as "44_MAGNUM"
And I name it "44 Magnum" in "English (United States)"
And I set its price to "$100.00" for "United States" channel
And I set its "Gun caliber" attribute to "11 mm" in "English (United States)"
And I set its "Overall length" attribute to "30.5 cm" in "English (United States)"
And I add it
Then I should be notified that it has been successfully created
And the product "44 Magnum" should appear in the store
And attribute "Gun caliber" of product "44 Magnum" should be "11 mm"
And attribute "Overall length" of product "44 Magnum" should be "30.5 cm"

@ui @javascript
Scenario: Adding and removing text attributes on product create page
Given I want to create a new simple product
When I specify its code as "44_MAGNUM"
And I name it "44 Magnum" in "English (United States)"
And I set its price to "$100.00" for "United States" channel
And I set its "Gun caliber" attribute to "11 mm" in "English (United States)"
And I set its "Overall length" attribute to "30.5 cm" in "English (United States)"
And I remove its "Gun caliber" attribute
And I add it
Then I should be notified that it has been successfully created
And the product "44 Magnum" should appear in the store
And attribute "Overall length" of product "44 Magnum" should be "30.5 cm"
And product "44 Magnum" should not have a "Gun caliber" attribute
17 changes: 17 additions & 0 deletions features/statically_greeting_a_customer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@greeting_customer
Feature: Statically greeting a customer
In order to provide an ultimate customer experience
As a Store Owner
I want to welcome new customers

Scenario: Statically greeting a customer with an unknown name
When a customer with an unknown name visits static welcome page
Then they should be statically greeted with "Hello!"

Scenario: Statically greeting a customer with a known name
When a customer named "Krzysztof" visits static welcome page
Then they should be statically greeted with "Hello, Krzysztof!"

Scenario: Statically greeting Lionel Richie
When a customer named "Lionel Richie" visits static welcome page
Then they should be statically greeted with "Hello, is it me you're looking for?"
1 change: 1 addition & 0 deletions node_modules
4 changes: 4 additions & 0 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
suites:
main:
namespace: Acme\SyliusExamplePlugin
psr4_prefix: Acme\SyliusExamplePlugin
11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -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="AcmeSyliusExamplePlugin 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>
Loading

0 comments on commit 78504bd

Please sign in to comment.