Skip to content
Merged
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
61 changes: 18 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,22 @@
name: build
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

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

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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ phpunit.phar
/tests/docker
/tests/dockerids

# nodejs
/node_modules
/package-lock.json
.phpunit.result.cache
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![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)

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

- PHP 8.1 or higher.

Installation
------------
Expand All @@ -27,13 +31,13 @@ The preferred way to install this extension is through [composer](https://getcom
Either run

```
php composer.phar require --prefer-dist yiisoft/yii2-bootstrap
php composer.phar require --prefer-dist yiisoft/yii2-bootstrap:^22.x-dev
```

or add

```
"yiisoft/yii2-bootstrap": "~2.0.0"
"yiisoft/yii2-bootstrap": "^22.x-dev"
```

to the require section of your `composer.json` file.
Expand Down
41 changes: 14 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "yiisoft/yii2-bootstrap",
"description": "The Twitter Bootstrap extension for the Yii framework",
"keywords": ["yii2", "bootstrap"],
"keywords": [
"yii2",
"bootstrap"
],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
Expand Down Expand Up @@ -32,42 +35,26 @@
}
],
"require": {
"yiisoft/yii2": "~2.0.6",
"bower-asset/bootstrap": "3.4.* | 3.3.* | 3.2.* | 3.1.*"
"php": ">=8.1",
"yiisoft/yii2": "22.0.x-dev"
},
"require-dev": {
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
"php-forge/foxy": "^0.1",
"phpunit/phpunit": "^9.6",
"yiisoft/yii2-coding-standards": "~2.0"
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"autoload": {
"psr-4": {
"yii\\bootstrap\\": "src"
}
},
"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
"yiisoft/yii2-composer": true,
"php-forge/foxy": true
}
},
"extra": {
"foxy": true
}
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"bootstrap3": "npm:bootstrap@^3.4.1"
}
}
32 changes: 20 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
<?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
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
>
<testsuites>
<testsuite name="Yii2-Bootstrap">
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
2 changes: 1 addition & 1 deletion src/BootstrapAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class BootstrapAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap/dist';
public $sourcePath = '@npm/bootstrap3/dist';
public $css = [
'css/bootstrap.css',
];
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapPluginAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class BootstrapPluginAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap/dist';
public $sourcePath = '@npm/bootstrap3/dist';
public $js = [
'js/bootstrap.js',
];
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapThemeAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class BootstrapThemeAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap/dist';
public $sourcePath = '@npm/bootstrap3/dist';
public $css = [
'css/bootstrap-theme.css',
];
Expand Down
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,
);
}
}
Loading