Skip to content

Commit

Permalink
GH-78 Adopt bundle best practices from https://symfony.com/doc/curren…
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbrandao committed Nov 3, 2021
1 parent 82d6706 commit 2564857
Show file tree
Hide file tree
Showing 191 changed files with 143 additions and 176 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
php: [ '7.2', '8.0' ]
php: [ '7.4', '8.0' ]
symfony: [ '3.4', '4.4' ]
fail-fast: false

Expand All @@ -29,7 +29,7 @@ jobs:
extensions: "${{ env.extensions }}"
ini-values: date.timezone=Europe/London,memory_limit=-1,error_reporting=-1,log_errors_max_len=0,zend.assertions=1,assert.exception=1,xdebug.show_exception_trace=0
php-version: "${{ matrix.php }}"
tools: composer, phpunit:8
tools: composer, phpunit:9

- name: Get Composer cache directory
id: composer-cache
Expand All @@ -48,8 +48,8 @@ jobs:
- name: Composer install
run: composer install --no-interaction --no-progress --prefer-dist --verbose

- name: PHPUnit Unit tests
run: phpunit --testsuit=unit --coverage-text
- name: PHP environment details
run: php -v

- name: PHPUnit Functional tests
run: phpunit --testsuit=unit --coverage-text
- name: PHPUnit Unit and Functional tests
run: XDEBUG_MODE=coverage phpunit --coverage-text
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
*.pyc
.idea
.phpunit.cache
.phpunit.result.cache
.php-cs-fixer.cache
composer.lock
/Resources/doc/_build/
/Tests/Functional/App/cache
/Tests/Functional/App/logs
/docs/_build/
/tests/Sandbox/App/cache
/tests/Sandbox/App/logs
/tmp
vendor
4 changes: 3 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude(['Tests/Functional/App', 'Tests/Sandbox', 'tools', 'tmp'])
->exclude(['tests/Sandbox', 'tools', 'tmp'])
->in(__DIR__)
;

Expand All @@ -13,6 +13,8 @@
'@PSR12' => true,
'strict_param' => false,
'array_syntax' => ['syntax' => 'short'],
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
])
->setFinder($finder)
->setCacheFile('.php-cs-fixer.cache')
Expand Down
38 changes: 26 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := /usr/bin/env bash
PWD = $(shell pwd)
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

DOCKER_COMPOSE = cd Tests/Sandbox/Compose && COMPOSE_DOCKER_CLI_BUILD=0 COMPOSE_PROJECT_NAME=smartybundle docker-compose
DOCKER_COMPOSE = cd tests/Sandbox/Compose && COMPOSE_DOCKER_CLI_BUILD=0 COMPOSE_PROJECT_NAME=smartybundle docker-compose
DOCKER_COMPOSE_PROD = $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.prod.yml
DC_BUILD_OPTS = --pull

Expand Down Expand Up @@ -110,25 +110,29 @@ dc-run-php7-sf3: ## Get a shell in a php7-sf3 container
$(DOCKER_COMPOSE) run --rm php bash
.PHONY: dc-run-php7-sf3

### Sandbox/Simple Docker targets ###
### Sandbox/DockerTesting targets ###
build-php7-sf3: ## Build the php7-sf3 test image
docker build . -f Tests/Sandbox/Simple/Dockerfile --no-cache --build-arg PHP_VERSION=7.4 --build-arg SYMFONY_VERSION=3.4 -t noiselabs/smarty-bundle-testing:php7-sf3
docker build . -f tests/Sandbox/DockerTesting/Dockerfile --no-cache --build-arg PHP_VERSION=7.4 --build-arg SYMFONY_VERSION=3.4 -t noiselabs/smarty-bundle-testing:php7-sf3
.PHONY: build-php7-sf3

build-php7-sf4: ## Build the php7-sf4 test image
docker build . -f Tests/Sandbox/Simple/Dockerfile --no-cache --build-arg PHP_VERSION=7.4 --build-arg SYMFONY_VERSION=4.4 -t noiselabs/smarty-bundle-testing:php7-sf4
docker build . -f tests/Sandbox/DockerTesting/Dockerfile --no-cache --build-arg PHP_VERSION=7.4 --build-arg SYMFONY_VERSION=4.4 -t noiselabs/smarty-bundle-testing:php7-sf4
.PHONY: build-php7-sf4

