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)
{
$this->expectNotToPerformAssertions();
/** @var Query $query */
$query = $this->invokeMethod(\Yii::createObject($modelClassName), 'findByCondition', [$validFilter]);
Customer::getDb()->queryBuilder->build($query);
$this->assertTrue(true);
}
public function illegalValuesForFindByCondition()

View File

@ -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);
}
/**

View File

@ -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);
}
/**

View File

@ -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);
}
}

View File

@ -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()

View File

@ -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',

View File

@ -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());
}

View File

@ -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

View File

@ -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

View File

@ -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);
}
/**