diff --git a/.codeclimate.sh b/.codeclimate.sh new file mode 100644 index 0000000..47d1c2e --- /dev/null +++ b/.codeclimate.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +php vendor/bin/test-reporter --stdout > codeclimate.json +curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..a5ec711 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,13 @@ +engines: + phpcodesniffer: + enabled: true + config: + file_extensions: "php" + phpmd: + enabled: true + config: + file_extensions: "php" + standard: "PSR1,Squiz" +ratings: + paths: + - "SourceQuery/**.php" diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..94f019a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: php +php: + - 5.5 + - 5.6 + - hhvm + - nightly + +notifications: + email: false + +install: + - composer install --dev --no-interaction +script: + - phpunit --configuration Tests/.phpunit.xml --verbose +after_script: + - ./.codeclimate.sh diff --git a/Tests/.phpunit.xml b/Tests/.phpunit.xml new file mode 100644 index 0000000..f0a722f --- /dev/null +++ b/Tests/.phpunit.xml @@ -0,0 +1,11 @@ + + + + + ./Tests.php + + + + + + diff --git a/Tests/Tests.php b/Tests/Tests.php new file mode 100644 index 0000000..d02b008 --- /dev/null +++ b/Tests/Tests.php @@ -0,0 +1,71 @@ +NextOutput ) === 0 ) + { + throw new InvalidPacketException( 'Buffer is empty', InvalidPacketException::BUFFER_EMPTY ); + } + + $Buffer = new Buffer( ); + $Buffer->Set( $this->NextOutput ); + + $this->NextOutput = ''; + + return $Buffer; + } + } + + class SourceQueryTests extends PHPUnit_Framework_TestCase + { + private $Socket; + private $SourceQuery; + + public function setUpBeforeClass() + { + $this->Socket = new TestableSocket(); + $this->SourceQuery = new SourceQuery( $this->Socket ); + $this->SourceQuery->Connect( 1, 2 ); + } + + /** + * @dataProvider InfoProvider + */ + public function testGetInfo( $RawInput, $ExpectedOutput ) + { + $this->Socket->NextOutput = $RawInput; + + $RealOutput = $this->SourceQuery->GetInfo(); + + $this->assertEquals( $ExpectedOutput, $RealOutput ); + } + + public function InfoProvider() + { + // read from Tests/Info/ folder + } + } diff --git a/composer.json b/composer.json index 6f023f1..82c6b48 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,11 @@ { "php": ">=5.5" }, + "require-dev": + { + "phpunit/phpunit": "5.0.*", + "codeclimate/php-test-reporter": "dev-master" + }, "autoload": { "psr-4":