build-php8-sf4: ## Build the php8-sf4 test image
docker build . -f Tests/Sandbox/Simple/Dockerfile --no-cache --build-arg PHP_VERSION=8.0 --build-arg SYMFONY_VERSION=4.4 -t noiselabs/smarty-bundle-testing:php8-sf4
docker build . -f tests/Sandbox/DockerTesting/Dockerfile --no-cache --build-arg PHP_VERSION=8.0 --build-arg SYMFONY_VERSION=4.4 -t noiselabs/smarty-bundle-testing:php8-sf4
.PHONY: build-php8-sf4

build-php8-sf5: ## Build the php8-sf5 test image
docker build . -f tests/Sandbox/DockerTesting/Dockerfile --no-cache --build-arg PHP_VERSION=8.0 --build-arg SYMFONY_VERSION=5.3 -t noiselabs/smarty-bundle-testing:php8-sf5
.PHONY: build-php8-sf5

build: ## Build Docker images
$(MAKE) build-php7-sf3 build-php7-sf4 build-php8-sf4
$(MAKE) build-php7-sf3 build-php7-sf4 build-php8-sf4 build-php8-sf5
.PHONY: build

build-parallel: ## Build Docker images in parallel
$(MAKE) -j4 build-php7-sf3 build-php7-sf4 build-php8-sf4
$(MAKE) -j4 build-php7-sf3 build-php7-sf4 build-php8-sf4 build-php8-sf5
.PHONY: build-parallel

test-php7-sf3: ## Run unit and functional tests in the php7-sf3 image
Expand All @@ -143,11 +147,17 @@ test-php8-sf4: ## Run unit and functional tests in the php8-sf4 image
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor noiselabs/smarty-bundle-testing:php8-sf4 composer test
.PHONY: test-php8-sf4

test-php8-sf5: ## Run unit and functional tests in the php8-sf5 image
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor noiselabs/smarty-bundle-testing:php8-sf5 composer test
.PHONY: test-php8-sf5

test: ## Run unit and functional tests
$(MAKE) test-php70 test-php71 test-php72 test-php73
$(MAKE) test-php7-sf3 test-php7-sf4 test-php8-sf4 test-php8-sf5
.PHONY: test

test-parallel: ## Run unit and functional tests in parallel
$(MAKE) -j4 test-php71 test-php72 test-php73 test-php80
$(MAKE) -j4 test-php7-sf3 test-php7-sf4 test-php8-sf4 test-php8-sf5
.PHONY: test-parallel

sh-php7-sf3: ## Get a shell in the php7-sf3 container
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor noiselabs/smarty-bundle-testing:php7-sf3 sh
Expand All @@ -162,17 +172,21 @@ sh-php8-sf4: ## Get a shell in the php8-sf4 container
.PHONY: sh-php8-sf4

web-php7-sf3: ## Launches the built-in PHP web server in the php7-sf3 container
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8073:8080/tcp -w /app/Tests/Functional/App noiselabs/smarty-bundle-testing:php7-sf3 php -S 0.0.0.0:8080 -t web
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8073:8080/tcp -w /app/tests/Sandbox/App noiselabs/smarty-bundle-testing:php7-sf3 php -S 0.0.0.0:8080 -t web
.PHONY: web-php7-sf3

web-php7-sf4: ## Launches the built-in PHP web server in the php7-sf4 container
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8074:8080/tcp -w /app/Tests/Functional/App noiselabs/smarty-bundle-testing:php7-sf4 php -S 0.0.0.0:8080 -t web
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8074:8080/tcp -w /app/tests/Sandbox/App noiselabs/smarty-bundle-testing:php7-sf4 php -S 0.0.0.0:8080 -t web
.PHONY: web-php7-sf4

web-php8-sf4: ## Launches the built-in PHP web server in the php8-sf4 container
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8084:8080/tcp -w /app/Tests/Functional/App noiselabs/smarty-bundle-testing:php8-sf4 php -S 0.0.0.0:8080 -t web
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8084:8080/tcp -w /app/tests/Sandbox/App noiselabs/smarty-bundle-testing:php8-sf4 php -S 0.0.0.0:8080 -t web
.PHONY: web-php8-sf4

web-php8-sf5: ## Launches the built-in PHP web server in the php8-sf5 container
docker run --rm -it --mount type=bind,src=$(PWD),dst=/app --mount type=volume,dst=/app/vendor -p 127.0.0.1:8085:8080/tcp -w /app/tests/Sandbox/App noiselabs/smarty-bundle-testing:php8-sf5 php -S 0.0.0.0:8080 -t web
.PHONY: web-php8-sf5

### Coding Standards ###
php-cs-fixer-dry-run: ## Check for PHP Coding Standards fixes but don't apply changes
tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --dry-run --diff -v
Expand Down
Binary file removed Resources/assets/phpstorm-text.png
Binary file not shown.
Binary file removed Resources/assets/phpstorm.png
Binary file not shown.
Empty file.
6 changes: 0 additions & 6 deletions Tests/Functional/App/config/routing.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions Tests/Functional/App/config/smarty.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions Tests/Sandbox/Simple/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions Tests/bootstrap.php

This file was deleted.

17 changes: 0 additions & 17 deletions autoload/phpunit-class-aliases.php

This file was deleted.

13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"require-dev": {
"phpunit/phpunit": "^8|^9",
"symfony/asset": "^3|^4",
"symfony/console": "^3|^4",
"symfony/expression-language": "^3|^4",
"symfony/phpunit-bridge": "^3|^4",
"symfony/security": "^3.4.48|^4",
Expand All @@ -44,20 +45,22 @@
"symfony/yaml": "^3|^4"
},
"autoload": {
"psr-4": { "NoiseLabs\\Bundle\\SmartyBundle\\": "" }
"psr-4": {
"NoiseLabs\\Bundle\\SmartyBundle\\": "src/"
}
},
"autoload-dev": {
"files": [
"autoload/phpunit-class-aliases.php"
]
"psr-4": {
"NoiseLabs\\Bundle\\SmartyBundle\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
}
},
"scripts": {
"test": "php -v && php vendor/bin/phpunit --version && php vendor/bin/phpunit",
"test": "php -dxdebug.mode=coverage vendor/bin/phpunit",
"test-with-coverage": "@test --coverage-text",
"test-unit": "@test --testsuite=unit",
"test-functional": "@test --testsuite=functional",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 20 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
columns="max"
convertErrorsToExceptions="true"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
processIsolation="false"
stopOnFailure="false"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="false"
beStrictAboutTodoAnnotatedTests="false"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">

<php>
<ini name="assert.exception" value="1"/>
Expand All @@ -29,10 +31,17 @@

<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">./Tests/Unit</directory>
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
<testsuite name="functional">
<directory suffix="Test.php">./Tests/Functional</directory>
<directory suffix="Test.php">tests/Functional</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SmartyExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
$loader->load('smarty.xml');

$configuration = new Configuration();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @author Vítor Brandão <[email protected]>
*/
class ResourcePlugin extends Plugin
class ResourcePlugin extends AbstractPlugin
{
public function getType()
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

use Exception;
use NoiseLabs\Bundle\SmartyBundle\DependencyInjection\SmartyExtension;
use PHPUnit_Framework_TestCase as TestCase;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
Expand All @@ -37,9 +37,6 @@
* DependencyInjection\SmartyExtension tests.
*
* @author Vítor Brandão <[email protected]>
*
* @internal
* @coversNothing
*/
class SmartyExtensionTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
* Test suite for the actions extension.
*
* @author Vítor Brandão <[email protected]>
*
* @internal
* @coversNothing
*/
class ActionsExtensionTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
* Test suite for the assets extension.
*
* @author Vítor Brandão <[email protected]>
*
* @internal
* @coversNothing
*/
class AssetsExtensionTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@

use NoiseLabs\Bundle\SmartyBundle\Extension\RoutingExtension;
use NoiseLabs\Bundle\SmartyBundle\Tests\TestCase;
use PHPUnit_Framework_Constraint_IsAnything;
use PHPUnit\Framework\Constraint\IsAnything;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
* Test suite for the routing extension.
*
* @author Vítor Brandão <[email protected]>
*
* @internal
* @coversNothing
*/
class RoutingExtensionTest extends TestCase
{
Expand Down Expand Up @@ -79,8 +76,8 @@ public function createRoutingExtension($referenceType = UrlGeneratorInterface::A
$generator->expects($this->any())
->method('generate')
->with(
new PHPUnit_Framework_Constraint_IsAnything(),
new PHPUnit_Framework_Constraint_IsAnything(),
new IsAnything(),
new IsAnything(),
$referenceType
)
->will($this->returnValue($url))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
* Test suite for the security extension.
*
* @author Vítor Brandão <[email protected]>
*
* @internal
* @coversNothing
*/
class SecurityExtensionTest extends TestCase
{
Expand Down
Loading

0 comments on commit 2564857

Please sign in to comment.