TerminalObjectTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace League\CLImate\Tests;
  3. class TerminalObjectTest extends TestBase
  4. {
  5. /** @test **/
  6. public function it_gracefully_handles_non_existent_objects()
  7. {
  8. $this->shouldWrite("\e[mHey there.\e[0m");
  9. $this->shouldHavePersisted();
  10. $this->cli->somethingThatDoesntExist('Hey there.');
  11. }
  12. /** @test **/
  13. public function it_can_chain_a_foreground_color_and_terminal_object()
  14. {
  15. $this->shouldWrite("\e[31m### Flank me! ###\e[0m");
  16. $this->shouldHavePersisted();
  17. $this->cli->red()->flank('Flank me!');
  18. }
  19. /** @test **/
  20. public function it_can_chain_a_background_color_and_terminal_object()
  21. {
  22. $this->shouldWrite("\e[41m### Flank me! ###\e[0m");
  23. $this->shouldHavePersisted();
  24. $this->cli->backgroundRed()->flank('Flank me!');
  25. }
  26. /** @test **/
  27. public function it_can_combine_a_foreground_color_and_terminal_object()
  28. {
  29. $this->shouldWrite("\e[31m### Flank me! ###\e[0m");
  30. $this->shouldHavePersisted();
  31. $this->cli->redFlank('Flank me!');
  32. }
  33. /** @test **/
  34. public function it_can_combine_a_background_color_and_terminal_object()
  35. {
  36. $this->shouldWrite("\e[41m### Flank me! ###\e[0m");
  37. $this->shouldHavePersisted();
  38. $this->cli->backgroundRedFlank('Flank me!');
  39. }
  40. /** @test **/
  41. public function it_can_chain_a_format_and_terminal_object()
  42. {
  43. $this->shouldWrite("\e[5m### Flank me! ###\e[0m");
  44. $this->shouldHavePersisted();
  45. $this->cli->blink()->flank('Flank me!');
  46. }
  47. /** @test **/
  48. public function it_can_combine_a_format_and_terminal_object()
  49. {
  50. $this->shouldWrite("\e[5m### Flank me! ###\e[0m");
  51. $this->shouldHavePersisted();
  52. $this->cli->blinkFlank('Flank me!');
  53. }
  54. /** @test **/
  55. public function it_can_combine_multiple_formats_and_terminal_object()
  56. {
  57. $this->shouldWrite("\e[4;5m### Flank me! ###\e[0m");
  58. $this->shouldHavePersisted();
  59. $this->cli->blinkUnderlineFlank('Flank me!');
  60. }
  61. /** @test **/
  62. public function it_can_combine_a_foreground_and_background_color_and_terminal_object()
  63. {
  64. $this->shouldWrite("\e[31;41m### Flank me! ###\e[0m");
  65. $this->shouldHavePersisted();
  66. $this->cli->redBackgroundRedFlank('Flank me!');
  67. }
  68. /** @test **/
  69. public function it_can_combine_a_format_and_foreground_and_background_color_and_terminal_object()
  70. {
  71. $this->shouldWrite("\e[5;31;41m### Flank me! ###\e[0m");
  72. $this->shouldHavePersisted();
  73. $this->cli->blinkRedBackgroundRedFlank('Flank me!');
  74. }
  75. }