Skip to content

Commit

Permalink
add: test & cs config
Browse files Browse the repository at this point in the history
upd: code styling
  • Loading branch information
j-schumann committed Oct 10, 2017
1 parent dd59264 commit 2826513
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer.lock
vendor/
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
sudo: false

language: php

cache:
directories:
- $HOME/.composer/cache
- $HOME/.local

env:
global:
- COMPOSER_ARGS="--no-interaction --prefer-source"
- CS_CHECK=true

matrix:
include:
- php: 7.1
env:
- TEST_COVERAGE=true
- php: 7.2

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi

install:
- travis_retry composer install $COMPOSER_ARGS
- composer info

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

The project follows Semantic Versioning (http://semver.org/)

## 2.1.0 - 2017-10-10
### Added
- test, code coverage and code styling config

### Changed
- dependencies

## 2.0.0 - 2017-02-02
### Changed
- require PHP 7.1+
Expand Down
30 changes: 23 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,41 @@
"homepage": "http://www.vrok.de/",
"keywords": ["supervisor", "supervisord", "zend", "zf3"],
"minimum-stability": "dev",
"prefer-stable": true,

"autoload": {
"psr-4": {
"SupervisorControl\\": "src/"
}
},
"require": {
"php": ">=7.1",
"mondalaci/supervisor-client": "dev-master",
"zendframework/zend-component-installer": "^0.6.0",
"zendframework/zend-mvc": "^3.0.4",
"zendframework/zend-mvc": "^3.1.0",
"zendframework/zend-mvc-console": "^1.1.11",
"zendframework/zend-mvc-form": "^1.0.0",
"zendframework/zend-mvc-plugin-flashmessenger": "^1.0.0"
},
"autoload": {
"psr-4": {
"SupervisorControl\\": "src/"
}
"require-dev": {
"phpunit/PHPUnit": "^6.4.1",
"zendframework/zend-coding-standard": "~1.0.0"
},
"extra": {
"branch-alias": {
"dev-dev": "1.1.x-dev",
"dev-master": "1.0.x-dev"
"dev-dev": "3.0.x-dev",
"dev-master": "2.1.x-dev"
}
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
}
}
8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
</ruleset>
24 changes: 24 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./test/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="translation-module Test Suite">
<directory>./test/</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
13 changes: 7 additions & 6 deletions src/Client/SupervisorClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getGroupConfig()
foreach ($config as $process) {
$groupName = $process['group'];

if (!isset($groups[$groupName])) {
if (! isset($groups[$groupName])) {
$groups[$groupName] = [
'name' => $groupName,
'priority' => $process['group_prio'],
Expand Down Expand Up @@ -118,7 +118,7 @@ public function getProcessFQN($name)
}

$config = $this->getProcessConfig($name);
if (!$config) {
if (! $config) {
return;
}

Expand All @@ -136,7 +136,7 @@ public function getProcessFQN($name)
public function getProcessInfo($processName)
{
$fqn = $this->getProcessFQN($processName);
if (!$fqn) {
if (! $fqn) {
return;
}

Expand All @@ -153,7 +153,7 @@ public function getProcessInfo($processName)
public function getProcessState($name)
{
$fqn = $this->getProcessFQN($name);
if (!$fqn) {
if (! $fqn) {
return self::PROCESS_STATE_UNKNOWN;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public function isProcessRunning($name)
*/
public function getProcessInfos(array $names, $reload = false)
{
if ($reload || !$this->processInfo) {
if ($reload || ! $this->processInfo) {
$this->processInfo = $this->getAllProcessInfo();
}
$infos = [];
Expand Down Expand Up @@ -223,11 +223,12 @@ public function getProcessInfos(array $names, $reload = false)
* @param string $method The method in the namespace
* @param mixed $args Optional arguments
*/
// @codingStandardsIgnoreLine
protected function _doRequest($namespace, $method, $args)
{
// Create the authorization header.
$authorization = '';
if (!is_null($this->_username) && !is_null($this->_password)) {
if (! is_null($this->_username) && ! is_null($this->_password)) {
$authorization = "\r\nAuthorization: Basic ".base64_encode($this->_username.':'.$this->_password);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Controller/SupervisorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function restartAction()
$form = new ConfirmationForm();
$form->setData($this->request->getPost());

if (!$this->request->isPost() || !$form->isValid()) {
if (! $this->request->isPost() || ! $form->isValid()) {
return [
'form' => $form,
];
Expand Down Expand Up @@ -93,7 +93,7 @@ public function stopallAction()
$form = new ConfirmationForm();
$form->setData($this->request->getPost());

if (!$this->request->isPost() || !$form->isValid()) {
if (! $this->request->isPost() || ! $form->isValid()) {
return [
'form' => $form,
];
Expand All @@ -115,7 +115,7 @@ public function groupAction()
$name = $this->params('name');

$groups = $this->supervisorClient->getGroupConfig();
if (!isset($groups[$name])) {
if (! isset($groups[$name])) {
$this->flashMessenger()->addErrorMessage('Group "'.$name.'" not found!');

return $this->redirect()->toRoute('supervisor');
Expand Down Expand Up @@ -164,7 +164,7 @@ public function stopgroupAction()
$form = new ConfirmationForm();
$form->setData($this->request->getPost());

if (!$this->request->isPost() || !$form->isValid()) {
if (! $this->request->isPost() || ! $form->isValid()) {
return [
'name' => $name,
'form' => $form,
Expand Down Expand Up @@ -219,7 +219,7 @@ public function stopProcessAction()
$form = new ConfirmationForm();
$form->setData($this->request->getPost());

if (!$this->request->isPost() || !$form->isValid()) {
if (! $this->request->isPost() || ! $form->isValid()) {
return [
'name' => $name,
'form' => $form,
Expand Down
1 change: 1 addition & 0 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php

0 comments on commit 2826513

Please sign in to comment.