1
0
mirror of https://github.com/ovh/php-ovh.git synced 2023-11-05 03:20:26 +01:00

Merge pull request #42 from shulard/feature/phing

Use a PHP build tool, Phing instead of Grunt.
This commit is contained in:
Vincent Cassé 2016-04-19 12:56:57 +02:00
commit aac96e68c1
8 changed files with 133 additions and 111 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ vendor
composer.lock
composer.phar
/phpunit.xml
/build.properties
/docs

View File

@ -15,4 +15,4 @@ before_script:
- composer self-update
- composer install
script: phpunit tests/ApiTest.php
script: vendor/bin/phing test -Donly.units=true

View File

@ -1,77 +0,0 @@
/**
* Gruntfile.js
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
php: {
dist: {
options: {
port: 8080,
base: 'web',
open: true,
keepalive: true
}
}
},
phpcs: {
application: {
dir: ['src/']
},
options: {
bin: 'vendor/bin/phpcs',
standard: 'PSR2'
}
},
phplint: {
options: {
swapPath: '/tmp'
},
all: ['src/*.php']
},
phpdocumentor: {
dist: {
options: {
directory: './src/',
bin: 'vendor/bin/phpdoc.php',
target: 'docs/'
}
}
},
clean: {
phpdocumentor: 'docs/'
},
phpunit: {
unit: {
dir: 'tests'
},
options: {
bin: 'vendor/bin/phpunit',
colors: true,
testdox: true
}
},
watch: {
scripts: {
files: ['src/*.php', 'src/**/*.php', 'tests/*.php', 'tests/**/*.php'],
tasks: ['precommit'],
},
},
});
grunt.loadNpmTasks('grunt-phpcs');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-phplint');
grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-phpdocumentor');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('phpdocs', [
'clean:phpdocumentor',
'phpdocumentor'
]);
grunt.registerTask('precommit', ['phplint:all', 'phpcs', 'phpunit:unit']);
grunt.registerTask('default', ['phplint:all', 'phpcs', 'phpunit:unit', 'phpdocs']);
grunt.registerTask('server', ['php']);
};

View File

@ -173,11 +173,10 @@ you can install local npm project in a clone a project
git clone https://github.com/ovh/php-ovh.git
cd php-ovh
php composer.phar install
npm install
To generate documentation, it's possible to use directly:
grunt default
vendor/bin/phing phpdocs
Documentation is available in docs/ directory.
@ -190,12 +189,15 @@ local npm project in a clone a project
git https://github.com/ovh/php-ovh.git
cd php-ovh
php composer.phar install
npm install
Edit **phpunit.xml** file with your credentials to pass functionals tests. Then,
you can run directly unit and functionals tests with grunt.
you can run directly unit and functionals tests with [phing](http://www.phing.info/).
grunt
vendor/bin/phing test
To skip functionals and run unit tests only, you can use the `only.units` option :
vendor/bin/phing test -Donly.units=true
Supported APIs
--------------

114
build.xml Normal file
View File

@ -0,0 +1,114 @@
<?xml version="1.0"?>
<project name="ovh/ovh" default="all">
<property name="base" value="${project.basedir}/" />
<property environment="env" />
<if>
<available file="${base}build.properties" property="" />
<then>
<property file="${base}build.properties" override="true" />
</then>
</if>
<!--##########################################################################################################-->
<target name="help">
<echo message="${phing.project.name} on [${git.branch}]" />
<echo message=" Available commands are:" />
<echo message=" test -> Run unit tests" />
<echo message=" clean -> Clean current environment" />
<echo message=" server -> Launch PHP built-in server" />
<echo message=" watch -> Run precommit task on every file changed" />
<echo message=" precommit -> Source code validation before commit" />
<echo message=" Specific tools tasks:" />
<echo message=" phpcs -> Run PHP Code Sniffer" />
<echo message=" phplint -> Run PHP Lint" />
<echo message=" phpdocs -> Run PHP Documentor" />
<echo message=" phpunit -> Run PHPUnit" />
</target>
<!--##########################################################################################################-->
<target name="test" description="Run unit tests">
<phingcall target="phpunit" />
</target>
<target name="clean" description="Clean current environment">
<delete dir="docs" includeemptydirs="true" verbose="true" failonerror="true" />
</target>
<target name="precommit" description="Source code validation before commit">
<phingcall target="phplint" />
<phingcall target="phpcs" />
<phingcall target="phpunit" />
</target>
<target name="all" description="Make a full integration check">
<phingcall target="phplint" />
<phingcall target="phpcs" />
<phingcall target="phpunit" />
<phingcall target="phpdocs" />
</target>
<!--##########################################################################################################-->
<target name="phpcs" description="Run PHP Code Sniffer">
<phpcodesniffer
standard="PSR2"
format="summary"
>
<fileset dir=".">
<include name="src/**/*.php"/>
<include name="test/**/*.php"/>
</fileset>
</phpcodesniffer>
</target>
<target name="phpcbf" description="Run PHP Code Sniffer">
<exec command="vendor/bin/phpcbf --standard=PSR2 src" logoutput="true" />
</target>
<target name="phplint" description="Run PHP Lint">
<phplint deprecatedAsError="true">
<fileset dir=".">
<include name="src/**/*.php"/>
<include name="test/**/*.php"/>
</fileset>
</phplint>
</target>
<target name="phpdocs" description="Run PHP Documentor" depends="clean">
<if>
<not><available file="docs" /></not>
<then>
<mkdir dir="docs" />
</then>
</if>
<phpdoc2 destdir="docs">
<fileset dir="src">
<include name="**/*.php" />
</fileset>
</phpdoc2>
</target>
<target name="phpunit" description="Run PHPUnit">
<if>
<and>
<isset property="only.units" />
<equals arg1="${only.units}" arg2="true" />
</and>
<then>
<fileset dir="tests" id="tests">
<include name="ApiTest.php"/>
</fileset>
</then>
<else>
<fileset dir="tests" id="tests">
<include name="**/*.php"/>
</fileset>
</else>
</if>
<phpunit
haltonfailure="true"
haltonerror="true"
bootstrap="tests/bootstrap.php"
printsummary="true"
>
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset refid="tests" />
</batchtest>
</phpunit>
</target>
<!--##########################################################################################################-->
</project>

View File

@ -11,6 +11,7 @@
"require-dev": {
"phpunit/phpunit": "4.*",
"phpdocumentor/phpdocumentor": "2.*",
"squizlabs/php_codesniffer": "1.*"
"squizlabs/php_codesniffer": "2.*",
"phing/phing": "^2.14"
}
}

View File

@ -1,15 +0,0 @@
{
"name": "ovh-ovh",
"version": "1.1.0",
"project": "Ovh",
"dependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-phpcs": "~0.2.2",
"grunt-php": "~0.3.2",
"grunt-phplint": "~0.0.5",
"grunt-phpunit": "~0.3.3",
"grunt-phpdocumentor": "~0.4.1",
"grunt-contrib-watch ": "~0.6.1"
}
}

View File

@ -228,7 +228,6 @@ class Api
$url = $this->endpoint . $path;
$request = new Request($method, $url);
if (isset($content) && $method == 'GET') {
$query_string = $request->getUri()->getQuery();
$query = array();
@ -243,14 +242,10 @@ class Api
$query = array_merge($query, (array)$content);
// rewrite query args to properly dump true/false parameters
foreach($query as $key => $value)
{
if ($value === false)
{
foreach ($query as $key => $value) {
if ($value === false) {
$query[$key] = "false";
}
elseif ($value === true)
{
} elseif ($value === true) {
$query[$key] = "true";
}
}