parent
6a94bcb6a6
commit
a5f54674d0
@ -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
|
@ -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"
|
@ -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
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="Tests">
|
||||
<file>./Tests.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="../build/logs/clover.xml"/>
|
||||
</logging>
|
||||
</phpunit>
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require __DIR__ . '/../SourceQuery/bootstrap.php';
|
||||
|
||||
use xPaw\SourceQuery\BaseSocket;
|
||||
use xPaw\SourceQuery\Exception\InvalidPacketException;
|
||||
use xPaw\SourceQuery\SourceQuery;
|
||||
|
||||
class TestableSocket extends BaseSocket
|
||||
{
|
||||
public $NextOutput = '';
|
||||
|
||||
public function Close( )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function Open( $Ip, $Port, $Timeout, $Engine )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function Write( $Header, $String = '' )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function Read( $Length = 1400 )
|
||||
{
|
||||
if( strlen( $this->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
|
||||
}
|
||||
}
|
Loading…
Reference in new issue