Some PSR2 code styling and test coverage enabled

This commit is contained in:
Michał Brzuchalski
2016-06-14 10:01:14 +02:00
parent b8bd71e265
commit 6e22a75a2e
10 changed files with 88 additions and 17 deletions

View File

@@ -1,4 +1,3 @@
# for php-coveralls # for php-coveralls
src_dir: src
coverage_clover: tests/coverage/clover.xml coverage_clover: tests/coverage/clover.xml
json_path: tests/coverage/coveralls-upload.json json_path: tests/coverage/coveralls-upload.json

21
build.xml Normal file
View File

@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<project name="nginx-configurator" default="test">
<target name="test" depends="-lint,-phpspec,-phpunit,-phpcs">
<exec command="bin/phpcov merge --clover tests/coverage/clover.xml tests/coverage/" checkreturn="true" passthru="true"/>
<exec command="bin/coveralls" checkreturn="true" passthru="true"/>
<exec command="bin/clover-dump --warning-percentage=70 --error-percentage=50 --fail-at=40 --ansi tests/coverage/clover.xml" checkreturn="true" passthru="true"/>
<exec command="bin/phpcov merge --html=tests/coverage/raport tests/coverage/"/>
</target>
<target name="-lint" hidden="true">
<exec command="bin/parallel-lint --exclude app --exclude vendor ." checkreturn="true" passthru="true"/>
</target>
<target name="-phpunit" hidden="true">
<exec command="bin/phpunit --coverage-php tests/coverage/phpunit.cov tests" checkreturn="true" passthru="true"/>
</target>
<target name="-phpspec" hidden="true">
<exec command="bin/phpspec run --format=pretty --no-code-generation" checkreturn="true" passthru="true"/>
</target>
<target name="-phpcs" hidden="true">
<exec command="bin/phpcs --colors -wp src --report=summary --standard=PSR2,phpcs.xml" checkreturn="true" passthru="true"/>
</target>
</project>

View File

