TerminalObjectTest.php 3.0 KB

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