mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
bump phpunit
This commit is contained in:
parent
9543b141ab
commit
a17fad62e7
14 changed files with 291 additions and 342 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,4 +2,4 @@
|
|||
.env
|
||||
vendor
|
||||
node_modules
|
||||
.php_cs.cache
|
||||
*.cache
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ dist: trusty
|
|||
sudo: false
|
||||
language: php
|
||||
php:
|
||||
- '7.1'
|
||||
- '7.3'
|
||||
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -16,7 +16,7 @@ mocha: node_modules
|
|||
|
||||
.PHONY: phpunit
|
||||
phpunit:
|
||||
cd test; DB_PORT=5433 DB_TYPE=pgsql DB_HOST=localhost DB_USERNAME=postgres DB_USERNAME=postgres DB_PASSWORD=test DB_DATABASE=postgres phpunit
|
||||
cd test; DB_PORT=5433 DB_TYPE=pgsql DB_HOST=localhost DB_USERNAME=postgres DB_USERNAME=postgres DB_PASSWORD=test DB_DATABASE=postgres ../vendor/bin/phpunit
|
||||
|
||||
.PHONY: test
|
||||
tests: phpunit mocha
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0",
|
||||
"phpunit/phpunit": "8.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.4",
|
||||
"phan/phan": "^1.2.1"
|
||||
}
|
||||
|
|
|
|||
537
composer.lock
generated
537
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,18 +11,20 @@ use Demostf\API\Demo\DemoStore;
|
|||
use Demostf\API\Providers\ChatProvider;
|
||||
use Demostf\API\Providers\DemoListProvider;
|
||||
use Demostf\API\Providers\DemoProvider;
|
||||
use \InvalidArgumentException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class DemoControllerTest extends ControllerTest {
|
||||
/** @var DemoStore|\PHPUnit_Framework_MockObject_MockObject $demoStore */
|
||||
/** @var DemoStore|MockObject $demoStore */
|
||||
private $demoStore;
|
||||
/** @var DemoProvider|\PHPUnit_Framework_MockObject_MockObject $demoProvider */
|
||||
/** @var DemoProvider|MockObject $demoProvider */
|
||||
private $demoProvider;
|
||||
/** @var ChatProvider|\PHPUnit_Framework_MockObject_MockObject $chatProvider */
|
||||
/** @var ChatProvider|MockObject $chatProvider */
|
||||
private $chatProvider;
|
||||
/** @var DemoListProvider|\PHPUnit_Framework_MockObject_MockObject $demoListProvider */
|
||||
/** @var DemoListProvider|MockObject $demoListProvider */
|
||||
private $demoListProvider;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->demoStore = $this->createMock(DemoStore::class);
|
||||
|
|
@ -79,10 +81,6 @@ class DemoControllerTest extends ControllerTest {
|
|||
$this->assertResponseData(['dummy']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Invalid key
|
||||
*/
|
||||
public function testSetDemoUrlInvalidKey() {
|
||||
$controller = $this->getController([], [
|
||||
'hash' => 'foo',
|
||||
|
|
@ -92,13 +90,12 @@ class DemoControllerTest extends ControllerTest {
|
|||
'key' => 'invalid',
|
||||
]);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Invalid key");
|
||||
|
||||
$controller->setDemoUrl('1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Invalid demo hash
|
||||
*/
|
||||
public function testSetDemoUrlInvalidHash() {
|
||||
$controller = $this->getController([], [
|
||||
'hash' => 'invalidhash',
|
||||
|
|
@ -108,6 +105,9 @@ class DemoControllerTest extends ControllerTest {
|
|||
'key' => 'supersecretkey',
|
||||
]);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Invalid demo hash");
|
||||
|
||||
$demo = $this->createConfiguredMock(Demo::class, [
|
||||
'getHash' => 'validhash',
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace Demostf\API\Test\Demo;
|
|||
use Demostf\API\Demo\Header;
|
||||
use Demostf\API\Demo\HeaderParser;
|
||||
use Demostf\API\Test\TestCase;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class HeaderParserTest extends TestCase {
|
||||
public function testParseFile() {
|
||||
|
|
@ -40,28 +41,25 @@ class HeaderParserTest extends TestCase {
|
|||
$this->assertEquals($expected->getVersion(), $parsed->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Not an HL2 demo
|
||||
*/
|
||||
public function testNonDemoShort() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Not an HL2 demo");
|
||||
|
||||
$parser = new HeaderParser();
|
||||
$parser->parseString('short');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Not an HL2 demo
|
||||
*/
|
||||
public function testNonDemoLong() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Not an HL2 demo");
|
||||
|
||||
$parser = new HeaderParser();
|
||||
$parser->parseHeader(__FILE__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testNonExisting() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$parser = new HeaderParser();
|
||||
$parser->parseHeader('/non/existing');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ namespace Demostf\API\Test\Demo;
|
|||
use Demostf\API\Demo\Parser;
|
||||
use Demostf\API\Demo\RawParser;
|
||||
use Demostf\API\Test\TestCase;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class ParserTest extends TestCase {
|
||||
/** @var RawParser|\PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var RawParser|MockObject */
|
||||
private $rawParser;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->rawParser = $this->getMockBuilder(RawParser::class)
|
||||
|
|
@ -60,10 +62,9 @@ class ParserTest extends TestCase {
|
|||
$this->assertEquals($expectedKills[0]['weapon'], $result->getKills()[0]->getWeapon());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFailedParse() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
/** @var RawParser|\PHPUnit_Framework_MockObject_MockObject $rawParser */
|
||||
$rawParser = $this->getMockBuilder(RawParser::class)
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ChatProviderTest extends TestCase {
|
|||
/** @var ChatProvider */
|
||||
private $provider;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->provider = new ChatProvider($this->getDatabaseConnection());
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DemoListProviderTest extends TestCase {
|
|||
/** @var UserProvider */
|
||||
private $userProvider;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->demoListProvider = new DemoListProvider($this->getDatabaseConnection());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class DemoProviderTest extends TestCase {
|
|||
/** @var KillProvider */
|
||||
private $killProvider;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->provider = new DemoProvider($this->getDatabaseConnection());
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use Demostf\API\Providers\UploadProvider;
|
|||
use Demostf\API\Providers\UserProvider;
|
||||
use Demostf\API\Test\TestCase;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class UploadProviderTest extends TestCase {
|
||||
/** @var RawParser */
|
||||
|
|
@ -41,7 +42,7 @@ class UploadProviderTest extends TestCase {
|
|||
/** @var string */
|
||||
private $tmpDir;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->rawParser = $this->getMockBuilder(RawParser::class)
|
||||
|
|
@ -104,7 +105,7 @@ class UploadProviderTest extends TestCase {
|
|||
rmdir($dir);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown(): void {
|
||||
$this->rmdirr($this->tmpDir);
|
||||
|
||||
parent::tearDown();
|
||||
|
|
@ -212,11 +213,10 @@ class UploadProviderTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Not an HL2 demo
|
||||
*/
|
||||
public function testUploadNonDemo() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Not an HL2 demo");
|
||||
|
||||
file_put_contents($this->tmpDir . '/foo.dem', 'asd');
|
||||
|
||||
$steamId = $this->getSteamId('123', 'a');
|
||||
|
|
@ -310,11 +310,10 @@ class UploadProviderTest extends TestCase {
|
|||
$this->assertEquals(3, $demo->getRedScore());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Not an HL2 demo
|
||||
*/
|
||||
public function testUploadKey() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Not an HL2 demo");
|
||||
|
||||
$uploadProvider = new UploadProvider(
|
||||
$this->getDatabaseConnection(),
|
||||
'http://example.com',
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class UserProviderTest extends TestCase {
|
|||
/** @var \SteamId */
|
||||
private $steamId;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->steamId = $this->getSteamId('76561198024494988', 'Icewind');
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
|
|||
return $this->database;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown(): void {
|
||||
$this->clearDatabase();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue