PluginLoadedCommandTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice.
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP(tm) Project
  13. * @since 3.1.9
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace Cake\Test\TestCase\Shell;
  17. use Cake\Core\Plugin;
  18. use Cake\Shell\PluginShell;
  19. use Cake\TestSuite\TestCase;
  20. /**
  21. * PluginShell test.
  22. */
  23. class PluginShellTest extends TestCase
  24. {
  25. /**
  26. * setup method
  27. *
  28. * @return void
  29. */
  30. public function setUp(): void
  31. {
  32. parent::setUp();
  33. $this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')->getMock();
  34. $this->shell = new PluginShell($this->io);
  35. }
  36. /**
  37. * Test that the option parser is shaped right.
  38. *
  39. * @return void
  40. */
  41. public function testGetOptionParser()
  42. {
  43. $this->shell->loadTasks();
  44. $parser = $this->shell->getOptionParser();
  45. $commands = $parser->subcommands();
  46. $this->assertArrayHasKey('unload', $commands);
  47. $this->assertArrayHasKey('load', $commands);
  48. $this->assertArrayHasKey('assets', $commands);
  49. }
  50. /**
  51. * Tests that list of loaded plugins is shown with loaded command.
  52. *
  53. * @return void
  54. */
  55. public function testLoaded()
  56. {
  57. $array = Plugin::loaded();
  58. $this->io->expects($this->at(0))
  59. ->method('out')
  60. ->with($array);
  61. $this->shell->loaded();
  62. }
  63. }