-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from moufmouf/unittests
Adding unit tests
- Loading branch information
Showing
10 changed files
with
283 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/vendor/ | ||
/composer.lock | ||
/build | ||
/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace TheCodingMachine\TDBM\Bundle\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use TheCodingMachine\GraphQLite\Schema; | ||
use TheCodingMachine\TDBM\TDBMService; | ||
|
||
class FunctionalTest extends TestCase | ||
{ | ||
public function testServiceWiring() | ||
{ | ||
$kernel = new TdbmTestingKernel('test', true); | ||
$kernel->boot(); | ||
$container = $kernel->getContainer(); | ||
|
||
$tdbmService = $container->get(TDBMService::class); | ||
$this->assertInstanceOf(TDBMService::class, $tdbmService); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
|
||
namespace TheCodingMachine\TDBM\Bundle\Tests; | ||
|
||
|
||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
use Symfony\Component\Routing\RouteCollectionBuilder; | ||
use TheCodingMachine\Graphqlite\Bundle\GraphqliteBundle; | ||
use TheCodingMachine\TDBM\Bundle\TdbmBundle; | ||
use TheCodingMachine\TDBM\Bundle\TdbmGraphqlBundle; | ||
|
||
class TdbmTestingKernel extends Kernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
const CONFIG_EXTS = '.{php,xml,yaml,yml}'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', true); | ||
} | ||
|
||
public function registerBundles() | ||
{ | ||
return [ | ||
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | ||
new DoctrineBundle(), | ||
new TdbmBundle(), | ||
]; | ||
} | ||
|
||
public function configureContainer(ContainerBuilder $c, LoaderInterface $loader) | ||
{ | ||
$loader->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<testsuites> | ||
<testsuite name="Graphql controllers bundle Test Suite"> | ||
<directory>./Tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./</directory> | ||
<exclude> | ||
<directory>./Resources</directory> | ||
<directory>./Tests</directory> | ||
<directory>./vendor</directory> | ||
<directory>./var</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
<php> | ||
<env name="DATABASE_URL" value="mysql://root:[email protected]:3306/test_tdbmbundle" /> | ||
</php> | ||
|
||
<logging> | ||
<log type="coverage-html" target="build/coverage"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<testsuites> | ||
<testsuite name="Graphql controllers bundle Test Suite"> | ||
<directory>./Tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./</directory> | ||
<exclude> | ||
<directory>./Resources</directory> | ||
<directory>./Tests</directory> | ||
<directory>./vendor</directory> | ||
<directory>./var</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
<php> | ||
<env name="DATABASE_URL" value="mysql://root:@127.0.0.1:3306/test_tdbmbundle" /> | ||
</php> | ||
|
||
<logging> | ||
<log type="coverage-html" target="build/coverage"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |