Skip to content

Commit

Permalink
Merge pull request #221 from ndm2/fix-install-test-failure
Browse files Browse the repository at this point in the history
Fix bootstrap shell install test failure.
  • Loading branch information
ADmad authored Jun 3, 2018
2 parents d9f3692 + 743b0d2 commit b81712a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"cakephp/cakephp": "^3.5"
"cakephp/cakephp": "^3.5.12"
},
"require-dev": {
"phpunit/phpunit": "^5.7.14|^6.0"
Expand Down
3 changes: 2 additions & 1 deletion src/Shell/BootstrapShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function install()
{
$this->TwbsAssets->installAssets();
$this->TwbsAssets->copyAssets();
$this->Assets->symlink();
$this->Assets->remove('BootstrapUI');
$this->Assets->symlink('BootstrapUI');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Shell/Task/TwbsAssetsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class TwbsAssetsTask extends Shell
public function __construct()
{
parent::__construct();
$this->_assetDir = new Folder(Plugin::path('BootstrapUI') . 'webroot');
$this->_nodeDir = new Folder(Plugin::path('BootstrapUI') . 'node_modules');
$this->_cssDir = new Folder($this->_assetDir->path . DS . 'css');
$this->_jsDir = new Folder($this->_assetDir->path . DS . 'js');
$this->_assetDir = new Folder(Plugin::path('BootstrapUI') . 'webroot', true);
$this->_nodeDir = new Folder(Plugin::path('BootstrapUI') . 'node_modules', true);
$this->_cssDir = new Folder($this->_assetDir->path . DS . 'css', true);
$this->_jsDir = new Folder($this->_assetDir->path . DS . 'js', true);
}

/**
Expand Down
61 changes: 57 additions & 4 deletions tests/TestCase/Shell/BootstrapShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,68 @@ public function tearDown()
unset($this->Shell);
}

public function testInstall()
public function testInstallInDebugMode()
{
$this->Shell->install();

$pluginPath = Plugin::path('BootstrapUI');
$nodePath = $pluginPath . 'node_modules';
$webrootPath = $pluginPath . 'webroot' . DS;
$cssPath = $webrootPath . 'css' . DS;
$jsPath = $webrootPath . 'js' . DS;

$this->assertDirectoryExists($nodePath);
$this->assertDirectoryExists($webrootPath);
$this->assertDirectoryExists($cssPath);
$this->assertDirectoryExists($jsPath);

$appWebrootPath = WWW_ROOT . 'bootstrap_u_i' . DS;
$appCssPath = $webrootPath . 'css' . DS;
$appJsPath = $webrootPath . 'js' . DS;

$this->assertDirectoryExists($appWebrootPath);
$this->assertDirectoryExists($appCssPath);
$this->assertDirectoryExists($appJsPath);

$sourceFiles = (new Folder($webrootPath))->findRecursive();
$targetFiles = (new Folder($appWebrootPath))->findRecursive();
$this->assertEquals(count($sourceFiles), count($targetFiles));
}

public function testInstallInProductionMode()
{
Configure::write('debug', false);
$this->Shell->install();
Configure::write('debug', true);

$pluginPath = Plugin::path('BootstrapUI');
$nodePath = $pluginPath . 'node_modules';
$webrootPath = $pluginPath . 'webroot' . DS;
$cssPath = $webrootPath . 'css' . DS;
$jsPath = $webrootPath . 'js' . DS;

$this->assertDirectoryExists($nodePath);
$this->assertDirectoryExists($webrootPath);

$this->assertDirectoryExists($cssPath);
$this->assertFileExists($cssPath . 'bootstrap.min.css');

$this->assertDirectoryExists($jsPath);
$this->assertFileExists($jsPath . 'bootstrap.min.js');
$this->assertFileExists($jsPath . 'jquery.min.js');
$this->assertFileExists($jsPath . 'popper.min.js');

$appWebrootPath = WWW_ROOT . 'bootstrap_u_i' . DS;
$appCssPath = $webrootPath . 'css' . DS;
$appJsPath = $webrootPath . 'js' . DS;

$this->assertDirectoryExists($appWebrootPath);
$this->assertDirectoryExists($appCssPath);
$this->assertDirectoryExists($appJsPath);

$this->_assetDir = new Folder(Plugin::path('BootstrapUI') . 'webroot');
$this->assertDirectoryExists($this->_assetDir->path . DS . 'css');
$this->assertDirectoryExists($this->_assetDir->path . DS . 'js');
$sourceFiles = (new Folder($webrootPath))->findRecursive();
$targetFiles = (new Folder($appWebrootPath))->findRecursive();
$this->assertEquals(count($sourceFiles), count($targetFiles));
}

public function testCopyLayouts()
Expand Down

0 comments on commit b81712a

Please sign in to comment.