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 #2 from adam-paterson/feature/tone-analyzer
Initial Tone Analyzer service
- Loading branch information
Showing
27 changed files
with
887 additions
and
8 deletions.
There are no files selected for viewing
Submodule .subsplit
added at
abfb97
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,23 @@ | ||
filter: | ||
excluded_paths: [Tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
|
||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
runs: 3 |
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 @@ | ||
preset: psr2 |
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,36 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
# This triggers builds to run on the new TravisCI infrastructure. | ||
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
sudo: false | ||
|
||
## Cache composer | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist | ||
|
||
script: | ||
- vendor/bin/phpcs --standard=psr2 --ignore=*/Tests/* src/ | ||
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
after_script: | ||
- | | ||
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' && "$TRAVIS_PHP_VERSION" != '7.0' ]]; then | ||
wget https://scrutinizer-ci.com/ocular.phar | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover | ||
fi |
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,76 @@ | ||
<?php | ||
|
||
|
||
namespace IBM\Watson\Common\Tests; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Handler\MockHandler; | ||
use GuzzleHttp\HandlerStack; | ||
use GuzzleHttp\Middleware; | ||
use GuzzleHttp\Psr7\Response; | ||
|
||
/** | ||
* Class TestCase | ||
* @package IBM\Watson\Common\Tests | ||
*/ | ||
abstract class TestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \GuzzleHttp\Client | ||
*/ | ||
private $httpClient; | ||
|
||
/** | ||
* @param string $path Mock response file | ||
* @param int $code Response code | ||
* @return Response | ||
*/ | ||
public function getMockHttpResponse($path, $code = 200) | ||
{ | ||
if ($path instanceof Response) { | ||
return $path; | ||
} | ||
|
||
$ref = new \ReflectionObject($this); | ||
$dir = dirname($ref->getFileName()); | ||
|
||
// if mock file doesn't exist, check parent directory | ||
if (!file_exists($dir . '/Mock/' . $path) && file_exists($dir . '/../Mock/' . $path)) { | ||
return new Response($code, [], file_get_contents($dir . '/../Mock/' . $path)); | ||
} | ||
|
||
return new Response($code, [], file_get_contents($dir . '/Mock/' . $path)); | ||
} | ||
|
||
/** | ||
* Get a mock HTTP client with history and mock responses | ||
* | ||
* @param mixed $container Responses container | ||
* @param $responses | ||
* @return Client | ||
*/ | ||
public function getMockHttpClientWithHistoryAndResponses(&$container, $responses) | ||
{ | ||
$mock = new MockHandler($responses); | ||
|
||
$stack = HandlerStack::create($mock); | ||
$history = Middleware::history($container); | ||
$stack->push($history); | ||
|
||
return new Client(['handler' => $stack]); | ||
} | ||
|
||
/** | ||
* Get HTTP client | ||
* | ||
* @return Client | ||
*/ | ||
public function getHttpClient() | ||
{ | ||
if (null === $this->httpClient) { | ||
$this->httpClient = new Client; | ||
} | ||
|
||
return $this->httpClient; | ||
} | ||
} |
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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="IBM Watson Common Test Suite"> | ||
<directory>/Tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
<exclude> | ||
<directory>s/Tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="tap" target="build/report.tap"/> | ||
<log type="junit" target="build/report.junit.xml"/> | ||
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/> | ||
<log type="coverage-text" target="build/coverage.txt"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</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,23 @@ | ||
filter: | ||
excluded_paths: [Tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
|
||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
runs: 3 |
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 @@ | ||
preset: psr2 |
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,36 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
# This triggers builds to run on the new TravisCI infrastructure. | ||
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
sudo: false | ||
|
||
## Cache composer | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist | ||
|
||
script: | ||
- vendor/bin/phpcs --standard=psr2 --ignore=*/Tests/* src/ | ||
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
after_script: | ||
- | | ||
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' && "$TRAVIS_PHP_VERSION" != '7.0' ]]; then | ||
wget https://scrutinizer-ci.com/ocular.phar | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover | ||
fi |
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,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Adam Paterson <hello@adampaterson.co.uk> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
Oops, something went wrong.