Skip to content

Commit

Permalink
Update php, phpunit and statan's versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Grebenschikov committed Jun 1, 2021
1 parent e2f0c8b commit 547e050
Show file tree
Hide file tree
Showing 26 changed files with 103 additions and 152 deletions.
7 changes: 4 additions & 3 deletions composer.json
Expand Up @@ -10,6 +10,7 @@
}
],
"require": {
"badoo/liveprof": "^1.3",
"php": ">=7.0",
"symfony/dependency-injection": "~3.0|~4.0",
"symfony/config": "~3.0|~4.0",
Expand All @@ -21,9 +22,9 @@
"ext-zlib": "*"
},
"require-dev": {
"phpunit/phpunit": "5.*",
"phpstan/phpstan": "^0.9.2",
"vimeo/psalm": "^1"
"phpunit/phpunit": "~9.5.4",
"phpstan/phpstan": "~0.12.88",
"vimeo/psalm": "~4.7.2"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -27,7 +27,7 @@ services:

web:
restart: always
build: './docker/web72'
build: 'docker/web'
command:
php -S 0.0.0.0:8000 -t src/www/ src/www/router.php
ports:
Expand Down
2 changes: 1 addition & 1 deletion docker/web72/Dockerfile → docker/web/Dockerfile
@@ -1,4 +1,4 @@
FROM php:7.2
FROM php:8.0
MAINTAINER Timur Shagiakhmetov <timur.shagiakhmetov@corp.badoo.com>

RUN apt-get update && apt-get -y install git-core unzip \
Expand Down
43 changes: 15 additions & 28 deletions phpunit.xml
@@ -1,29 +1,16 @@
<phpunit bootstrap="tests/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
cacheTokens="false"
verbose="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
processIsolation="false"
stopOnSkipped="false"
>
<testsuites>
<testsuite>
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/Badoo</directory>
<exclude>
<directory suffix=".php">src/Badoo/ConsoleCommands</directory>
</exclude>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" backupGlobals="false" backupStaticAttributes="false" verbose="true" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" processIsolation="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/Badoo</directory>
</include>
<exclude>
<directory suffix=".php">src/Badoo/ConsoleCommands</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion tests/unit/Badoo/BaseTestCase.php
Expand Up @@ -21,7 +21,7 @@ class BaseTestCase extends \PHPUnit\Framework\TestCase
/**
* @throws \Exception
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

Expand Down
38 changes: 18 additions & 20 deletions tests/unit/Badoo/LiveProfilerUI/AggregatorTest.php
Expand Up @@ -321,9 +321,9 @@ public function testProcessPerfdata($data, $methods, $call_map, $method_data, $e
$this->setProtectedProperty($AggregatorMock, 'fields', $FieldList->getFields());
$result = $this->invokeMethod($AggregatorMock, 'processPerfdata', [$data]);

self::assertAttributeEquals($methods, 'methods', $AggregatorMock);
self::assertAttributeEquals($call_map, 'call_map', $AggregatorMock);
self::assertAttributeEquals($method_data, 'method_data', $AggregatorMock);
self::assertEquals($methods, $this->getProtectedProperty($AggregatorMock, 'methods'));
self::assertEquals($call_map, $this->getProtectedProperty($AggregatorMock, 'call_map'));
self::assertEquals($method_data, $this->getProtectedProperty($AggregatorMock, 'method_data'));

static::assertEquals($expected, $result);
}
Expand Down Expand Up @@ -439,8 +439,8 @@ public function testAggregate($call_map, $method_data, $expected_call_map, $expe

$this->invokeMethod($AggregatorMock, 'aggregate', []);

self::assertAttributeEquals($expected_call_map, 'call_map', $AggregatorMock);
self::assertAttributeEquals($expected_method_data, 'method_data', $AggregatorMock);
self::assertEquals($expected_call_map, $this->getProtectedProperty($AggregatorMock, 'call_map'));
self::assertEquals($expected_method_data, $this->getProtectedProperty($AggregatorMock, 'method_data'));
}

/**
Expand Down Expand Up @@ -613,7 +613,7 @@ public function testSaveTree($insert_result, $expected)
*/
public function testGetAndPopulateMethodNamesMap()
{
$method_names = ['method' => 1];
$method_names = ['method' => ['date' => 1]];
$AggregatorMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\Aggregator::class)
->disableOriginalConstructor()
->setMethods(['getMethodNamesMap', 'pushToMethodNamesMap'])
Expand All @@ -629,7 +629,7 @@ public function testGetAndPopulateMethodNamesMap()
$method_names = ['method'];
$result = $this->invokeMethod($AggregatorMock, 'getAndPopulateMethodNamesMap', [$method_names]);

$expected = ['method' => 1];
$expected = ['method' => ['date' => 1]];
self::assertEquals($expected, $result);
}

