AssetsTaskTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * CakePHP : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP Project
  12. * @since 3.0.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Shell\Task;
  16. use Cake\Core\App;
  17. use Cake\Core\Configure;
  18. use Cake\Core\Plugin;
  19. use Cake\Filesystem\Folder;
  20. use Cake\Shell\Task\AssetsTask;
  21. use Cake\TestSuite\TestCase;
  22. /**
  23. * SymlinkAssetsTask class
  24. *
  25. */
  26. class SymlinkAssetsTaskTest extends TestCase {
  27. /**
  28. * setUp method
  29. *
  30. * @return void
  31. */
  32. public function setUp() {
  33. parent::setUp();
  34. $this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
  35. $this->Task = $this->getMock(
  36. 'Cake\Shell\Task\AssetsTask',
  37. array('in', 'out', 'err', '_stop'),
  38. array($this->io)
  39. );
  40. }
  41. /**
  42. * tearDown method
  43. *
  44. * @return void
  45. */
  46. public function tearDown() {
  47. parent::tearDown();
  48. unset($this->Task);
  49. Plugin::unload();
  50. }
  51. /**
  52. * testExecute method
  53. *
  54. * @return void
  55. */
  56. public function testExecute() {
  57. Plugin::load('TestPlugin');
  58. Plugin::load('Company/TestPluginThree');
  59. $this->Task->main();
  60. $path = WWW_ROOT . 'test_plugin';
  61. $link = new \SplFileInfo($path);
  62. $this->assertTrue($link->isLink());
  63. $this->assertTrue(file_exists($path . DS . 'root.js'));
  64. unlink($path);
  65. $path = WWW_ROOT . 'company' . DS . 'test_plugin_three';
  66. $link = new \SplFileInfo($path);
  67. $this->assertTrue($link->isLink());
  68. $this->assertTrue(file_exists($path . DS . 'css' . DS . 'company.css'));
  69. $folder = new Folder(WWW_ROOT . 'company');
  70. $folder->delete();
  71. }
  72. /**
  73. * test that plugins without webroot are not processed
  74. *
  75. * @return void
  76. */
  77. public function testForPluginWithoutWebroot() {
  78. Plugin::load('TestPluginTwo');
  79. $this->Task->main();
  80. $this->assertFalse(file_exists(WWW_ROOT . 'test_plugin_two'));
  81. }
  82. }