CommandTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace League\CLImate\Tests;
  3. use League\CLImate\Decorator\Component\Command;
  4. class CommandTest extends TestBase
  5. {
  6. /** @test */
  7. public function it_can_add_a_command()
  8. {
  9. $command = new Command();
  10. $command->add('my_new_command', 'that_new_new');
  11. $this->assertArrayHasKey('my_new_command', $command->commands);
  12. $this->assertSame($command->commands['my_new_command'], 'that_new_new');
  13. }
  14. /** @test */
  15. public function it_can_retrieve_all_the_commands()
  16. {
  17. $command = new Command();
  18. $this->assertSame($command->commands, $command->all());
  19. }
  20. /** @test */
  21. public function it_can_retrieve_a_command_value()
  22. {
  23. $command = new Command();
  24. $this->assertSame('green', $command->get('info'));
  25. }
  26. /** @test */
  27. public function it_returns_null_for_non_existent_command()
  28. {
  29. $command = new Command();
  30. $this->assertNull($command->get('wat'));
  31. }
  32. /** @test */
  33. public function it_can_set_an_existing_command_as_current()
  34. {
  35. $command = new Command();
  36. $this->assertSame('green', $command->set('info'));
  37. }
  38. /** @test */
  39. public function it_returns_false_when_setting_a_non_existent_command_as_current()
  40. {
  41. $command = new Command();
  42. $this->assertFalse($command->set('wat'));
  43. }
  44. }