Skip to content

Commit dc19832

Browse files
committed
Update Makefile and some other files
1 parent 5751c34 commit dc19832

13 files changed

+199
-103
lines changed

DEVELOPMENT.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Node
2+
3+
Be sure you have node 14 on your machine. You can use NVM to easily switch versions.
4+
5+
# Docker
6+
7+
Be sure you have docker on your machine.
8+
9+
# Symfony
10+
11+
Be sure you have the Symfony binary on your machine.
12+
13+
```
14+
curl -sS https://get.symfony.com/cli/installer | bash
15+
```

LICENSE

-21
This file was deleted.

LICENSE.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2021 Monsieur Biz
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

+59-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
.DEFAULT_GOAL := help
22
SHELL=/bin/bash
33
APP_DIR=tests/Application
4+
SYLIUS_VERSION=1.10
45
SYMFONY=cd ${APP_DIR} && symfony
56
COMPOSER=symfony composer
67
CONSOLE=${SYMFONY} console
78
export COMPOSE_PROJECT_NAME=search
9+
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
810
COMPOSE=docker-compose
911
YARN=yarn
10-
PHPSTAN=symfony php vendor/bin/phpstan
11-
PHPUNIT=symfony php vendor/bin/phpunit
12-
PHPSPEC=symfony php vendor/bin/phpspec
1312

1413
###
1514
### DEVELOPMENT
1615
### ¯¯¯¯¯¯¯¯¯¯¯
1716

18-
install: platform sylius ## Install the plugin
17+
install: application platform sylius es.reindex ## Install the plugin
1918
.PHONY: install
2019

2120
up: docker.up server.start ## Up the project (start docker, start symfony server)
2221
stop: server.stop docker.stop ## Stop the project (stop docker, stop symfony server)
2322
down: server.stop docker.down ## Down the project (removes docker containers, stop symfony server)
2423

2524
reset: docker.down ## Stop docker and remove dependencies
26-
rm -rf ${APP_DIR}/{node_modules} ${APP_DIR}/yarn.lock
25+
rm -rf ${APP_DIR}/node_modules ${APP_DIR}/yarn.lock
26+
rm -rf ${APP_DIR}
2727
rm -rf vendor composer.lock
2828
.PHONY: reset
2929

@@ -32,7 +32,9 @@ dependencies: vendor node_modules ## Setup the dependencies
3232

3333
.php-version: .php-version.dist
3434
cp .php-version.dist .php-version
35-
(cd ${APP_DIR} && ln -sf ../../.php-version)
35+
36+
php.ini: php.ini.dist
37+
cp php.ini.dist php.ini
3638

3739
vendor: composer.lock ## Install the PHP dependencies using composer
3840
ifdef GITHUB_ACTIONS
@@ -51,6 +53,7 @@ endif
5153
yarn.install: ${APP_DIR}/yarn.lock
5254

5355
${APP_DIR}/yarn.lock:
56+
ln -sf ${APP_DIR}/node_modules node_modules
5457
cd ${APP_DIR} && ${YARN} install && ${YARN} build
5558
${YARN} install
5659
${YARN} encore prod
@@ -59,23 +62,61 @@ node_modules: ${APP_DIR}/node_modules ## Install the Node dependencies using yar
5962

6063
${APP_DIR}/node_modules: yarn.install
6164

