diff --git a/composer.json b/composer.json index 2e1add7..ca88ef0 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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": { diff --git a/docker-compose.yml b/docker-compose.yml index 2803ec4..6d08422 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/docker/web72/Dockerfile b/docker/web/Dockerfile similarity index 98% rename from docker/web72/Dockerfile rename to docker/web/Dockerfile index 767287b..df7cec0 100644 --- a/docker/web72/Dockerfile +++ b/docker/web/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.2 +FROM php:8.0 MAINTAINER Timur Shagiakhmetov RUN apt-get update && apt-get -y install git-core unzip \ diff --git a/phpunit.xml b/phpunit.xml index 913f8fd..a593ca3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,29 +1,16 @@ - - - - tests/unit - - - - - src/Badoo - - src/Badoo/ConsoleCommands - - - + + + + + src/Badoo + + + src/Badoo/ConsoleCommands + + + + + tests/unit + + diff --git a/tests/unit/Badoo/BaseTestCase.php b/tests/unit/Badoo/BaseTestCase.php index 985d968..518f99f 100644 --- a/tests/unit/Badoo/BaseTestCase.php +++ b/tests/unit/Badoo/BaseTestCase.php @@ -21,7 +21,7 @@ class BaseTestCase extends \PHPUnit\Framework\TestCase /** * @throws \Exception */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/unit/Badoo/LiveProfilerUI/AggregatorTest.php b/tests/unit/Badoo/LiveProfilerUI/AggregatorTest.php index 0749938..39f1620 100644 --- a/tests/unit/Badoo/LiveProfilerUI/AggregatorTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/AggregatorTest.php @@ -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); } @@ -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')); } /** @@ -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']) @@ -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); } @@ -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 ] @@ -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' => [], @@ -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'], @@ -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'], @@ -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'], @@ -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'], @@ -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'], @@ -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() diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/DBUtilsTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/DBUtilsTest.php index 00eeac2..1382e73 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/DBUtilsTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/DBUtilsTest.php @@ -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'); } } diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/StorageTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/StorageTest.php index e9c8a99..3273c31 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/StorageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/StorageTest.php @@ -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(); @@ -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', [[]]); } @@ -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]); } diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/DirectionTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/DirectionTest.php index cff77d9..9dd2a4c 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/DirectionTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/DirectionTest.php @@ -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); } diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FieldTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FieldTest.php index 6eb1300..9b65118 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FieldTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FieldTest.php @@ -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); } diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FunctionsTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FunctionsTest.php index 0ef3228..19f1edf 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FunctionsTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/FunctionsTest.php @@ -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); } diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/OperatorTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/OperatorTest.php index fb8b674..f584437 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/OperatorTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/OperatorTest.php @@ -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); } diff --git a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/TableTest.php b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/TableTest.php index 1dc3abf..55ccd65 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DB/Validators/TableTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DB/Validators/TableTest.php @@ -18,12 +18,10 @@ public function testValidate() self::assertTrue($result); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid table name: table - */ public function testValidateError() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid table name: table'); $table = 'table'; Table::validate($table); } diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/FileSourceTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/FileSourceTest.php index de5191a..c91988b 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/FileSourceTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/FileSourceTest.php @@ -14,7 +14,7 @@ class FileSourceTest extends \unit\Badoo\BaseTestCase /** @var \Badoo\LiveProfilerUI\Interfaces\DataPackerInterface */ protected $DataPacker; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -61,7 +61,7 @@ protected function setUp() $this->DataPacker = new \Badoo\LiveProfilerUI\DataPacker(); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/JobTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/JobTest.php index beb541b..438cdd2 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/JobTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/JobTest.php @@ -15,7 +15,7 @@ class JobTest extends \unit\Badoo\BaseTestCase protected $AggregatorStorage; protected $FieldList; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -51,12 +51,10 @@ public function testGetSnapshotsDataByDates() self::assertEquals($expected, $result); } - /** - * @expectedExceptionMessage Can't get job - * @expectedException \InvalidArgumentException - */ public function testGetNotExistsJob() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Can\'t get job'); $Source = new \Badoo\LiveProfilerUI\DataProviders\Job($this->AggregatorStorage, $this->FieldList); $result = $Source->getJob('app2', 'label2', '2019-01-02', ['new']); diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodDataTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodDataTest.php index 2e5a012..6b6e32c 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodDataTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodDataTest.php @@ -15,7 +15,7 @@ class MethodDataTest extends \unit\Badoo\BaseTestCase protected $AggregatorStorage; protected $FieldList; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTest.php index 7d4e493..538ec24 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTest.php @@ -13,7 +13,7 @@ class MethodTest extends \unit\Badoo\BaseTestCase protected $AggregatorStorage; protected $FieldList; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTreeTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTreeTest.php index 4eb2393..75dabf1 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTreeTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/MethodTreeTest.php @@ -15,7 +15,7 @@ class MethodTreeTest extends \unit\Badoo\BaseTestCase protected $AggregatorStorage; protected $FieldList; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/SnapshotTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/SnapshotTest.php index 9102683..838f59e 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/SnapshotTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/SnapshotTest.php @@ -15,7 +15,7 @@ class SnapshotTest extends \unit\Badoo\BaseTestCase protected $AggregatorStorage; protected $FieldList; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -129,12 +129,10 @@ public function testGetLastSnapshots() self::assertEquals($expected, $result); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Can't get snapshot - */ public function testGetOneById() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Can\'t get snapshot'); $Snapshot = new \Badoo\LiveProfilerUI\DataProviders\Snapshot($this->AggregatorStorage, $this->FieldList); $result = $Snapshot->getOneById(5); @@ -191,12 +189,10 @@ public function testListByIdsResult() self::assertEquals($expected, $result); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Can't get snapshot - */ public function testGetOneByAppAndLabel() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Can\'t get snapshot'); $Snapshot = new \Badoo\LiveProfilerUI\DataProviders\Snapshot($this->AggregatorStorage, $this->FieldList); $Snapshot->getOneByAppAndLabel('app', 'label'); } @@ -210,12 +206,10 @@ public function testGetOneByAppAndLabelResult() self::assertInstanceOf(\Badoo\LiveProfilerUI\Entity\Snapshot::class, $result); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Can't get snapshot - */ public function testGetOneByAppAndLabelAndDate() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Can\'t get snapshot'); $Snapshot = new \Badoo\LiveProfilerUI\DataProviders\Snapshot($this->AggregatorStorage, $this->FieldList); $result = $Snapshot->getOneByAppAndLabelAndDate('app', 'label', 'date'); diff --git a/tests/unit/Badoo/LiveProfilerUI/DataProviders/SourceTest.php b/tests/unit/Badoo/LiveProfilerUI/DataProviders/SourceTest.php index 7f548f2..bba5c86 100644 --- a/tests/unit/Badoo/LiveProfilerUI/DataProviders/SourceTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/DataProviders/SourceTest.php @@ -12,7 +12,7 @@ class SourceTest extends \unit\Badoo\BaseTestCase protected $SourceStorage; protected $DataPacker; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/AjaxPagesTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/AjaxPagesTest.php index 029cac3..c85c9ce 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/AjaxPagesTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/AjaxPagesTest.php @@ -15,7 +15,7 @@ public function providerRebuildSnapshot() : array return [ 'exists_job' => [ 'exists_job' => new Job(['id' => 1]), - 'add_result' => true, + 'add_result' => 0, 'expected' => [ 'status' => false, 'message' => 'Job for snapshot (app, label, date) is already exists' @@ -23,7 +23,7 @@ public function providerRebuildSnapshot() : array ], 'successfully_added' => [ 'exists_job' => null, - 'add_result' => true, + 'add_result' => 1, 'expected' => [ 'status' => true, 'message' => 'Added a job for aggregating a snapshot (app, label, date)' @@ -31,7 +31,7 @@ public function providerRebuildSnapshot() : array ], 'add_error' => [ 'exists_job' => null, - 'add_result' => false, + 'add_result' => 0, 'expected' => [ 'status' => false, 'message' => 'Error in the snapshot (app, label, date) aggregating' @@ -43,11 +43,11 @@ public function providerRebuildSnapshot() : array /** * @dataProvider providerRebuildSnapshot * @param Job|null $ExistsJob - * @param bool $add_result + * @param ште $add_result * @param array $expected * @throws \ReflectionException */ - public function testRebuildSnapshot($ExistsJob, $add_result, $expected) + public function testRebuildSnapshot(?Job $ExistsJob, int $add_result, array $expected) { $JobMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\DataProviders\Job::class) ->disableOriginalConstructor() diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/FlameGraphPageTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/FlameGraphPageTest.php index 3e8247b..e3fb4f4 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/FlameGraphPageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/FlameGraphPageTest.php @@ -35,10 +35,10 @@ public function providerInvalidData() : array * @param $label * @param $snapshot_id * @throws \ReflectionException - * @expectedException \InvalidArgumentException */ public function testInvalidData($app, $label, $snapshot_id) { + $this->expectException(\InvalidArgumentException::class); $StorageMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\DB\Storage::class) ->disableOriginalConstructor() ->setMethods(['getOne']) @@ -217,7 +217,7 @@ public function providerCalculateParamThreshold() : array ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); - $MethodTreeMock->method('getValue')->willReturn(200); + $MethodTreeMock->method('getValue')->willReturn(200.0); $data = []; for ($i = 0; $i < 3001; $i++) { $data[$i] = $MethodTreeMock; diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php index f354551..544a46e 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php @@ -35,11 +35,11 @@ public function providerInvalidData() * @param $label * @param $snapshot_id * @throws \ReflectionException - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Can't get snapshot */ public function testInvalidData($app, $label, $snapshot_id) { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Can\'t get snapshot'); $StorageMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\DB\Storage::class) ->disableOriginalConstructor() ->setMethods(['getOne']) @@ -189,12 +189,13 @@ public function testCleanData() } /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Empty snapshot_id, app and label * @throws \ReflectionException */ public function testCleanDataInvalidData() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Empty snapshot_id, app and label'); + $PageMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\Pages\ProfileMethodListPage::class) ->disableOriginalConstructor() ->setMethods(['__construct']) diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php index cb9bf7a..19d88ae 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php @@ -468,12 +468,12 @@ public function testCleanData() } /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Empty snapshot_id, app and label * @throws \ReflectionException */ public function testCleanDataInvalidData() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Empty snapshot_id, app and label'); $PageMock = $this->getMockBuilder(\Badoo\LiveProfilerUI\Pages\ProfileMethodTreePage::class) ->disableOriginalConstructor() ->setMethods(['__construct']) diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/SnapshotsDiffPageTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/SnapshotsDiffPageTest.php index 00806d1..49a4cd5 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/SnapshotsDiffPageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/SnapshotsDiffPageTest.php @@ -80,11 +80,11 @@ public function testGetTemplateData() /** * @throws \Exception - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Diff functionality is not available */ public function testGetSnapshotsDiffNotSupported() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Diff functionality is not available'); $FieldList = new \Badoo\LiveProfilerUI\FieldList(['wt', 'ct'], [], []); $data = [ @@ -238,7 +238,7 @@ public function providerGetSnapshotsDiff() ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); - $MethodTreeMock->method('getValue')->willReturn(200); + $MethodTreeMock->method('getValue')->willReturn(200.0); return [ [ diff --git a/tests/unit/Badoo/LiveProfilerUI/ViewTest.php b/tests/unit/Badoo/LiveProfilerUI/ViewTest.php index edcd2ae..3ca2e47 100644 --- a/tests/unit/Badoo/LiveProfilerUI/ViewTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/ViewTest.php @@ -8,12 +8,10 @@ class ViewTest extends \unit\Badoo\BaseTestCase { - /** - * @expectedException \Exception - * @expectedExceptionMessage Template file not found - */ public function testFetchFileWrongTemplate() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Template file not found'); $View = new \Badoo\LiveProfilerUI\View(); $View->fetchFile('wrong_template', []); } @@ -43,6 +41,6 @@ public function testFetchFile($use_layout, $expected) $View = new \Badoo\LiveProfilerUI\View($use_layout); $result = $View->fetchFile('error', ['error' => 'test error']); - self::assertContains($expected, $result); + self::assertStringContainsString($expected, $result); } }