CommandTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * CakePHP : 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 Project
  12. * @since 3.6.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Console;
  16. use Cake\Console\Command;
  17. use Cake\ORM\Locator\TableLocator;
  18. use Cake\ORM\Table;
  19. use Cake\TestSuite\TestCase;
  20. use TestApp\Command\ExampleCommand;
  21. /**
  22. * Test case for Console\Command
  23. */
  24. class CommandTest extends TestCase
  25. {
  26. /**
  27. * test orm locator is setup
  28. *
  29. * @return void
  30. */
  31. public function testConstructorSetsLocator()
  32. {
  33. $command = new Command();
  34. $result = $command->getTableLocator();
  35. $this->assertInstanceOf(TableLocator::class, $result);
  36. }
  37. /**
  38. * test loadModel is configured properly
  39. *
  40. * @return void
  41. */
  42. public function testConstructorLoadModel()
  43. {
  44. $command = new Command();
  45. $command->loadModel('Comments');
  46. $this->assertInstanceOf(Table::class, $command->Comments);
  47. }
  48. /**
  49. * Test name inflection
  50. *
  51. * @return void
  52. */
  53. public function testNameInflection()
  54. {
  55. $command = new ExampleCommand();
  56. $this->assertSame('Example', $command->getName());
  57. }
  58. }