Remove test of data providers, and replace expectNotToPerformAssertions() to assertTrue(true) for code coverage.

This commit is contained in:
Wilmer Arambula
2024-03-21 09:56:54 -03:00
parent 4b1281618a
commit 3357e64ee6
10 changed files with 27 additions and 34 deletions

View File

@ -1931,11 +1931,11 @@ abstract class ActiveRecordTest extends DatabaseTestCase
*/ */
public function testLegalValuesForFindByCondition($modelClassName, $validFilter) public function testLegalValuesForFindByCondition($modelClassName, $validFilter)
{ {
$this->expectNotToPerformAssertions();
/** @var Query $query */ /** @var Query $query */
$query = $this->invokeMethod(\Yii::createObject($modelClassName), 'findByCondition', [$validFilter]); $query = $this->invokeMethod(\Yii::createObject($modelClassName), 'findByCondition', [$validFilter]);
Customer::getDb()->queryBuilder->build($query); Customer::getDb()->queryBuilder->build($query);
$this->assertTrue(true);
} }
public function illegalValuesForFindByCondition() public function illegalValuesForFindByCondition()

View File

@ -78,8 +78,6 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest
public function testTransactionIsolation() public function testTransactionIsolation()
{ {
$this->expectNotToPerformAssertions();
$connection = $this->getConnection(true); $connection = $this->getConnection(true);
$transaction = $connection->beginTransaction(Transaction::READ_COMMITTED); $transaction = $connection->beginTransaction(Transaction::READ_COMMITTED);
@ -87,6 +85,8 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest
$transaction = $connection->beginTransaction(Transaction::SERIALIZABLE); $transaction = $connection->beginTransaction(Transaction::SERIALIZABLE);
$transaction->commit(); $transaction->commit();
$this->assertTrue(true);
} }
/** /**

View File

@ -481,25 +481,25 @@ class ContainerTest extends TestCase
public function testVariadicConstructor() public function testVariadicConstructor()
{ {
$this->expectNotToPerformAssertions();
if (\defined('HHVM_VERSION')) { if (\defined('HHVM_VERSION')) {
static::markTestSkipped('Can not test on HHVM because it does not support variadics.'); static::markTestSkipped('Can not test on HHVM because it does not support variadics.');
} }
$container = new Container(); $container = new Container();
$container->get('yiiunit\framework\di\stubs\Variadic'); $container->get('yiiunit\framework\di\stubs\Variadic');
$this->assertTrue(true);
} }
public function testVariadicCallable() public function testVariadicCallable()
{ {
$this->expectNotToPerformAssertions();
if (\defined('HHVM_VERSION')) { if (\defined('HHVM_VERSION')) {
static::markTestSkipped('Can not test on HHVM because it does not support variadics.'); static::markTestSkipped('Can not test on HHVM because it does not support variadics.');
} }
require __DIR__ . '/testContainerWithVariadicCallable.php'; require __DIR__ . '/testContainerWithVariadicCallable.php';
$this->assertTrue(true);
} }
/** /**
@ -507,8 +507,6 @@ class ContainerTest extends TestCase
*/ */
public function testDelayedInitializationOfSubArray() public function testDelayedInitializationOfSubArray()
{ {
$this->expectNotToPerformAssertions();
$definitions = [ $definitions = [
'test' => [ 'test' => [
'class' => Corge::className(), 'class' => Corge::className(),
@ -534,6 +532,8 @@ class ContainerTest extends TestCase
Yii::$container->set('setLater', new Qux()); Yii::$container->set('setLater', new Qux());
Yii::$container->get('test'); Yii::$container->get('test');
$this->assertTrue(true);
} }
/** /**

View File

@ -155,8 +155,6 @@ class GridViewTest extends \yiiunit\TestCase
public function testHeaderLabels() public function testHeaderLabels()
{ {
$this->expectNotToPerformAssertions();
// Ensure GridView does not call Model::generateAttributeLabel() to generate labels unless the labels are explicitly used. // Ensure GridView does not call Model::generateAttributeLabel() to generate labels unless the labels are explicitly used.
$this->mockApplication([ $this->mockApplication([
'components' => [ 'components' => [
@ -200,5 +198,7 @@ class GridViewTest extends \yiiunit\TestCase
]); ]);
$grid->renderTableHeader(); $grid->renderTableHeader();
// If NoAutoLabels::generateAttributeLabel() has not been called no exception will be thrown meaning this test passed successfully. // If NoAutoLabels::generateAttributeLabel() has not been called no exception will be thrown meaning this test passed successfully.
$this->assertTrue(true);
} }
} }

View File

@ -359,8 +359,6 @@ class FileHelperTest extends TestCase
*/ */
public function testCopyDirWithSameName() public function testCopyDirWithSameName()
{ {
$this->expectNotToPerformAssertions();
$this->createFileStructure([ $this->createFileStructure([
'data' => [], 'data' => [],
'data-backup' => [], 'data-backup' => [],
@ -370,6 +368,8 @@ class FileHelperTest extends TestCase
$this->testFilePath . DIRECTORY_SEPARATOR . 'data', $this->testFilePath . DIRECTORY_SEPARATOR . 'data',
$this->testFilePath . DIRECTORY_SEPARATOR . 'data-backup' $this->testFilePath . DIRECTORY_SEPARATOR . 'data-backup'
); );
$this->assertTrue(true);
} }
public function testRemoveDirectory() public function testRemoveDirectory()

View File

@ -2060,7 +2060,7 @@ EOD;
} }
/** /**
* @dataProvider testGetInputIdDataProvider * @dataProvider getInputIdDataProvider
*/ */
public function testGetInputId($attributeName, $inputIdExpected) public function testGetInputId($attributeName, $inputIdExpected)
{ {
@ -2073,7 +2073,7 @@ EOD;
} }
/** /**
* @dataProvider testGetInputIdByNameDataProvider * @dataProvider getInputIdByNameDataProvider
*/ */
public function testGetInputIdByName($attributeName, $inputIdExpected) public function testGetInputIdByName($attributeName, $inputIdExpected)
{ {
@ -2182,10 +2182,8 @@ HTML;
$this->assertStringContainsString('placeholder="My placeholder: Name"', $html); $this->assertStringContainsString('placeholder="My placeholder: Name"', $html);
} }
public function testGetInputIdDataProvider() public static function getInputIdDataProvider()
{ {
$this->expectNotToPerformAssertions();
return [ return [
[ [
'foo', 'foo',
@ -2223,10 +2221,8 @@ HTML;
]; ];
} }
public function testGetInputIdByNameDataProvider() public static function getInputIdByNameDataProvider()
{ {
$this->expectNotToPerformAssertions();
return [ return [
[ [
'foo', 'foo',

View File

@ -54,9 +54,8 @@ class IpHelperTest extends TestCase
public function testIpv6ExpandingWithInvalidValue() public function testIpv6ExpandingWithInvalidValue()
{ {
try { try {
$this->expectNotToPerformAssertions();
IpHelper::expandIPv6('fa01::1/64'); IpHelper::expandIPv6('fa01::1/64');
$this->assertTrue(true);
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->assertStringEndsWith('Unrecognized address fa01::1/64', $exception->getMessage()); $this->assertStringEndsWith('Unrecognized address fa01::1/64', $exception->getMessage());
} }

View File

@ -376,7 +376,8 @@ class UrlRuleTest extends TestCase
} }
/** /**
* @dataProvider testGetCreateUrlStatusProvider * @dataProvider getCreateUrlStatusProvider
*
* @param array $ruleConfig * @param array $ruleConfig
* @param array $tests * @param array $tests
*/ */
@ -413,10 +414,8 @@ class UrlRuleTest extends TestCase
* - second element is the expected URL * - second element is the expected URL
* - third element is the expected result of getCreateUrlStatus() method * - third element is the expected result of getCreateUrlStatus() method
*/ */
public function testGetCreateUrlStatusProvider() public static function getCreateUrlStatusProvider()
{ {
$this->expectNotToPerformAssertions();
return [ return [
'single controller' => [ 'single controller' => [
// rule properties // rule properties

View File

@ -1292,7 +1292,8 @@ class UrlRuleTest extends TestCase
} }
/** /**
* @dataProvider testGetCreateUrlStatusProvider * @dataProvider getCreateUrlStatusProvider
*
* @param array $config * @param array $config
* @param array $tests * @param array $tests
*/ */
@ -1329,10 +1330,8 @@ class UrlRuleTest extends TestCase
* - third element is the expected URL * - third element is the expected URL
* - fourth element is the expected result of getCreateUrlStatus() method * - fourth element is the expected result of getCreateUrlStatus() method
*/ */
public function testGetCreateUrlStatusProvider() public static function getCreateUrlStatusProvider()
{ {
$this->expectNotToPerformAssertions();
return [ return [
'route' => [ 'route' => [
// rule properties // rule properties

View File

@ -110,8 +110,6 @@ HTML
public function testRegisterClientScript() public function testRegisterClientScript()
{ {
$this->expectNotToPerformAssertions();
$this->mockWebApplication(); $this->mockWebApplication();
$_SERVER['REQUEST_URI'] = 'http://example.com/'; $_SERVER['REQUEST_URI'] = 'http://example.com/';
@ -135,6 +133,8 @@ HTML
$form->field($model, 'name'); $form->field($model, 'name');
$form::end(); $form::end();
ob_get_clean(); ob_get_clean();
$this->assertTrue(true);
} }
/** /**