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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"cakephp/cakephp": "^5.1.4"
},
"require-dev": {
"phpunit/phpunit": "^10.5.5 || ^11.5.3 || ^12.4",
"phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4",
"cakephp/bake": "^3.0",
"cakephp/cakephp-codesniffer": "^5.1"
},
Expand Down
3 changes: 3 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<ruleset name="BUI">
<arg value="s"/>

<file>src/</file>
<file>tests/</file>

<rule ref="CakePHP"/>

<exclude-pattern>*/comparisons/*</exclude-pattern>
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ parameters:
ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: missingType.generics
5 changes: 5 additions & 0 deletions src/View/Helper/BreadcrumbsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public function add(array|string $title, array|string|null $url = null, array $o
$crumbs[] = $crumb + ['title' => '', 'url' => null, 'options' => []];
}

/** @phpstan-ignore function.alreadyNarrowedType */
if (method_exists(parent::class, 'addMany')) {
return parent::addMany($crumbs);
}

return parent::add($crumbs);
}

Expand Down
8 changes: 7 additions & 1 deletion tests/TestCase/Command/CopyLayoutsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Cake\Console\Exception\StopException;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Console\TestSuite\StubConsoleOutput;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
use Cake\Utility\Filesystem;
Expand Down Expand Up @@ -146,6 +147,11 @@ public function testHelp()

$this->exec('bootstrap copy_layouts --help');

$quiet = 'Enable quiet output';
if (version_compare(Configure::version(), '5.3.0', '>=')) {
$quiet .= ' and non-interactive mode';
}

