diff --git a/.gitignore b/.gitignore index 4fbb073..e205c7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /vendor/ /composer.lock +/build +/cache \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d4a355a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,56 @@ +language: php +sudo: false +cache: + directories: + - $HOME/.composer/cache/files + #- $HOME/symfony-bridge/.phpunit + +env: + global: + - PHPUNIT_FLAGS="-v" + #- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" + +matrix: + fast_finish: true + include: + # Test the latest stable release + - php: 7.1 + - php: 7.2 + - php: 7.3 + env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" + + # Test LTS versions. + - php: 7.3 + env: DEPENDENCIES="symfony/lts:^4" + + # Latest commit to master + - php: 7.3 + env: STABILITY="dev" + + allow_failures: + # Minimum supported dependencies with the latest and oldest PHP version + - php: 7.3 + env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" + - php: 7.1 + env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" + # Dev-master is allowed to fail. + - env: STABILITY="dev" + +before_install: + - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi + - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; + - if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; + +install: + # To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 + - if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi + - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction + #- ./vendor/bin/simple-phpunit install + +script: + - composer validate --strict --no-check-lock + # simple-phpunit is the PHPUnit wrapper provided by the PHPUnit Bridge component and + # it helps with testing legacy code and deprecations (composer require symfony/phpunit-bridge) + #- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS + - composer phpstan + - ./vendor/bin/phpunit diff --git a/README.md b/README.md index e6cfc61..4ba8c2f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/tdbm-bundle/v/stable)](https://packagist.org/packages/thecodingmachine/tdbm-bundle) +[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/tdbm-bundle/v/unstable)](https://packagist.org/packages/thecodingmachine/tdbm-bundle) +[![License](https://poser.pugx.org/thecodingmachine/tdbm-bundle/license)](https://packagist.org/packages/thecodingmachine/tdbm-bundle) +[![Build Status](https://travis-ci.org/thecodingmachine/tdbm-bundle.svg?branch=master)](https://travis-ci.org/thecodingmachine/tdbm-bundle) +[![Coverage Status](https://coveralls.io/repos/thecodingmachine/tdbm-bundle/badge.svg?branch=master&service=github)](https://coveralls.io/github/thecodingmachine/tdbm-bundle?branch=master) + # TDBM Symfony bundle TDBM integration package for Symfony 4. diff --git a/Tests/Fixtures/config/services.yaml b/Tests/Fixtures/config/services.yaml new file mode 100644 index 0000000..d0fcf25 --- /dev/null +++ b/Tests/Fixtures/config/services.yaml @@ -0,0 +1,27 @@ +# This file is the entry point to configure your own services. +# Files in the packages/ subdirectory configure your dependencies. + +# Put parameters here that don't need to change on each machine where the app is deployed +# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration +parameters: + +services: + # default configuration for services in *this* file + _defaults: + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + + # makes classes in src/ available to be used as services + # this creates a service per class whose id is the fully-qualified class name + TheCodingMachine\Graphqlite\Bundle\Tests\Fixtures\: + resource: '../*' + exclude: '../{Entities}' + + # controllers are imported separately to make sure services can be injected + # as action arguments even if you don't extend any base controller class + #App\Controller\: + # resource: '../src/Controller' + # tags: ['controller.service_arguments'] + + # add more service definitions when explicit configuration is needed + # please note that last definitions always *replace* previous ones diff --git a/Tests/FunctionalTest.php b/Tests/FunctionalTest.php new file mode 100644 index 0000000..7b08315 --- /dev/null +++ b/Tests/FunctionalTest.php @@ -0,0 +1,21 @@ +boot(); + $container = $kernel->getContainer(); + + $tdbmService = $container->get(TDBMService::class); + $this->assertInstanceOf(TDBMService::class, $tdbmService); + } +} diff --git a/Tests/TdbmTestingKernel.php b/Tests/TdbmTestingKernel.php new file mode 100644 index 0000000..c63f6ad --- /dev/null +++ b/Tests/TdbmTestingKernel.php @@ -0,0 +1,72 @@ +load(function(ContainerBuilder $container) { + $container->loadFromExtension('framework', array( + 'secret' => 'S0ME_SECRET', + )); + $container->loadFromExtension('doctrine', array( + 'dbal' => [ + 'driver' => 'pdo_mysql', + 'server_version' => '5.7', + 'charset'=> 'utf8mb4', + 'default_table_options' => [ + 'charset' => 'utf8mb4', + 'collate' => 'utf8mb4_unicode_ci', + ], + 'url' => '%env(resolve:DATABASE_URL)%' + ] + )); + }); + $confDir = $this->getProjectDir().'/Tests/Fixtures/config'; + + $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); + } + + protected function configureRoutes(RouteCollectionBuilder $routes) + { + } + + public function getCacheDir() + { + return __DIR__.'/../cache/'.spl_object_hash($this); + } +} diff --git a/composer.json b/composer.json index 267cecd..c08a522 100644 --- a/composer.json +++ b/composer.json @@ -24,13 +24,28 @@ "php" : ">=7.1", "thecodingmachine/tdbm" : "~5.0.0", "doctrine/doctrine-bundle": "^1.9", - "doctrine/orm": "*" + "doctrine/orm": "^1 || ^2" + }, + "require-dev": { + "roave/security-advisories": "dev-master", + "symfony/security-bundle": "^4.1.9", + "symfony/yaml": "^4.1.9", + "phpunit/phpunit": "^7.5.6", + "phpstan/phpstan": "^0.11.4" + }, + "scripts": { + "phpstan": "phpstan analyse TdbmBundle.php DependencyInjection/ Resources/ -c phpstan.neon --level=7 --no-progress" }, "autoload" : { "psr-4" : { "TheCodingMachine\\TDBM\\Bundle\\" : "" } }, + "autoload-dev" : { + "psr-4" : { + "TheCodingMachine\\TDBM\\Bundle\\" : "" + } + }, "extra": { "branch-alias": { "dev-master": "5.0.x-dev" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..5d46020 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + ignoreErrors: + - "#Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition::children\\(\\)#" +#includes: +# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..e0a156a --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,39 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + ./var + + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..e4acdb6 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,39 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + ./var + + + + + + + + + + + + +