From 3357e64ee664f0b9d038ccd213f837d9e75f2cea Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Thu, 21 Mar 2024 09:56:54 -0300 Subject: [PATCH] Remove test of data providers, and replace `expectNotToPerformAssertions()` to `assertTrue(true)` for code coverage. --- tests/framework/db/ActiveRecordTest.php | 4 ++-- tests/framework/db/oci/ConnectionTest.php | 4 ++-- tests/framework/di/ContainerTest.php | 12 ++++++------ tests/framework/grid/GridViewTest.php | 4 ++-- tests/framework/helpers/FileHelperTest.php | 4 ++-- tests/framework/helpers/HtmlTest.php | 12 ++++-------- tests/framework/helpers/IpHelperTest.php | 3 +-- tests/framework/rest/UrlRuleTest.php | 7 +++---- tests/framework/web/UrlRuleTest.php | 7 +++---- tests/framework/widgets/ActiveFormTest.php | 4 ++-- 10 files changed, 27 insertions(+), 34 deletions(-) diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index 264212a08c..389f470c76 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -1931,11 +1931,11 @@ abstract class ActiveRecordTest extends DatabaseTestCase */ public function testLegalValuesForFindByCondition($modelClassName, $validFilter) { - $this->expectNotToPerformAssertions(); - /** @var Query $query */ $query = $this->invokeMethod(\Yii::createObject($modelClassName), 'findByCondition', [$validFilter]); Customer::getDb()->queryBuilder->build($query); + + $this->assertTrue(true); } public function illegalValuesForFindByCondition() diff --git a/tests/framework/db/oci/ConnectionTest.php b/tests/framework/db/oci/ConnectionTest.php index 0b1a5f0d03..76992cce91 100644 --- a/tests/framework/db/oci/ConnectionTest.php +++ b/tests/framework/db/oci/ConnectionTest.php @@ -78,8 +78,6 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest public function testTransactionIsolation() { - $this->expectNotToPerformAssertions(); - $connection = $this->getConnection(true); $transaction = $connection->beginTransaction(Transaction::READ_COMMITTED); @@ -87,6 +85,8 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest $transaction = $connection->beginTransaction(Transaction::SERIALIZABLE); $transaction->commit(); + + $this->assertTrue(true); } /** diff --git a/tests/framework/di/ContainerTest.php b/tests/framework/di/ContainerTest.php index b4c425b089..ba62b598b7 100644 --- a/tests/framework/di/ContainerTest.php +++ b/tests/framework/di/ContainerTest.php @@ -481,25 +481,25 @@ class ContainerTest extends TestCase public function testVariadicConstructor() { - $this->expectNotToPerformAssertions(); - if (\defined('HHVM_VERSION')) { static::markTestSkipped('Can not test on HHVM because it does not support variadics.'); } $container = new Container(); $container->get('yiiunit\framework\di\stubs\Variadic'); + + $this->assertTrue(true); } public function testVariadicCallable() { - $this->expectNotToPerformAssertions(); - if (\defined('HHVM_VERSION')) { static::markTestSkipped('Can not test on HHVM because it does not support variadics.'); } require __DIR__ . '/testContainerWithVariadicCallable.php'; + + $this->assertTrue(true); } /** @@ -507,8 +507,6 @@ class ContainerTest extends TestCase */ public function testDelayedInitializationOfSubArray() { - $this->expectNotToPerformAssertions(); - $definitions = [ 'test' => [ 'class' => Corge::className(), @@ -534,6 +532,8 @@ class ContainerTest extends TestCase Yii::$container->set('setLater', new Qux()); Yii::$container->get('test'); + + $this->assertTrue(true); } /** diff --git a/tests/framework/grid/GridViewTest.php b/tests/framework/grid/GridViewTest.php index e151e257d4..cdf63756c8 100644 --- a/tests/framework/grid/GridViewTest.php +++ b/tests/framework/grid/GridViewTest.php @@ -155,8 +155,6 @@ class GridViewTest extends \yiiunit\TestCase public function testHeaderLabels() { - $this->expectNotToPerformAssertions(); - // Ensure GridView does not call Model::generateAttributeLabel() to generate labels unless the labels are explicitly used. $this->mockApplication([ 'components' => [ @@ -200,5 +198,7 @@ class GridViewTest extends \yiiunit\TestCase ]); $grid->renderTableHeader(); // If NoAutoLabels::generateAttributeLabel() has not been called no exception will be thrown meaning this test passed successfully. + + $this->assertTrue(true); } } diff --git a/tests/framework/helpers/FileHelperTest.php b/tests/framework/helpers/FileHelperTest.php index d13e57e821..c8b3f34427 100644 --- a/tests/framework/helpers/FileHelperTest.php +++ b/tests/framework/helpers/FileHelperTest.php @@ -359,8 +359,6 @@ class FileHelperTest extends TestCase */ public function testCopyDirWithSameName() { - $this->expectNotToPerformAssertions(); - $this->createFileStructure([ 'data' => [], 'data-backup' => [], @@ -370,6 +368,8 @@ class FileHelperTest extends TestCase $this->testFilePath . DIRECTORY_SEPARATOR . 'data', $this->testFilePath . DIRECTORY_SEPARATOR . 'data-backup' ); + + $this->assertTrue(true); } public function testRemoveDirectory() diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 6bb38ccc65..c8d3646681 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -2060,7 +2060,7 @@ EOD; } /** - * @dataProvider testGetInputIdDataProvider + * @dataProvider getInputIdDataProvider */ public function testGetInputId($attributeName, $inputIdExpected) { @@ -2073,7 +2073,7 @@ EOD; } /** - * @dataProvider testGetInputIdByNameDataProvider + * @dataProvider getInputIdByNameDataProvider */ public function testGetInputIdByName($attributeName, $inputIdExpected) { @@ -2182,10 +2182,8 @@ HTML; $this->assertStringContainsString('placeholder="My placeholder: Name"', $html); } - public function testGetInputIdDataProvider() + public static function getInputIdDataProvider() { - $this->expectNotToPerformAssertions(); - return [ [ 'foo', @@ -2223,10 +2221,8 @@ HTML; ]; } - public function testGetInputIdByNameDataProvider() + public static function getInputIdByNameDataProvider() { - $this->expectNotToPerformAssertions(); - return [ [ 'foo', diff --git a/tests/framework/helpers/IpHelperTest.php b/tests/framework/helpers/IpHelperTest.php index ae90bb6a05..fb6b1e4037 100644 --- a/tests/framework/helpers/IpHelperTest.php +++ b/tests/framework/helpers/IpHelperTest.php @@ -54,9 +54,8 @@ class IpHelperTest extends TestCase public function testIpv6ExpandingWithInvalidValue() { try { - $this->expectNotToPerformAssertions(); - IpHelper::expandIPv6('fa01::1/64'); + $this->assertTrue(true); } catch (\Exception $exception) { $this->assertStringEndsWith('Unrecognized address fa01::1/64', $exception->getMessage()); } diff --git a/tests/framework/rest/UrlRuleTest.php b/tests/framework/rest/UrlRuleTest.php index f2c5b4b6a8..9cc39935f7 100644 --- a/tests/framework/rest/UrlRuleTest.php +++ b/tests/framework/rest/UrlRuleTest.php @@ -376,7 +376,8 @@ class UrlRuleTest extends TestCase } /** - * @dataProvider testGetCreateUrlStatusProvider + * @dataProvider getCreateUrlStatusProvider + * * @param array $ruleConfig * @param array $tests */ @@ -413,10 +414,8 @@ class UrlRuleTest extends TestCase * - second element is the expected URL * - third element is the expected result of getCreateUrlStatus() method */ - public function testGetCreateUrlStatusProvider() + public static function getCreateUrlStatusProvider() { - $this->expectNotToPerformAssertions(); - return [ 'single controller' => [ // rule properties diff --git a/tests/framework/web/UrlRuleTest.php b/tests/framework/web/UrlRuleTest.php index f1d2dd6ee2..1602f4eff5 100644 --- a/tests/framework/web/UrlRuleTest.php +++ b/tests/framework/web/UrlRuleTest.php @@ -1292,7 +1292,8 @@ class UrlRuleTest extends TestCase } /** - * @dataProvider testGetCreateUrlStatusProvider + * @dataProvider getCreateUrlStatusProvider + * * @param array $config * @param array $tests */ @@ -1329,10 +1330,8 @@ class UrlRuleTest extends TestCase * - third element is the expected URL * - fourth element is the expected result of getCreateUrlStatus() method */ - public function testGetCreateUrlStatusProvider() + public static function getCreateUrlStatusProvider() { - $this->expectNotToPerformAssertions(); - return [ 'route' => [ // rule properties diff --git a/tests/framework/widgets/ActiveFormTest.php b/tests/framework/widgets/ActiveFormTest.php index 4cca48b68f..313b345907 100644 --- a/tests/framework/widgets/ActiveFormTest.php +++ b/tests/framework/widgets/ActiveFormTest.php @@ -110,8 +110,6 @@ HTML public function testRegisterClientScript() { - $this->expectNotToPerformAssertions(); - $this->mockWebApplication(); $_SERVER['REQUEST_URI'] = 'http://example.com/'; @@ -135,6 +133,8 @@ HTML $form->field($model, 'name'); $form::end(); ob_get_clean(); + + $this->assertTrue(true); } /**