-
Notifications
You must be signed in to change notification settings - Fork 3
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 #7 from gdubost/v3
Ajout du provider v3 pour le json
- Loading branch information
Showing
27 changed files
with
8,396 additions
and
118 deletions.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage_clover: tmp/behat/coverage.clover.xml | ||
json_path: tmp/behat/coveralls-upload.json |
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,20 @@ | ||
image: etna/drone-php7:php71 | ||
cache: | ||
- /root/.composer | ||
env: | ||
- APPLICATION_ENV=test | ||
- COVERALLS_REPO_TOKEN=$$COVERALLS_TOKEN | ||
- COVERALLS_SERVICE_NAME=drone.io | ||
script: | ||
- composer global require phpdocumentor/phpdocumentor --no-interaction --prefer-dist --no-progress | ||
- composer install --dev --no-interaction --prefer-dist --no-progress --no-scripts | ||
- composer phing | ||
- composer coveralls | ||
notify: | ||
slack: | ||
webhook_url: $$SLACK_WEBHOOK_URL | ||
username: drone | ||
channel: $$SLACK_CHANNEL | ||
on_started: true | ||
on_failure: true | ||
on_success: true |
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,4 +1,29 @@ | ||
bin/ | ||
tmp/ | ||
vendor/ | ||
composer.lock | ||
.DS_Store | ||
doc/ | ||
.php_cs.cache | ||
|
||
###> symfony/framework-bundle ### | ||
/.env.local | ||
/.env.local.php | ||
/.env.*.local | ||
/public/bundles/ | ||
/var/ | ||
/vendor/ | ||
###< symfony/framework-bundle ### | ||
|
||
###> squizlabs/php_codesniffer ### | ||
/.phpcs-cache | ||
/phpcs.xml | ||
###< squizlabs/php_codesniffer ### | ||
|
||
###> friendsofphp/php-cs-fixer ### | ||
/.php_cs | ||
/.php_cs.cache | ||
###< friendsofphp/php-cs-fixer ### | ||
|
||
###> phpunit/phpunit ### | ||
/phpunit.xml | ||
###< phpunit/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,55 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__ . "/src") | ||
; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRules([ | ||
"@PSR1" => true, | ||
"@PSR2" => true, | ||
"@Symfony" => true, | ||
"@Symfony:risky" => true, | ||
"@DoctrineAnnotation" => true, | ||
"@PHP56Migration" => true, | ||
"@PHP56Migration:risky" => true, | ||
"@PHP70Migration" => true, | ||
"@PHP70Migration:risky" => true, | ||
"@PHP71Migration" => true, | ||
"@PHP71Migration:risky" => true, | ||
"binary_operator_spaces" => [ | ||
"align_double_arrow" => true, | ||
"align_equals" => true | ||
], | ||
"concat_space" => true, | ||
"strict_comparison" => true, | ||
"combine_consecutive_issets" => true, | ||
"combine_consecutive_unsets" => true, | ||
"comment_to_phpdoc" => true, | ||
"compact_nullable_typehint" => true, | ||
"explicit_indirect_variable" => true, | ||
"explicit_string_variable" => true, | ||
"header_comment" => [ | ||
"commentType" => "PHPDoc", | ||
"header" => "PHP version 7.1\n@author BLU <dev@etna-alternance.net>", | ||
"location" => "after_open", | ||
"separate" => "bottom" | ||
], | ||
"linebreak_after_opening_tag" => true, | ||
"no_useless_else" => true, | ||
"no_useless_return" => true, | ||
"ordered_imports" => true, | ||
"phpdoc_order" => true, | ||
"psr0" => true, | ||
"return_assignment" => true, | ||
"visibility_required" => [ | ||
"elements" => ['property', 'method'] | ||
], | ||
"concat_space" => [ | ||
"spacing" => "one" | ||
] | ||
]) | ||
->setFinder($finder) | ||
->setRiskyAllowed(true) | ||
->setUsingCache(false) | ||
; |
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
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,19 @@ | ||
<?php | ||
|
||
namespace TestApp\Controller; | ||
|
||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
class BaseController extends Controller | ||
{ | ||
/** | ||
* @Route("/", methods={"POST"}, name="home") | ||
*/ | ||
public function home(Request $req) | ||
{ | ||
return new JsonResponse($req->request->all(), 200); | ||
} | ||
} |
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,61 @@ | ||
<?php | ||
|
||
namespace TestApp; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\Config\Resource\FileResource; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel as BaseKernel; | ||
use Symfony\Component\Routing\RouteCollectionBuilder; | ||
|
||
class Kernel extends BaseKernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
const CONFIG_EXTS = '.{php,xml,yaml,yml}'; | ||
|
||
public function getCacheDir() | ||
{ | ||
return $this->getProjectDir().'/TestApp/tmp/cache/'.$this->environment; | ||
} | ||
|
||
public function getLogDir() | ||
{ | ||
return $this->getProjectDir().'/TestApp/tmp/log'; | ||
} | ||
|
||
public function registerBundles() | ||
{ | ||
$contents = require $this->getProjectDir().'/TestApp/config/bundles.php'; | ||
foreach ($contents as $class => $envs) { | ||
if (isset($envs['all']) || isset($envs[$this->environment])) { | ||
yield new $class(); | ||
} | ||
} | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) | ||
{ | ||
$container->addResource(new FileResource($this->getProjectDir().'/TestApp/config/bundles.php')); | ||
// Feel free to remove the "container.autowiring.strict_mode" parameter | ||
// if you are using symfony/dependency-injection 4.0+ as it's the default behavior | ||
$container->setParameter('container.autowiring.strict_mode', true); | ||
$container->setParameter('container.dumper.inline_class_loader', true); | ||
$confDir = $this->getProjectDir().'/TestApp/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) | ||
{ | ||
$confDir = $this->getProjectDir().'/TestApp/config'; | ||
|
||
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); | ||
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); | ||
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace TestApp\Services; | ||
|
||
use Symfony\Component\HttpKernel\KernelEvents; | ||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
class ExceptionListener implements EventSubscriberInterface | ||
{ | ||
private $debug; | ||
|
||
public function __construct(ContainerInterface $container) | ||
{ | ||
$this->debug = $container->getParameter("kernel.debug"); | ||
} | ||
|
||
public function onKernelException(GetResponseForExceptionEvent $event) | ||
{ | ||
$exception = $event->getException(); | ||
if (is_a($exception, "InvalidArgumentException")) { | ||
$code = 400; | ||
} else { | ||
$code = (method_exists($exception, 'getStatusCode')) ? | ||
$exception->getStatusCode() : | ||
(method_exists($exception, 'getCode') && $exception->getCode() !== 0 ? $exception->getCode() : 500); | ||
} | ||
$event->setResponse( | ||
new JsonResponse((true === $this->debug || 500 !== $code) ? $exception->getMessage() : null, $code) | ||
); | ||
} | ||
|
||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
KernelEvents::EXCEPTION => ['onKernelException', 32], | ||
]; | ||
} | ||
} |
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,7 @@ | ||
<?php | ||
|
||
return [ | ||
ETNA\Json\JsonBundle::class => ['all' => true], | ||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], | ||
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], | ||
]; |
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,7 @@ | ||
framework: | ||
secret: '%env(APP_SECRET)%' | ||
|
||
php_errors: | ||
log: true | ||
|
||
test: true |
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,3 @@ | ||
controllers: | ||
resource: ../../app/Controller/ | ||
type: annotation |
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,31 @@ | ||
# 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: | ||
application_name: 'test_app' | ||
|
||
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. | ||
public: false # Allows optimizing the container by removing unused services; this also means | ||
# fetching services directly from the container via $container->get() won't work. | ||
# The best practice is to be explicit about your dependencies anyway. | ||
|
||
# makes classes in src/ available to be used as services | ||
# this creates a service per class whose id is the fully-qualified class name | ||
TestApp\: | ||
resource: '../app/*' | ||
exclude: '../app/{Entity,Migrations,Tests,Kernel.php}' | ||
|
||
# controllers are imported separately to make sure services can be injected | ||
# as action arguments even if you don't extend any base controller class | ||
TestApp\Controller\: | ||
resource: '../app/Controller' | ||
tags: ['controller.service_arguments'] | ||
|
||
# add more service definitions when explicit configuration is needed | ||
# please note that last definitions always *replace* previous ones | ||
|
||
json_request: | ||
class: 'ETNA\Json\Services\JsonRequestService' |
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,43 @@ | ||
default: | ||
formatters: | ||
progress: | ||
decorated: true | ||
verbose: true | ||
time: true | ||
language: fr | ||
output_path: null | ||
multiline_arguments: true | ||
|
||
suites: | ||
default: | ||
paths: | ||
- '%paths.base%/features/suites' | ||
contexts: | ||
- ETNA\FeatureContext\ApiContext | ||
extensions: | ||
Behat\Symfony2Extension: | ||
kernel: | ||
class: TestApp\Kernel | ||
env: testing | ||
|
||
ci: | ||
suites: | ||
default: | ||
paths: | ||
- '%paths.base%/features/suites' | ||
contexts: | ||
- ETNA\FeatureContext\CoverageContext: | ||
coverage_path: /tmp/behat/coverage | ||
whitelist: | ||
- src | ||
blacklist: | ||
- vendor | ||
- bin | ||
- tmp | ||
- Tests | ||
- ETNA\FeatureContext\ApiContext | ||
extensions: | ||
Behat\Symfony2Extension: | ||
kernel: | ||
class: TestApp\Kernel | ||
env: testing |
Oops, something went wrong.