CommandTest.php 1.4 KB

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