Expand Down Expand Up @@ -725,19 +725,19 @@ public function providerCreateOrUpdateSnapshot()
return [
[
'exists_snapshot' => null,
'update_result' => 1,
'update_result' => true,
'create_result' => 1,
'expected' => 1
],
[
'exists_snapshot' => null,
'update_result' => 1,
'update_result' => true,
'create_result' => 0,
'expected' => false
],
[
'exists_snapshot' => $SnapshotMock,
'update_result' => 1,
'update_result' => true,
'create_result' => 0,
'expected' => 2
]
Expand Down Expand Up @@ -795,7 +795,7 @@ public function providerSaveResult() : array
[
'method_data' => 'method_data',
'delete_result' => true,
'create_result' => true,
'create_result' => 1,
'save_tree' => true,
'save_data' => true,
'error_msg' => [],
Expand All @@ -804,7 +804,7 @@ public function providerSaveResult() : array
[
'method_data' => 'method_data',
'delete_result' => false,
'create_result' => true,
'create_result' => 1,
'save_tree' => true,
'save_data' => true,
'error_msg' => ['Can\'t delete old data'],
Expand All @@ -813,7 +813,7 @@ public function providerSaveResult() : array
[
'method_data' => 'method_data',
'delete_result' => true,
'create_result' => false,
'create_result' => 0,
'save_tree' => true,
'save_data' => true,
'error_msg' => ['Can\'t create or update snapshot'],
Expand All @@ -822,7 +822,7 @@ public function providerSaveResult() : array
[
'method_data' => 'method_data',
'delete_result' => true,
'create_result' => true,
'create_result' => 1,
'save_tree' => false,
'save_data' => true,
'error_msg' => ['Can\'t save tree data'],
Expand All @@ -831,7 +831,7 @@ public function providerSaveResult() : array
[
'method_data' => 'method_data',
'delete_result' => true,
'create_result' => true,
'create_result' => 1,
'save_tree' => true,
'save_data' => false,
'error_msg' => ['Can\'t save method data'],
Expand All @@ -840,7 +840,7 @@ public function providerSaveResult() : array
[
'method_data' => null,
'delete_result' => true,
'create_result' => true,
'create_result' => 1,
'save_tree' => true,
'save_data' => true,
'error_msg' => ['Empty method data'],
Expand Down Expand Up @@ -984,12 +984,10 @@ public function testGetSnapshotsDataForProcessing($processed, $new, $expected)
static::assertEquals($expected, $result);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Num of days must be > 0
*/
public function testGetSnapshotsDataForProcessingError()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Num of days must be > 0');
/** @var \Badoo\LiveProfilerUI\Aggregator $AggregatorMock */
$AggregatorMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\Aggregator::class)
->disableOriginalConstructor()
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/Badoo/LiveProfilerUI/DB/DBUtilsTest.php
Expand Up @@ -68,12 +68,10 @@ public function testPrepareCreateTablesPgsql()
self::assertEquals($expected, $result);
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Not supported db type: invalid
*/
public function testPrepareCreateTablesInvalidType()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Not supported db type: invalid');
\Badoo\LiveProfilerUI\DB\SqlTableBuilder::prepareCreateTables('invalid', '', ['wt'], 'ct');
}
}
44 changes: 15 additions & 29 deletions tests/unit/Badoo/LiveProfilerUI/DB/StorageTest.php
Expand Up @@ -11,7 +11,7 @@ class StorageTest extends \unit\Badoo\BaseTestCase
/** @var \Badoo\LiveProfilerUI\DB\Storage */
protected $Storage;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -64,39 +64,31 @@ public function testGetSelectQueryBuilder(array $fields, array $params, string $
self::assertEquals($expected, $QueryBuilder->getSql());
}

/**
* @expectedException \Badoo\LiveProfilerUI\Exceptions\DatabaseException
* @expectedExceptionMessage Can't insert into details
*/
public function testInsertError()
{
$this->expectException(\Badoo\LiveProfilerUI\Exceptions\DatabaseException::class);
$this->expectExceptionMessage('Can\'t insert into details');
$this->Storage->insert('details', ['a' => 1]);
}

/**
* @expectedException \Badoo\LiveProfilerUI\Exceptions\DatabaseException
* @expectedExceptionMessage Can't insert into details
*/
public function testInsertManyError()
{
$this->expectException(\Badoo\LiveProfilerUI\Exceptions\DatabaseException::class);
$this->expectExceptionMessage('Can\'t insert into details');
$this->Storage->insertMany('details', [['a' => 1]]);
}

/**
* @expectedException \Badoo\LiveProfilerUI\Exceptions\InvalidFieldValueException
* @expectedExceptionMessage Can't insert empty data
*/
public function testInsertManyEmptyData()
{
$this->expectException(\Badoo\LiveProfilerUI\Exceptions\InvalidFieldValueException::class);
$this->expectExceptionMessage('Can\'t insert empty data');
$this->Storage->insertMany('details', []);
}

/**
* @expectedException \Badoo\LiveProfilerUI\Exceptions\InvalidFieldValueException
* @expectedExceptionMessage Can't insert empty data
*/
public function testInsertManyEmptyOneOfData()
{
$this->expectException(\Badoo\LiveProfilerUI\Exceptions\InvalidFieldValueException::class);
$this->expectExceptionMessage('Can\'t insert empty data');
$this->Storage->insertMany('details', [[]]);
}

Expand All @@ -111,30 +103,24 @@ public function testMultiQuery()
self::assertTrue($result);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Can't delete without any conditions
*/
public function testDeleteEmptyData()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Can\'t delete without any conditions');
$this->Storage->delete('details', []);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Can't update without any conditions
*/
public function testUpdateEmptyParams()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Can\'t update without any conditions');
$this->Storage->update('details', ['a' => 1], []);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Can't update without any fields
*/
public function testUpdateEmptyFields()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Can\'t update without any fields');
$this->Storage->update('details', [], ['a' => 1]);
}

Expand Down
Expand Up @@ -18,12 +18,10 @@ public function testValidate()
self::assertTrue($result);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid order direction: Invalid
*/
public function testValidateError()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid order direction: Invalid');
$direction = 'Invalid';
Direction::validate($direction);
}
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/Badoo/LiveProfilerUI/DB/Validators/FieldTest.php
Expand Up @@ -18,12 +18,10 @@ public function testValidate()
self::assertTrue($result);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid field: _123_
*/
public function testValidateError()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid field: _123_');
$field = '_123_';
Field::validate($field);
}
Expand Down
Expand Up @@ -18,12 +18,10 @@ public function testValidate()
self::assertTrue($result);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid function name: div
*/
public function testValidateError()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid function name: div');
$function = 'div';
Functions::validate($function);
}
Expand Down
Expand Up @@ -18,12 +18,10 @@ public function testValidate()
self::assertTrue($result);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid operator: !!
*/
public function testValidateError()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid operator: !!');
$operator = '!!';
Operator::validate($operator);
}
Expand Down

0 comments on commit 547e050

Please sign in to comment.