Skip to content

Commit

Permalink
Remove test of data providers, and replace `expectNotToPerformAsserti…
Browse files Browse the repository at this point in the history
…ons()` to `assertTrue(true)` for code coverage.
  • Loading branch information
terabytesoftw committed Mar 21, 2024
1 parent 4b12816 commit 3357e64
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 34 deletions.
4 changes: 2 additions & 2 deletions tests/framework/db/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1931,11 +1931,11 @@ public function legalValuesForFindByCondition()
*/
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()
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/db/oci/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public function testQuoteFullColumnName()

public function testTransactionIsolation()
{
$this->expectNotToPerformAssertions();

$connection = $this->getConnection(true);

$transaction = $connection->beginTransaction(Transaction::READ_COMMITTED);
$transaction->commit();

$transaction = $connection->beginTransaction(Transaction::SERIALIZABLE);
$transaction->commit();

$this->assertTrue(true);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/framework/di/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,34 +481,32 @@ public function testContainerSingletons()

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

/**
* @see https://github.com/yiisoft/yii2/issues/18245
*/
public function testDelayedInitializationOfSubArray()
{
$this->expectNotToPerformAssertions();

$definitions = [
'test' => [
'class' => Corge::className(),
Expand All @@ -534,6 +532,8 @@ public function testDelayedInitializationOfSubArray()

Yii::$container->set('setLater', new Qux());
Yii::$container->get('test');

$this->assertTrue(true);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/grid/GridViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ public function testFooter() {

public function testHeaderLabels()
{
$this->expectNotToPerformAssertions();

// Ensure GridView does not call Model::generateAttributeLabel() to generate labels unless the labels are explicitly used.
$this->mockApplication([
'components' => [
Expand Down Expand Up @@ -200,5 +198,7 @@ public function testHeaderLabels()
]);
$grid->renderTableHeader();
// If NoAutoLabels::generateAttributeLabel() has not been called no exception will be thrown meaning this test passed successfully.

$this->assertTrue(true);
}
}
4 changes: 2 additions & 2 deletions tests/framework/helpers/FileHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ public function testCopyDirToAnotherWithSameName()
*/
public function testCopyDirWithSameName()
{
$this->expectNotToPerformAssertions();

$this->createFileStructure([
'data' => [],
'data-backup' => [],
Expand All @@ -370,6 +368,8 @@ public function testCopyDirWithSameName()
$this->testFilePath . DIRECTORY_SEPARATOR . 'data',
$this->testFilePath . DIRECTORY_SEPARATOR . 'data-backup'
);

$this->assertTrue(true);
}

public function testRemoveDirectory()
Expand Down
12 changes: 4 additions & 8 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ public function testGetInputName()
}

/**
* @dataProvider testGetInputIdDataProvider
* @dataProvider getInputIdDataProvider
*/
public function testGetInputId($attributeName, $inputIdExpected)
{
Expand All @@ -2073,7 +2073,7 @@ public function testGetInputId($attributeName, $inputIdExpected)
}

/**
* @dataProvider testGetInputIdByNameDataProvider
* @dataProvider getInputIdByNameDataProvider
*/
public function testGetInputIdByName($attributeName, $inputIdExpected)
{
Expand Down Expand Up @@ -2182,10 +2182,8 @@ public function testOverrideSetActivePlaceholder()
$this->assertStringContainsString('placeholder="My placeholder: Name"', $html);
}

public function testGetInputIdDataProvider()
public static function getInputIdDataProvider()
{
$this->expectNotToPerformAssertions();

return [
[
'foo',
Expand Down Expand Up @@ -2223,10 +2221,8 @@ public function testGetInputIdDataProvider()
];
}

public function testGetInputIdByNameDataProvider()
public static function getInputIdByNameDataProvider()
{
$this->expectNotToPerformAssertions();

return [
[
'foo',
Expand Down
3 changes: 1 addition & 2 deletions tests/framework/helpers/IpHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public function expandIpv6Provider()
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());
}
Expand Down
7 changes: 3 additions & 4 deletions tests/framework/rest/UrlRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ public function testCreateUrl($ruleConfig, $tests)
}

/**
* @dataProvider testGetCreateUrlStatusProvider
* @dataProvider getCreateUrlStatusProvider
*
* @param array $ruleConfig
* @param array $tests
*/
Expand Down Expand Up @@ -413,10 +414,8 @@ public function testGetCreateUrlStatus($ruleConfig, $tests)
* - 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
Expand Down
7 changes: 3 additions & 4 deletions tests/framework/web/UrlRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,8 @@ protected function getTestsForToString()
}

/**
* @dataProvider testGetCreateUrlStatusProvider
* @dataProvider getCreateUrlStatusProvider
*
* @param array $config
* @param array $tests
*/
Expand Down Expand Up @@ -1329,10 +1330,8 @@ public function testGetCreateUrlStatus($config, $tests)
* - 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
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/widgets/ActiveFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ public function testOutputBuffering()

public function testRegisterClientScript()
{
$this->expectNotToPerformAssertions();

$this->mockWebApplication();
$_SERVER['REQUEST_URI'] = 'http://example.com/';

Expand All @@ -135,6 +133,8 @@ public function testRegisterClientScript()
$form->field($model, 'name');
$form::end();
ob_get_clean();

$this->assertTrue(true);
}

/**
Expand Down

0 comments on commit 3357e64

Please sign in to comment.