PluginShellTest.php 1.8 KB

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