Skip to content

Commit 7f4354a

Browse files
committed
Improves test application and README
1 parent 59e0e06 commit 7f4354a

File tree

5 files changed

+133
-16
lines changed

5 files changed

+133
-16
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ before_script:
7272

7373
script:
7474
- composer validate --strict
75-
- vendor/bin/phpstan analyse -c phpstan.neon -l max src/
76-
77-
- vendor/bin/phpunit
78-
- vendor/bin/phpspec run
79-
- vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun
75+
- composer suite
8076

8177
after_failure:
8278
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"

README.md

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,136 @@
1212

1313
1. Run `composer require webgriffe/sylius-table-rate-shipping-plugin`.
1414

15-
2. TODO
15+
2. Add the plugin to the `config/bundles.php` file:
16+
17+
```php
18+
Webgriffe\SyliusTableRateShippingPlugin\WebgriffeSyliusTableRateShippingPlugin::class => ['all' => true],
19+
```
20+
21+
3. Add the plugin's config to by creating the file `config/packages/webgriffe_sylius_table_rate_shipping_plugin.yaml` with the following content:
22+
23+
```yaml
24+
imports:
25+
- { resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/config.yml" }
26+
```
27+
28+
4. Add the plugin's routing by creating the file `config/routes/webgriffe_sylius_table_rate_shipping_plugin.yaml` with the following content:
29+
30+
```yaml
31+
webgriffe_sylius_table_rate_shipping_plugin_shop:
32+
resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/shop_routing.yml"
33+
prefix: /{_locale}
34+
requirements:
35+
_locale: ^[a-z]{2}(?:_[A-Z]{2})?$
36+
37+
webgriffe_sylius_table_rate_shipping_plugin_admina:
38+
resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/admin_routing.yml"
39+
prefix: /admin
40+
41+
```
42+
43+
5. Finish the installation by updating the database schema and installing assets:
44+
45+
```bash
46+
bin/console doctrine:migrations:diff
47+
bin/console doctrine:migrations:migrate
48+
bin/console assets:install
49+
bin/console sylius:theme:assets:install
50+
```
1651

1752
## Contributing
1853

19-
Refer to the SyliusPluginSkeleton: https://github.com/Sylius/PluginSkeleton
54+
To contribute you need to:
55+
56+
1. Clone this repository into you development environment
57+
58+
2. Copy the `.env.test.dist` file inside the test application directory to the `.env` file:
59+
60+
```bash
61+
cp tests/Application/.env.test.dist tests/Application/.env
62+
```
63+
64+
3. Edit the `tests/Application/.env` file by setting configuration specific for your development environment. For example, if you want to use SQLite as database driver during testing you can set the `DATABASE_URL` environment variable as follows:
65+
66+
```bash
67+
DATABASE_URL=sqlite:///%kernel.project_dir%/var/%kernel.environment%_db.sql
68+
```
69+
70+
4. Then, from the plugin's root directory, run the following commands:
71+
72+
```bash
73+
(cd tests/Application && yarn install)
74+
(cd tests/Application && yarn build)
75+
(cd tests/Application && bin/console assets:install public)
76+
(cd tests/Application && bin/console doctrine:database:create)
77+
(cd tests/Application && bin/console doctrine:schema:create)
78+
(cd tests/Application && bin/console server:run localhost:8080 -d public)
79+
```
80+
81+
5. Now at http://localhost:8080/ you have a full Sylius testing application which runs the plugin
82+
83+
### Testing
84+
85+
After your changes you must ensure that the tests are still passing. The current CI suite runs the following tests:
86+
87+
* Easy Coding Standard
88+
89+
```bash
90+
vendor/bin/ecs check src/ tests/Behat/
91+
```
92+
93+
* PHPStan
94+
95+
```bash
96+
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
97+
```
98+
99+
* PHPUnit
100+
101+
```bash
102+
vendor/bin/phpunit
103+
```
104+
105+
* PHPSpec
106+
107+
```bash
108+
vendor/bin/phpspec run
109+
```
110+
111+
* Behat
112+
113+
```bash
114+
vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun
115+
```
116+
117+
To run them all with a single command run:
118+
119+
```bash
120+
composer suite
121+
```
122+
123+
To run Behat's JS scenarios you need to setup Selenium and Chromedriver. Do the following:
124+
125+
1. Download [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)
126+
127+
2. Download [Selenium Standalone Server](https://www.seleniumhq.org/download/)
128+
129+
3. Run Selenium with Chromedriver
130+
131+
```bash
132+
java -Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone.jar
133+
```
134+
135+
4. Remember that the test application webserver must be up and running as described above:
136+
137+
```bash
138+
cd tests/Application && bin/console server:run localhost:8080 -d public
139+
```
140+
141+
License
142+
-------
143+
This library is under the MIT license. See the complete license in the LICENSE file.
144+
145+
Credits
146+
-------
147+
Developed by [Webgriffe®](http://www.webgriffe.com/).

src/Resources/config/services.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/Application/config/packages/_sylius.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ imports:
66

77
- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }
88

9-
- { resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/config.yml" }
10-
119
parameters:
1210
sylius_core.public_dir: '%kernel.project_dir%/public'
1311

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports:
2+
- { resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/config.yml" }

0 commit comments

Comments
 (0)