@@ -6,19 +6,20 @@
"require": { "require": {
"madkom/collection": "^1.0", "madkom/collection": "^1.0",
"ferno/loco": "@dev", "ferno/loco": "@dev",
"madkom/uri": "^1.0" "madkom/uri": "^1.0",
"henrikbjorn/phpspec-code-coverage": "1.*"
}, },
"require-dev": { "require-dev": {
"phpspec/phpspec": "^2.5", "phpspec/phpspec": "^2.5",
"phpunit/phpunit": "~4", "phpunit/phpunit": "~4",
"knplabs/phpspec-welldone-extension": "dev-master", "knplabs/phpspec-welldone-extension": "dev-master",
"henrikbjorn/phpspec-code-coverage": "1.0.*",
"squizlabs/php_codesniffer": "^2.3", "squizlabs/php_codesniffer": "^2.3",
"phpunit/phpcov": "*", "phpunit/phpcov": "*",
"jakub-onderka/php-parallel-lint": "0.*", "jakub-onderka/php-parallel-lint": "0.*",
"jakub-onderka/php-console-highlighter": "0.*", "jakub-onderka/php-console-highlighter": "0.*",
"satooshi/php-coveralls": "dev-master", "satooshi/php-coveralls": "dev-master",
"clover/dump": "dev-master" "clover/dump": "dev-master",
"symfony/var-dumper": "^3.1"
}, },
"repositories": [ "repositories": [
{ {

View File

@@ -1,5 +1,15 @@
extensions:
- PhpSpec\Extension\CodeCoverageExtension
- Knp\PhpSpec\WellDone\Extension
suites: suites:
types: types:
namespace: Madkom\NginxConfigurator namespace: Madkom\NginxConfigurator
psr4_prefix: Madkom\NginxConfigurator psr4_prefix: Madkom\NginxConfigurator
spec_path: tests spec_path: tests
code_coverage:
output: tests/coverage/phpspec.cov
format: php
formatter.name: pretty

View File

@@ -5,15 +5,18 @@
* Date: 10.06.16 * Date: 10.06.16
* Time: 14:25 * Time: 14:25
*/ */
namespace Madkom\NginxConfigurator\Command; namespace Madkom\NginxConfigurator\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
/**
* Class AddLocationCommand
* @package Madkom\NginxConfigurator\Command
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
*/
class AddLocationCommand extends BaseCommand class AddLocationCommand extends BaseCommand
{ {
protected function configure() protected function configure()
@@ -23,11 +26,37 @@ class AddLocationCommand extends BaseCommand
$this->setDescription("Adds location context and configuration"); $this->setDescription("Adds location context and configuration");
$this->addArgument('name', InputArgument::OPTIONAL, 'Server hostname:port', 'localhost:80'); $this->addArgument('name', InputArgument::OPTIONAL, 'Server hostname:port', 'localhost:80');
$this->addOption('internal', null, InputOption::VALUE_NONE, 'Adds internal directive'); $this->addOption('internal', null, InputOption::VALUE_NONE, 'Adds internal directive');
$this->addOption('proxy_pass', null, InputOption::VALUE_OPTIONAL, 'Adds proxy_pass url <comment>(eg. http://proxy/)</comment>'); $this->addOption(
$this->addOption('proxy_bind', null, InputOption::VALUE_OPTIONAL, 'Adds proxy_bind directive url or variable <comment>(eg. $server_addr)</comment>'); 'proxy_pass',
$this->addOption('proxy_redirect', null, InputOption::VALUE_OPTIONAL ^ InputOption::VALUE_IS_ARRAY, 'Adds proxy_redirect directive <comment>(eg. http://$host or https://$host)</comment>'); null,
$this->addOption('proxy_set_header', null, InputOption::VALUE_OPTIONAL ^ InputOption::VALUE_IS_ARRAY, 'Adds proxy_set_header directive <comment>(eg. "Content-Type: text/html"</comment>'); InputOption::VALUE_OPTIONAL,
$this->addOption('proxy_pass_request_body', null, InputOption::VALUE_OPTIONAL, 'Adds proxy_pass_requeest_body directive <comment>(on|off)</comment>', 'on'); 'Adds proxy_pass url <comment>(eg. http://proxy/)</comment>'
);
$this->addOption(
'proxy_bind',
null,
InputOption::VALUE_OPTIONAL,
'Adds proxy_bind directive url or variable <comment>(eg. $server_addr)</comment>'
);
$this->addOption(
'proxy_redirect',
null,
InputOption::VALUE_OPTIONAL ^ InputOption::VALUE_IS_ARRAY,
'Adds proxy_redirect directive <comment>(eg. http://$host or https://$host)</comment>'
);
$this->addOption(
'proxy_set_header',
null,
InputOption::VALUE_OPTIONAL ^ InputOption::VALUE_IS_ARRAY,
'Adds proxy_set_header directive <comment>(eg. "Content-Type: text/html"</comment>'
);
$this->addOption(
'proxy_pass_request_body',
null,
InputOption::VALUE_OPTIONAL,
'Adds proxy_pass_requeest_body directive <comment>(on|off)</comment>',
'on'
);
// // new Directive('internal'), // // new Directive('internal'),
// new Directive('expires', [new Param('-1')]), // new Directive('expires', [new Param('-1')]),

View File

@@ -49,7 +49,7 @@ class AddServerCommand extends BaseCommand
$config->append($server); $config->append($server);
$builder = new Builder(); $builder = new Builder();
$builder->appendServerNode($server); $builder->append($server);
$builder->dumpFile($filename); $builder->dumpFile($filename);
} }
} }

View File

@@ -165,7 +165,7 @@ class Parser extends Grammar
* @throws GrammarException * @throws GrammarException
* @throws UnrecognizedContextException * @throws UnrecognizedContextException
*/ */
protected function parseSection($section, $space0 = null, $params, $open = null, $space1 = null, $directives) : Context protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context
{ {
switch ($section) { switch ($section) {
case 'server': case 'server':

11
test.conf Normal file
View File

@@ -0,0 +1,11 @@
server {
listen 90;
listen [::]:90 default ipv6only=on;
server_name test-ms;
}
server {
listen 90;
listen [::]:90 default ipv6only=on;
server_name test-ms;
}