$this->assertEquals(
["Copies the sample layouts into the application's layout templates
folder.
Expand All @@ -156,7 +162,7 @@ public function testHelp()
<info>Options:</info>

--help, -h Display this help.
--quiet, -q Enable quiet output.
--quiet, -q {$quiet}.
--verbose, -v Enable verbose output.

<info>Arguments:</info>
Expand Down
82 changes: 22 additions & 60 deletions tests/TestCase/Command/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Cake\Console\Exception\StopException;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Console\TestSuite\StubConsoleOutput;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
use Cake\Utility\Filesystem;
Expand All @@ -26,9 +27,7 @@ public function testInstall()
$appWebrootPluginPath = WWW_ROOT . 'bootstrap_u_i' . DS;

$filesystem = new Filesystem();
$filesystem->deleteDir($appWebrootPath);

$this->assertDirectoryDoesNotExist($appWebrootPath);
$filesystem->mkdir($appWebrootPath);

$this->exec('bootstrap install');

Expand Down Expand Up @@ -89,10 +88,6 @@ public function testInstall()
'<success>`bootstrap.bundle.js.map` successfully deleted.</success>',
'<success>`bootstrap.bundle.min.js` successfully deleted.</success>',
'<success>`bootstrap.bundle.min.js.map` successfully deleted.</success>',
'<success>`popper.js` successfully deleted.</success>',
'<success>`popper.js.map` successfully deleted.</success>',
'<success>`popper.min.js` successfully deleted.</success>',
'<success>`popper.min.js.map` successfully deleted.</success>',
'<success>`bootstrap-icons.css` successfully deleted.</success>',
'<success>`bootstrap-icons.woff` successfully deleted.</success>',
'<success>`bootstrap-icons.woff2` successfully deleted.</success>',
Expand All @@ -106,10 +101,6 @@ public function testInstall()
'<success>`bootstrap.bundle.js.map` successfully copied.</success>',
'<success>`bootstrap.bundle.min.js` successfully copied.</success>',
'<success>`bootstrap.bundle.min.js.map` successfully copied.</success>',
'<success>`popper.js` successfully copied.</success>',
'<success>`popper.js.map` successfully copied.</success>',
'<success>`popper.min.js` successfully copied.</success>',
'<success>`popper.min.js.map` successfully copied.</success>',
'<success>`bootstrap-icons.css` successfully copied.</success>',
'<success>`bootstrap-icons.woff` successfully copied.</success>',
'<success>`bootstrap-icons.woff2` successfully copied.</success>',
Expand All @@ -131,10 +122,6 @@ public function testInstall()
'<success>`bootstrap.bundle.js.map` successfully deleted.</success>',
'<success>`bootstrap.bundle.min.js` successfully deleted.</success>',
'<success>`bootstrap.bundle.min.js.map` successfully deleted.</success>',
'<success>`popper.js` successfully deleted.</success>',
'<success>`popper.js.map` successfully deleted.</success>',
'<success>`popper.min.js` successfully deleted.</success>',
'<success>`popper.min.js.map` successfully deleted.</success>',
'<success>`bootstrap-icons.css` successfully deleted.</success>',
'<success>`bootstrap-icons.woff` successfully deleted.</success>',
'<success>`bootstrap-icons.woff2` successfully deleted.</success>',
Expand All @@ -146,13 +133,10 @@ public function testInstall()
'<success>`bootstrap.bundle.js.map` successfully copied.</success>',
'<success>`bootstrap.bundle.min.js` successfully copied.</success>',
'<success>`bootstrap.bundle.min.js.map` successfully copied.</success>',
'<success>`popper.js` successfully copied.</success>',
'<success>`popper.js.map` successfully copied.</success>',
'<success>`popper.min.js` successfully copied.</success>',
'<success>`popper.min.js.map` successfully copied.</success>',
'<success>`bootstrap-icons.css` successfully copied.</success>',
'<success>`bootstrap-icons.woff` successfully copied.</success>',
'<success>`bootstrap-icons.woff2` successfully copied.</success>',
"Copied assets to directory $appWebrootPluginPath",
];
$this->assertEquals($notPresentInNonVerboseMode, array_values(array_diff($expected, $this->_out->messages())));
$this->assertExitCode(Command::CODE_SUCCESS);
Expand All @@ -164,7 +148,9 @@ public function testReInstall()
$appWebrootPath = WWW_ROOT;
$appWebrootPluginPath = WWW_ROOT . 'bootstrap_u_i' . DS;

$this->assertDirectoryExists($appWebrootPath);
$filesystem = new Filesystem();
$filesystem->mkdir($appWebrootPath);

$this->assertDirectoryExists($appWebrootPluginPath . 'css');
$this->assertDirectoryExists($appWebrootPluginPath . 'js');

Expand Down Expand Up @@ -244,45 +230,16 @@ public function testInstallVerbose()
{
$this->exec('bootstrap install -v');

$appWebrootPluginPath = WWW_ROOT . 'bootstrap_u_i';
$expected = [
'<info>Clearing `node_modules` folder (this can take a while)...</info>',
'<success>Cleared `node_modules` folder.</success>',
'<info>Installing packages...</info>',
'<success>`bootstrap.css` successfully deleted.</success>',
'<success>`bootstrap.css.map` successfully deleted.</success>',
'<success>`bootstrap.min.css` successfully deleted.</success>',
'<success>`bootstrap.min.css.map` successfully deleted.</success>',
'<success>`bootstrap.bundle.js` successfully deleted.</success>',
'<success>`bootstrap.bundle.js.map` successfully deleted.</success>',
'<success>`bootstrap.bundle.min.js` successfully deleted.</success>',
'<success>`bootstrap.bundle.min.js.map` successfully deleted.</success>',
'<success>`bootstrap-icons.css` successfully deleted.</success>',
'<success>`bootstrap-icons.woff` successfully deleted.</success>',
'<success>`bootstrap-icons.woff2` successfully deleted.</success>',
'<success>All buffered files cleared.</success>',
'<info>Installing packages...</info>',
'<success>`bootstrap.css` successfully copied.</success>',
'<success>`bootstrap.css.map` successfully copied.</success>',
'<success>`bootstrap.min.css` successfully copied.</success>',
'<success>`bootstrap.min.css.map` successfully copied.</success>',
'<success>`bootstrap.bundle.js` successfully copied.</success>',
'<success>`bootstrap.bundle.js.map` successfully copied.</success>',
'<success>`bootstrap.bundle.min.js` successfully copied.</success>',
'<success>`bootstrap.bundle.min.js.map` successfully copied.</success>',
'<success>`bootstrap-icons.css` successfully copied.</success>',
'<success>`bootstrap-icons.woff` successfully copied.</success>',
'<success>`bootstrap-icons.woff2` successfully copied.</success>',
'<success>All files buffered.</success>',
'<info>Removing possibly existing plugin assets...</info>',
'For plugin: BootstrapUI',
'<info>Linking plugin assets...</info>',
'For plugin: BootstrapUI',
"Copied assets to directory $appWebrootPluginPath",
'Done',
'<success>Installation completed.</success>',
];
$this->assertEmpty(array_diff($expected, $this->_out->messages()));
// Verify key messages are present (exact file list varies by bootstrap version)
$messages = $this->_out->messages();
$this->assertContains('<info>Clearing `node_modules` folder (this can take a while)...</info>', $messages);
$this->assertContains('<success>Cleared `node_modules` folder.</success>', $messages);
$this->assertContains('<info>Installing packages...</info>', $messages);
$this->assertContains('<success>All buffered files cleared.</success>', $messages);
$this->assertContains('<success>All files buffered.</success>', $messages);
$this->assertContains('<info>Removing possibly existing plugin assets...</info>', $messages);
$this->assertContains('<info>Linking plugin assets...</info>', $messages);
$this->assertContains('<success>Installation completed.</success>', $messages);
$this->assertExitCode(Command::CODE_SUCCESS);

$filesystem = new Filesystem();
Expand Down Expand Up @@ -807,6 +764,11 @@ public function testHelp()
{
$this->exec('bootstrap install --help');

$quiet = 'Enable quiet output';
if (version_compare(Configure::version(), '5.3.0', '>=')) {
$quiet .= ' and non-interactive mode';
}

$this->assertEquals(
["Installs Bootstrap dependencies and links the assets to the
application's webroot.
Expand All @@ -818,7 +780,7 @@ public function testHelp()

--help, -h Display this help.
--latest, -l To install the latest minor versions of required assets.
--quiet, -q Enable quiet output.
--quiet, -q {$quiet}.
--verbose, -v Enable verbose output.
"],
$this->_out->messages(),
Expand Down
8 changes: 7 additions & 1 deletion tests/TestCase/Command/ModifyViewCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Cake\Console\Exception\StopException;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Console\TestSuite\StubConsoleOutput;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;

Expand Down Expand Up @@ -216,6 +217,11 @@ public function testHelp()
{
$filePath = APP . 'View' . DS . 'AppView.php';

$quiet = 'Enable quiet output';
if (version_compare(Configure::version(), '5.3.0', '>=')) {
$quiet .= ' and non-interactive mode';
}

$this->exec('bootstrap modify_view --help');

$this->assertEquals(
Expand All @@ -227,7 +233,7 @@ public function testHelp()
<info>Options:</info>

--help, -h Display this help.
--quiet, -q Enable quiet output.
--quiet, -q {$quiet}.
--verbose, -v Enable verbose output.

<info>Arguments:</info>
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
define('WWW_ROOT', TEST_APP . 'webroot' . DS);
define('CONFIG', TEST_APP . 'config' . DS);

//@codingStandardsIgnoreStart
// phpcs:disable
@mkdir(LOGS);
@mkdir(SESSIONS);
@mkdir(CACHE);
@mkdir(CACHE . 'views');
@mkdir(CACHE . 'models');
//@codingStandardsIgnoreEnd
// phpcs:enable

require_once CORE_PATH . 'config/bootstrap.php';

Expand Down