Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit 84ef54b

Browse files
Merge pull request #1 from guillermoandrae/master
Documentation, cleanup, verbosity messages.
2 parents 49c486e + 76da706 commit 84ef54b

8 files changed

Lines changed: 117 additions & 7 deletions

File tree

.scrutinizer.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tools:
2+
external_code_coverage: true
3+
php_sim: true
4+
php_pdepend: true
5+
php_analyzer: true
6+
php_code_sniffer:
7+
config:
8+
standard: "PSR2"
9+
filter:
10+
excluded_paths:
11+
- 'reports/*'
12+
- 'tests/*'
13+
- 'vendor/*'
14+
build_failure_conditions:
15+
- 'issues.label("coding-style").exists'
16+
- 'project.metric("scrutinizer.quality", < 8)'
17+
- 'project.metric("scrutinizer.test_coverage", < 0.80)'

.travis.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
language: php
2+
23
php:
34
- 5.5
5+
- 5.6
6+
- hhvm
7+
8+
sudo: false
9+
10+
matrix:
11+
fast_finish: true
12+
413
install:
5-
- composer install --no-interaction --prefer-source
14+
- composer install --no-interaction --prefer-source
15+
16+
script:
17+
- ./vendor/bin/phpunit --coverage-clover=coverage.clover
18+
19+
after_script:
20+
- wget https://scrutinizer-ci.com/ocular.phar
21+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Contributing
2+
3+
## Pull Requests
4+
5+
1. Create your own [fork](https://help.github.com/articles/fork-a-repo) of the repo.
6+
2. Send a pull request with your changes.
7+
8+
## Style Guide
9+
10+
All pull requests must adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Hampton Roads PHP
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
# hrphp-cli
2-
[![Build Status](https://api.travis-ci.org/hrphp/hrphp-cli.png?branch=master)](http://travis-ci.org/hrphp/hrphp-cli)
2+
[![Travis branch](https://img.shields.io/travis/hrphp/hrphp-cli.svg?style=flat)](https://travis-ci.org/hrphp/hrphp-cli) [![Coverage Status](http://img.shields.io/scrutinizer/coverage/g/hrphp/hrphp-cli.svg?style=flat)](https://scrutinizer-ci.com/g/hrphp/hrphp-cli/?branch=master) [![Code Quality](http://img.shields.io/scrutinizer/g/hrphp/hrphp-cli.svg?style=flat)](https://scrutinizer-ci.com/g/hrphp/hrphp-cli/?branch=master) [![HHVM](https://img.shields.io/hhvm/hrphp/hrphp-cli.svg?style=flat)](http://hhvm.h4cc.de/package/hrphp/hrphp-cli.json)
33

44
CLI tool for HRPHP related shenanigans.
5+
6+
## Usage
7+
You can use this tool in one of two ways.
8+
9+
You can execute the `hrphp` file in the `bin` directory:
10+
```
11+
./bin/hrphp <command>
12+
```
13+
14+
Or you can download and run the phar:
15+
```
16+
php hrphp.phar <command>
17+
```
18+
19+
Run the `list` command to see a list of available commands:
20+
```
21+
php hrphp.phar list
22+
```

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "hrphp/hrphp-cli",
33
"description": "CLI tool for HRPHP related shenanigans.",
44
"require": {
5-
"php": ">=5.5",
65
"symfony/console": "~2.6",
76
"phing/phing": "@stable",
87
"kherge/box": "~2.0",

src/library/Command/PingCommand.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,31 @@ public function getClient()
3737
return $this->client;
3838
}
3939

40+
/**
41+
* {@inheritdoc}
42+
*/
4043
protected function configure()
4144
{
4245
$this->setName('ping')
4346
->setDescription('Pings the HRPHP website');
4447
}
4548

49+
/**
50+
* {@inheritdoc}
51+
*/
4652
protected function execute(InputInterface $input, OutputInterface $output)
4753
{
4854
$output->writeln(sprintf('<info>%s command</info>', $this->getName()));
4955
$response = $this->getClient()->get(HRPHP_URL);
50-
/*
56+
5157
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
5258
$output->writeln(sprintf('Attempting to hit %s at %s...', HRPHP_URL, date('H:i:s A')));
5359
}
60+
5461
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
5562
$output->writeln(sprintf('Ping being sent from %s...', gethostname()));
5663
}
57-
*/
64+
5865
if ($response->getStatusCode() === 200) {
5966
$output->writeln(sprintf('%s is up!', HRPHP_URL));
6067
}

tests/library/Command/PingCommandTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use GuzzleHttp\Psr7\Response;
1515
use Hrphp\Cli\Command\PingCommand;
1616
use Symfony\Component\Console\Application;
17+
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Tester\CommandTester;
1819

1920
class PingCommandTest extends \PHPUnit_Framework_TestCase
@@ -34,6 +35,26 @@ public function testPing()
3435
self::assertContains(sprintf('%s is up!', HRPHP_URL), $output);
3536
}
3637

38+
public function testVerbosePing()
39+
{
40+
$commandTester = $this->getCommandTester(
41+
'ping',
42+
[ 'verbosity' => OutputInterface::VERBOSITY_VERBOSE ]
43+
);
44+
$output = $commandTester->getDisplay();
45+
self::assertContains('Attempting to hit', $output);
46+
}
47+
48+
public function testVeryVerbosePing()
49+
{
50+
$commandTester = $this->getCommandTester(
51+
'ping',
52+
[ 'verbosity' => OutputInterface::VERBOSITY_VERY_VERBOSE ]
53+
);
54+
$output = $commandTester->getDisplay();
55+
self::assertContains('Ping being sent from', $output);
56+
}
57+
3758
protected function setUp()
3859
{
3960
$command = new PingCommand($this->getClient());
@@ -58,13 +79,14 @@ protected function getClient()
5879

5980
/**
6081
* @param string $commandName
82+
* @param array $options
6183
* @return CommandTester
6284
*/
63-
protected function getCommandTester($commandName)
85+
protected function getCommandTester($commandName, array $options = [])
6486
{
6587
$command = $this->getApplication()->find($commandName);
6688
$commandTester = new CommandTester($command);
67-
$commandTester->execute(array_merge(array('command' => $commandName)));
89+
$commandTester->execute(['command' => $commandName], $options);
6890
return $commandTester;
6991
}
7092

0 commit comments

Comments
 (0)