65+
###
66+
### TEST APPLICATION
67+
### ¯¯¯¯¯
68+
69+
application: .php-version php.ini ${APP_DIR} setup_application ${APP_DIR}/docker-compose.yaml
70+
71+
${APP_DIR}:
72+
(${COMPOSER} create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="${SYLIUS_VERSION}" ${APP_DIR})
73+
74+
setup_application:
75+
rm -f ${APP_DIR}/yarn.lock
76+
(cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}')
77+
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
78+
(cd ${APP_DIR} && ${COMPOSER} require --no-scripts --no-progress --no-install --no-update monsieurbiz/${PLUGIN_NAME}="*@dev")
79+
$(MAKE) apply_dist
80+
$(MAKE) ${APP_DIR}/.php-version
81+
$(MAKE) ${APP_DIR}/php.ini
82+
(cd ${APP_DIR} && ${COMPOSER} install)
83+
84+
${APP_DIR}/docker-compose.yaml:
85+
rm -f ${APP_DIR}/docker-compose.yml
86+
rm -f ${APP_DIR}/docker-compose.yaml
87+
cp docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
88+
.PHONY: ${APP_DIR}/docker-compose.yaml
89+
90+
${APP_DIR}/.php-version: .php-version
91+
(cd ${APP_DIR} && ln -sf ../../.php-version)
92+
93+
${APP_DIR}/php.ini: php.ini
94+
(cd ${APP_DIR} && ln -sf ../../php.ini)
95+
96+
apply_dist:
97+
cp -Rv dist/* ${APP_DIR}
98+
cp -Rv dist/.env.local ${APP_DIR}/.env.local
99+
62100
###
63101
### TESTS
64102
### ¯¯¯¯¯
65103

66-
test.all: test.composer test.phpstan test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig ## Run all tests in once
104+
test.all: test.composer test.phpstan test.phpmd test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once
67105

68106
test.composer: ## Validate composer.json
69107
${COMPOSER} validate --strict
70108

71109
test.phpstan: ## Run PHPStan
72-
${PHPSTAN} analyse -c phpstan.neon src/
110+
${COMPOSER} phpstan || true
111+
112+
test.phpmd: ## Run PHPMD
113+
${COMPOSER} phpmd || true
73114

74115
test.phpunit: ## Run PHPUnit
75-
${PHPUNIT}
116+
${COMPOSER} phpunit
76117

77118
test.phpspec: ## Run PHPSpec
78-
${PHPSPEC} run
119+
${COMPOSER} phpspec
79120

80121
test.phpcs: ## Run PHP CS Fixer in dry-run
81122
${COMPOSER} run -- phpcs --dry-run -v
@@ -87,7 +128,7 @@ test.container: ## Lint the symfony container
87128
${CONSOLE} lint:container
88129

89130
test.yaml: ## Lint the symfony Yaml files
90-
${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config --parse-tags
131+
${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config
91132

92133
test.schema: ## Validate MySQL Schema
93134
${CONSOLE} doctrine:schema:validate
@@ -115,12 +156,6 @@ sylius.assets: ## Install all assets with symlinks
115156
${CONSOLE} sylius:install:assets
116157
${CONSOLE} sylius:theme:assets:install --symlink
117158

118-
###
119-
### JANE
120-
### ¯¯¯¯¯¯
121-
jane.generate: ## Generate Models classes with Jane
122-
${COMPOSER} run -- jane-generate
123-
124159
###
125160
### PLATFORM
126161
### ¯¯¯¯¯¯¯¯
@@ -130,11 +165,6 @@ platform: .php-version up ## Setup the platform tools
130165

131166
docker.pull: ## Pull the docker images
132167
cd ${APP_DIR} && ${COMPOSE} pull
133-
.PHONY: docker.pull
134-
135-
docker.build: ## Build (and pull) the docker images
136-
cd ${APP_DIR} && ${COMPOSE} build --pull
137-
.PHONY: docker.build
138168

139169
docker.up: ## Start the docker containers
140170
cd ${APP_DIR} && ${COMPOSE} up -d
@@ -148,13 +178,19 @@ docker.down: ## Stop and remove the docker containers
148178
cd ${APP_DIR} && ${COMPOSE} down
149179
.PHONY: docker.down
150180

181+
docker.logs: ## Logs the docker containers
182+
cd ${APP_DIR} && ${COMPOSE} logs -f
183+
.PHONY: docker.logs
184+
151185
server.start: ## Run the local webserver using Symfony
152-
${SYMFONY} local:proxy:domain:attach ${COMPOSE_PROJECT_NAME}
153186
${SYMFONY} local:server:start -d
154187

155188
server.stop: ## Stop the local webserver
156189
${SYMFONY} local:server:stop
157190

191+
es.reindex: ## Reindex elasticsearch
192+
${CONSOLE} monsieurbiz:search:populate
193+
158194
###
159195
### HELP
160196
### ¯¯¯¯

TESTING.md

+30-50
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,58 @@
11
# Testing
22

3-
Be sure you've run the `composer install` before reading this file.
4-
With Symfony binary, you should run `symfony composer install`
3+
## Requirements
54

6-
## Installation
5+
You'll need:
76

8-
1. To be able to run yarn build correctly, create symlink for `node_modules` :
7+
- PHP 7.4 minimum.
8+
- docker, for the database.
9+
- symfony CLI, to run the local server.
10+
- composer, to install PHP dependencies.
11+
- npm and yarn, to install ui dependencies and build the JS/CSS files.
912

10-
```bash
11-
ln -s tests/Application/node_modules node_modules
12-
```
13+
## Installation
1314

14-
2. From the plugin root directory, run the following commands:
15+
```bash
16+
make install
17+
```
1518

16-
```bash
17-
$ (cd tests/Application && yarn install)
18-
$ (cd tests/Application && yarn build)
19-
$ (cd tests/Application && bin/console assets:install public -e test)
20-
$ (cd tests/Application && bin/console doctrine:database:drop --force -e test --if-exists)
21-
$ (cd tests/Application && bin/console doctrine:database:create -e test)
22-
$ (cd tests/Application && bin/console doctrine:schema:create -e test)
23-
```
24-
25-
To be able to setup the plugin's database, remember to configure your database credentials in `tests/Application/.env`
26-
and `tests/Application/.env.test`. You can also add custom configuration in `tests/Application/.env.test.local`.
19+
This will run a Sylius app (the one in `tests/Application/`) with the plugin
20+
installed and all Sylius' sample data. It uses the symfony binary.
2721

2822
## Usage
2923

30-
### Running plugin tests
24+
### List all available commands
3125

32-
- PHPUnit
26+
```bash
27+
make help
28+
```
3329

34-
```bash
35-
$ vendor/bin/phpunit
36-
```
30+
### Running minimum plugin tests
3731

38-
- PHPSpec
32+
- PHPUnit
3933

4034
```bash
41-
$ vendor/bin/phpspec run
35+
make test.phpunit
4236
```
43-
44-
- PHPStan
45-
46-
```bash
47-
$ vendor/bin/phpstan analyse src
48-
```
49-
50-
### Opening Sylius with the plugin
51-
52-
- Using `test` environment:
5337

54-
```bash
55-
$ (cd tests/Application && bin/console sylius:fixtures:load -e test)
56-
$ (cd tests/Application && bin/console server:run -d public -e test)
57-
```
58-
59-
- Using `dev` environment:
38+
- PHP CS fixer
6039

6140
```bash
62-
$ (cd tests/Application && bin/console sylius:fixtures:load -e 1.0-dev)
63-
$ (cd tests/Application && bin/console server:run -d public -e 1.0-dev)
41+
make test.phpcs
6442
```
6543

66-
### Reindex Elasticsearch
44+
> Tip: You can fix your code with `make test.phpcs.fix`!
6745

68-
- Using `test` environment:
46+
- PHPSpec
6947

7048
```bash
71-
$ (cd tests/Application && bin/console monsieurbiz:search:populate -e test)
49+
make test.phpspec
7250
```
73-
74-
- Using `dev` environment:
51+
52+
- PHPStan
7553

7654
```bash
77-
$ (cd tests/Application && bin/console monsieurbiz:search:populate -e 1.0-dev)
55+
make test.phpstan
7856
```
57+
58+
> Tip: You can run all tests with `make test.all`!

docker-compose.yaml.dist

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.8'
2+
services:
3+
database:
4+
image: mysql:8.0
5+
ports:
6+
- 3306
7+
environment:
8+
MYSQL_ALLOW_EMPTY_PASSWORD: 1
9+
MYSQL_DATABASE: sylius
10+
volumes:
11+
- database:/var/lib/mysql
12+
13+
mailer:
14+
image: monsieurbiz/mailcatcher
15+
ports:
16+
- 1025
17+
- 1080
18+
19+
volumes:
20+
database: {}

php.ini.dist

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
memory_limit=-1

phpmd.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<rule ref="rulesets/naming.xml/ShortClassName"/>
4545
<rule ref="rulesets/naming.xml/ShortVariable">
4646
<properties>
47-
<property name="exceptions" value="id,qb"/>
47+
<property name="exceptions" value="id,em,qb"/>
4848
</properties>
4949
</rule>
5050
<rule ref="rulesets/naming.xml/ShortMethodName"/>

phpspec.yml.dist

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ suites:
22
main:
33
namespace: MonsieurBiz\SyliusSearchPlugin
44
psr4_prefix: MonsieurBiz\SyliusSearchPlugin
5+
src_path: src
6+
spec_path: tests

phpstan.neon

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ parameters:
1111
- 'src/DependencyInjection/MonsieurBizSyliusSearchExtension.php'
1212

1313
# Test dependencies
14-
- 'tests/Application/app/**.php'
15-
- 'tests/Application/src/**.php'
14+
- 'tests/Application/**/*'

0 commit comments

Comments
 (0)