Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise min PHP version to PHP 7.3, check compatibility PHP 8.3. #278

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Contributing to Yii2

- [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md)
- [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md)
- [Give us feedback or start a design discussion](https://forum.yiiframework.com/c/yii-2-0/general-discussions/16)
- [Give us feedback or start a design discussion](https://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/)
- [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md)
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

open_collective: yiisoft
github: [yiisoft]
tidelift: "packagist/yiisoft/yii2-bootstrap"
tidelift: "packagist/yiisoft/yii2-bootstrap5"
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Yii communities listed at https://github.com/yiisoft/yii2/wiki/communities

### What steps will reproduce the problem?

### What's expected?
### What is the expected result?

### What do you get instead?

Expand Down
70 changes: 27 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,31 @@
name: build
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

on: [push, pull_request]
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
name: build

jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: Run unit tests with coverage
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always
if: matrix.php == '7.1'
- name: Run unit tests without coverage
run: vendor/bin/phpunit --verbose --colors=always
if: matrix.php != '7.1'
- name: Upload code coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
if: matrix.php == '7.1'
continue-on-error: true # if is fork
phpunit:
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-bootstrap/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-bootstrap/downloads.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap)
[![Build Status](https://github.com/yiisoft/yii2-bootstrap/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-bootstrap/actions)
[![codecov](https://codecov.io/gh/yiisoft/yii2-bootstrap/graph/badge.svg?token=WgenN23NcE)](https://codecov.io/gh/yiisoft/yii2-bootstrap)

Requirements
------------

- PHP 7.3 or higher.

Installation
------------
Expand Down
14 changes: 2 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
}
],
"require": {
"php": ">=7.3",
"yiisoft/yii2": "~2.0.6",
"bower-asset/bootstrap": "3.4.* | 3.3.* | 3.2.* | 3.1.*"
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
"phpunit/phpunit": "^9.6"
},
"repositories": [
{
Expand All @@ -53,20 +53,10 @@
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
},
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch"
}
}
},
"config": {
"allow-plugins": {
"cweagans/composer-patches": true,
"yiisoft/yii2-composer": true
}
}
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-Bootstrap">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
6 changes: 3 additions & 3 deletions tests/ActiveFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ActiveFieldTest extends TestCase
*/
private $attributeName = 'attributeName';

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 Expand Up @@ -93,7 +93,7 @@ public function testRadioListItemOptions()
]
])->render();

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

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

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

public function testHorizontalCssClasses()
Expand Down
6 changes: 3 additions & 3 deletions tests/ActiveFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

/**
* Tests for ActiveForm widget
*
*
* @group bootstrap
*/
class ActiveFormTest extends TestCase
{

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 All @@ -27,6 +27,6 @@ public function testFormNoRoleAttribute()
{
$form = ActiveForm::widget();

$this->assertNotContains('role="form"', $form);
$this->assertStringNotContainsString('role="form"', $form);
}
}
2 changes: 1 addition & 1 deletion tests/ButtonDropdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function testContainerOptions()
],
]);

$this->assertContains("$containerClass btn-group", $out);
$this->assertStringContainsString("$containerClass btn-group", $out);
}
}
8 changes: 4 additions & 4 deletions tests/ButtonGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function testContainerOptions()
],
]);

static::assertContains('button-A', $out);
static::assertContains('button-B', $out);
static::assertContains('button-B', $out);
static::assertNotContains('button-C', $out);
static::assertStringContainsString('button-A', $out);
static::assertStringContainsString('button-B', $out);
static::assertStringContainsString('button-B', $out);
static::assertStringNotContainsString('button-C', $out);
}
}
37 changes: 25 additions & 12 deletions tests/CollapseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace yiiunit\extensions\bootstrap;

use yii\base\DynamicModel;
use yii\base\InvalidConfigException;
use yii\bootstrap\Collapse;
use yii\widgets\ActiveForm;

Expand Down Expand Up @@ -170,13 +171,13 @@ public function invalidItemsProvider()

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

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

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

/**
Expand All @@ -262,8 +263,11 @@ public function testItemToggleTag()
'class' => 'custom-toggle',
],
]);
$this->assertContains('<h4 class="panel-title"><span class="custom-toggle collapse-toggle collapsed" data-toggle="collapse" ', $output);
$this->assertNotContains('<a', $output);
$this->assertStringContainsString(
'<h4 class="panel-title"><span class="custom-toggle collapse-toggle collapsed" data-toggle="collapse" ',
$output,
);
$this->assertStringNotContainsString('<a', $output);

$output = Collapse::widget([
'items' => $items,
Expand All @@ -272,8 +276,11 @@ public function testItemToggleTag()
'class' => ['widget' => 'custom-toggle'],
],
]);
$this->assertContains('<h4 class="panel-title"><span class="custom-toggle collapsed" data-toggle="collapse" ', $output);
$this->assertNotContains('collapse-toggle', $output);
$this->assertStringContainsString(
'<h4 class="panel-title"><span class="custom-toggle collapsed" data-toggle="collapse" ',
$output,
);
$this->assertStringNotContainsString('collapse-toggle', $output);
}

/**
Expand All @@ -297,7 +304,13 @@ public function testItemToggleTagClasses()
$output = Collapse::widget([
'items' => $items,
]);
$this->assertContains('<h4 class="panel-title"><a class="collapse-toggle" href="#w5-collapse1" data-toggle="collapse" ', $output);
$this->assertContains('<h4 class="panel-title"><a class="collapse-toggle collapsed" href="#w5-collapse2" data-toggle="collapse" ', $output);
$this->assertStringContainsString(
'<h4 class="panel-title"><a class="collapse-toggle" href="#w5-collapse1" data-toggle="collapse" ',
$output,
);
$this->assertStringContainsString(
'<h4 class="panel-title"><a class="collapse-toggle collapsed" href="#w5-collapse2" data-toggle="collapse" ',
$output,
);
}
}
9 changes: 6 additions & 3 deletions tests/NavBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* Tests for NavBar widget
*
*
* @group bootstrap
*/
class NavBarTest extends TestCase
Expand Down Expand Up @@ -39,7 +39,10 @@ public function testBrandImage()
'brandUrl' => '/',
]);

$this->assertContains('<a class="navbar-brand" href="/"><img src="/images/test.jpg" alt=""></a>', $out);
$this->assertStringContainsString(
'<a class="navbar-brand" href="/"><img src="/images/test.jpg" alt=""></a>',
$out,
);
}

public function testHeaderContent()
Expand All @@ -57,6 +60,6 @@ public function testHeaderContent()
'headerContent' => $testContent,
]);

$this->assertContains($testContent, $out);
$this->assertStringContainsString($testContent, $out);
}
}
4 changes: 2 additions & 2 deletions tests/NavTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class NavTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->mockWebApplication([
'components' => [
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testIds()

$this->assertEqualsWithoutLE($expected, $out);
}

public function testRenderDropDownWithDropDownOptions()
{
Nav::$counter = 0;
Expand Down
Loading