Skip to content

Commit

Permalink
Raise min version to PHP 7.3, check compatibility PHP 8.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Oct 4, 2023
1 parent cf7807d commit bda07df
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 132 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
],
"minimum-stability": "stable",
"require": {
"php": ">=7.0",
"php": ">=7.3",
"ext-json": "*",
"yiisoft/yii2": "^2.0.42",
"bower-asset/bootstrap": "^5.1.0"
},
"require-dev": {
"yiisoft/yii2-coding-standards": "~2.0",
"phpunit/phpunit": "^6.5.14",
"phpunit/phpunit": "^9.6",
"twbs/bootstrap-icons": "^1.7.2"
},
"suggest": {
Expand Down
37 changes: 25 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./tests/bootstrap.php"
colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>

<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Yii2-Bootstrap5">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
26 changes: 16 additions & 10 deletions tests/AccordionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ public function invalidItemsProvider()

/**
* @dataProvider invalidItemsProvider
* @expectedException \yii\base\InvalidConfigException
*/
public function testMissingLabel($items)
{
Accordion::widget([
'items' => $items,
]);
$this->expectException(InvalidConfigException::class);
$this->expectExceptionMessage("The 'label' option is required.");

Accordion::widget(['items' => $items]);
}

/**
Expand Down Expand Up @@ -278,12 +278,12 @@ public function testAutoCloseItems()
$output = Accordion::widget([
'items' => $items
]);
$this->assertContains('data-bs-parent="', $output);
$this->assertStringContainsString('data-bs-parent="', $output);
$output = Accordion::widget([
'autoCloseItems' => false,
'items' => $items
]);
$this->assertNotContains('data-bs-parent="', $output);
$this->assertStringNotContainsString('data-bs-parent="', $output);
}

/**
Expand All @@ -310,8 +310,11 @@ public function testItemToggleTag()
'class' => 'custom-toggle',
],
]);
$this->assertContains('<h5 class="mb-0"><a type="button" class="custom-toggle" href="#w0-collapse0" ', $output);
$this->assertNotContains('<button', $output);
$this->assertStringContainsString(
'<h5 class="mb-0"><a type="button" class="custom-toggle" href="#w0-collapse0" ',
$output,
);
$this->assertStringNotContainsString('<button', $output);

$output = Accordion::widget([
'items' => $items,
Expand All @@ -320,7 +323,10 @@ public function testItemToggleTag()
'class' => ['widget' => 'custom-toggle'],
],
]);
$this->assertContains('<h5 class="mb-0"><a type="button" class="custom-toggle" href="#w1-collapse0" ', $output);
$this->assertNotContains('collapse-toggle', $output);
$this->assertStringContainsString(
'<h5 class="mb-0"><a type="button" class="custom-toggle" href="#w1-collapse0" ',
$output,
);
$this->assertStringNotContainsString('collapse-toggle', $output);
}
}
8 changes: 4 additions & 4 deletions tests/ActiveFieldDefaultFormCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ public function testHorizontalLayout()
HTML;


$this->assertContainsWithoutLE($expected, $out);
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
$this->assertStringContainsString($expected, $out);
$this->assertStringContainsString($expected2, $out);
$this->assertStringContainsString($expected3, $out);
}

protected function setUp()
protected function setUp(): void
{
// dirty way to have Request object not throwing exception when running testHomeLinkNull()
$_SERVER['SCRIPT_FILENAME'] = 'index.php';
Expand Down
6 changes: 3 additions & 3 deletions tests/ActiveFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function testRadioListItemOptions()
]
])->render();

$this->assertContains('data-attribute="test"', $content);
$this->assertStringContainsString('data-attribute="test"', $content);
}

/**
Expand All @@ -306,10 +306,10 @@ public function testCheckboxListItemOptions()
]
])->render();

$this->assertContains('data-attribute="test"', $content);
$this->assertStringContainsString('data-attribute="test"', $content);
}

protected function setUp()
protected function setUp(): void
{
// dirty way to have Request object not throwing exception when running testHomeLinkNull()
$_SERVER['SCRIPT_FILENAME'] = "index.php";
Expand Down
49 changes: 24 additions & 25 deletions tests/ActiveFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function testDefaultLayout()
</div>
HTML;


$this->assertContainsWithoutLE($expected, $out);
$this->assertStringContainsString($expected, $out);
}

public function testHorizontalLayout()
Expand Down Expand Up @@ -109,9 +108,9 @@ public function testHorizontalLayout()
HTML;


$this->assertContainsWithoutLE($expected, $out);
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
$this->assertStringContainsString($expected, $out);
$this->assertStringContainsString($expected2, $out);
$this->assertStringContainsString($expected3, $out);
}

/**
Expand All @@ -138,7 +137,7 @@ public function testHorizontalLayoutTemplateOverride()
HTML;


$this->assertContainsWithoutLE($expected, $out);
$this->assertStringContainsString($expected, $out);
}

public function testInlineLayout()
Expand Down Expand Up @@ -192,10 +191,10 @@ public function testInlineLayout()
HTML;


$this->assertContainsWithoutLE('<form id="w0" class="form-inline"', $out);
$this->assertContainsWithoutLE($expected, $out);
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
$this->assertStringContainsString('<form id="w0" class="form-inline"', $out);
$this->assertStringContainsString($expected, $out);
$this->assertStringContainsString($expected2, $out);
$this->assertStringContainsString($expected3, $out);
}

public function testFloatingLayout()
Expand Down Expand Up @@ -249,10 +248,10 @@ public function testFloatingLayout()
HTML;


$this->assertContainsWithoutLE('<form id="w0"', $out);
$this->assertContainsWithoutLE($expected, $out);
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
$this->assertStringContainsString('<form id="w0"', $out);
$this->assertStringContainsString($expected, $out);
$this->assertStringContainsString($expected2, $out);
$this->assertStringContainsString($expected3, $out);
}

public function testHintRendering()
Expand Down Expand Up @@ -304,10 +303,10 @@ public function testHintRendering()
</div>
HTML;

$this->assertContainsWithoutLE($expected, $out);
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
$this->assertContainsWithoutLE($expected4, $out);
$this->assertStringContainsString($expected, $out);
$this->assertStringContainsString($expected2, $out);
$this->assertStringContainsString($expected3, $out);
$this->assertStringContainsString($expected4, $out);
}

public function testStaticControlRendering()
Expand Down Expand Up @@ -357,9 +356,9 @@ public function testStaticControlRendering()
</div>
HTML;

$this->assertContainsWithoutLE($expected, $out);
$this->assertContainsWithoutLE($expected2, $out);
$this->assertContainsWithoutLE($expected3, $out);
$this->assertStringContainsString($expected, $out);
$this->assertStringContainsString($expected2, $out);
$this->assertStringContainsString($expected3, $out);
}

/**
Expand Down Expand Up @@ -387,7 +386,7 @@ public function testInputTemplate()
</div>
HTML;

$this->assertContainsWithoutLE($expected, $out);
$this->assertStringContainsString($expected, $out);
}

/**
Expand All @@ -397,7 +396,7 @@ public function testFormNoRoleAttribute()
{
$form = ActiveForm::widget();

$this->assertNotContains('role="form"', $form);
$this->assertStringNotContainsString('role="form"', $form);
}

public function testErrorSummaryRendering()
Expand All @@ -415,10 +414,10 @@ public function testErrorSummaryRendering()
$out = ob_get_clean();


$this->assertContainsWithoutLE('<div class="alert alert-danger"', $out);
$this->assertStringContainsString('<div class="alert alert-danger"', $out);
}

protected function setUp()
protected function setUp(): void
{
// dirty way to have Request object not throwing exception when running testFormNoRoleAttribute()
$_SERVER['REQUEST_URI'] = "index.php";
Expand Down
2 changes: 1 addition & 1 deletion tests/ButtonDropdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testContainerOptions()
],
]);

$this->assertContains("$containerClass dropup btn-group", $out);
$this->assertStringContainsString("$containerClass dropup btn-group", $out);
}

public function testDirection()
Expand Down
2 changes: 1 addition & 1 deletion tests/CarouselTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ public function testCrossfade()
]
]);

$this->assertContains('class="carousel slide carousel-fade"', $out);
$this->assertStringContainsString('class="carousel slide carousel-fade"', $out);
}
}
Loading

0 comments on commit bda07df

Please sign in to comment.