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 version to PHP 7.3, check compatibility PHP 8.3. #76

Draft
wants to merge 3 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
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 --ignore-platform-req=php"
name: build

jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ["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.4'
- name: Run unit tests without coverage
run: vendor/bin/phpunit --verbose --colors=always
if: matrix.php != '7.4'
- 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.4'
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-bootstrap5/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap5)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-bootstrap5/downloads.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap5)
[![Build Status](https://github.com/yiisoft/yii2-bootstrap5/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-bootstrap5/actions)
[![codecov](https://codecov.io/gh/yiisoft/yii2-bootstrap5/graph/badge.svg?token=TlrNVGdJFY)](https://codecov.io/gh/yiisoft/yii2-bootstrap5)

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

- PHP 7.3 or higher.

Installation
------------
Expand Down
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