DrawTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace League\CLImate\Tests;
  3. class DrawTest extends TestBase
  4. {
  5. protected function drawWorks()
  6. {
  7. $this->shouldWrite("\e[m __ ______ _____ _ __ _____\e[0m");
  8. $this->shouldWrite("\e[m \ \ / / __ \| __ \| |/ // ____|\e[0m");
  9. $this->shouldWrite("\e[m \ \ /\ / / | | | |__) | ' /| (___\e[0m");
  10. $this->shouldWrite("\e[m \ \/ \/ /| | | | _ /| < \___ \\\e[0m");
  11. $this->shouldWrite("\e[m \ /\ / | |__| | | \ \| . \ ____) |\e[0m");
  12. $this->shouldWrite("\e[m \/ \/ \____/|_| \_\_|\_\_____/\e[0m");
  13. $this->shouldHavePersisted();
  14. }
  15. private function draw404(): void
  16. {
  17. $this->shouldWrite("\e[m _ _ ___ _ _\e[0m");
  18. $this->shouldWrite("\e[m | || | / _ \| || |\e[0m");
  19. $this->shouldWrite("\e[m | || |_| | | | || |_\e[0m");
  20. $this->shouldWrite("\e[m |__ _| | | |__ _|\e[0m");
  21. $this->shouldWrite("\e[m | | | |_| | | |\e[0m");
  22. $this->shouldWrite("\e[m |_| \___/ |_|\e[0m");
  23. $this->shouldHavePersisted();
  24. }
  25. /**
  26. * @test
  27. * @doesNotPerformAssertions
  28. */
  29. public function it_can_draw_something()
  30. {
  31. $this->shouldWrite("\e[m ( )\e[0m");
  32. $this->shouldWrite("\e[m H\e[0m");
  33. $this->shouldWrite("\e[m H\e[0m");
  34. $this->shouldWrite("\e[m _H_\e[0m");
  35. $this->shouldWrite("\e[m .-'-.-'-.\e[0m");
  36. $this->shouldWrite("\e[m / \\\e[0m");
  37. $this->shouldWrite("\e[m| |\e[0m");
  38. $this->shouldWrite("\e[m| .-------'._\e[0m");
  39. $this->shouldWrite("\e[m| / / '.' '. \\\e[0m");
  40. $this->shouldWrite("\e[m| \ \ @ @ / /\e[0m");
  41. $this->shouldWrite("\e[m| '---------'\e[0m");
  42. $this->shouldWrite("\e[m| _______|\e[0m");
  43. $this->shouldWrite("\e[m| .'-+-+-+|\e[0m");
  44. $this->shouldWrite("\e[m| '.-+-+-+|\e[0m");
  45. $this->shouldWrite("\e[m| \"\"\"\"\"\" |\e[0m");
  46. $this->shouldWrite("\e[m'-.__ __.-'\e[0m");
  47. $this->shouldWrite("\e[m \"\"\"\e[0m");
  48. $this->shouldHavePersisted();
  49. $this->cli->draw('bender');
  50. }
  51. /**
  52. * @test
  53. * @doesNotPerformAssertions
  54. */
  55. public function it_404s_when_it_gets_invalid_art()
  56. {
  57. $this->draw404();
  58. $this->cli->draw('something-that-doesnt-exist');
  59. }
  60. /**
  61. * @test
  62. * @doesNotPerformAssertions
  63. */
  64. public function it_can_take_a_custom_art_directory()
  65. {
  66. $this->drawWorks();
  67. $this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . 'art');
  68. $this->cli->draw('works');
  69. }
  70. /**
  71. * @test
  72. * @doesNotPerformAssertions
  73. */
  74. public function it_can_take_a_custom_art_directory_with_a_trailing_slash()
  75. {
  76. $this->drawWorks();
  77. $this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . 'art' . \DIRECTORY_SEPARATOR);
  78. $this->cli->draw('works');
  79. }
  80. /**
  81. * @test
  82. * @doesNotPerformAssertions
  83. */
  84. public function it_can_chain_the_art_setting()
  85. {
  86. $this->drawWorks();
  87. $this->cli->addArt(__DIR__ . \DIRECTORY_SEPARATOR . 'art')->draw('works');
  88. }
  89. /**
  90. * Ensure we don't use the path to match the file name.
  91. * https://github.com/thephpleague/climate/issues/130
  92. * @doesNotPerformAssertions
  93. */
  94. public function testAddArt1()
  95. {
  96. $this->shouldWrite("\e[mart\e[0m");
  97. $this->shouldWrite("\e[m\e[0m");
  98. $this->shouldHavePersisted();
  99. $this->cli->addArt(__DIR__ . "/art/");
  100. $this->cli->draw("art");
  101. }
  102. /**
  103. * Ensure we can draw files without extensions.
  104. * @doesNotPerformAssertions
  105. */
  106. public function testDraw1()
  107. {
  108. $this->shouldWrite("\e[m __\e[0m");
  109. $this->shouldWrite("\e[m ____ / /_ ____\e[0m");
  110. $this->shouldWrite("\e[m / __ \\/ __ \\/ __ \\\e[0m");
  111. $this->shouldWrite("\e[m / /_/ / / / / /_/ /\e[0m");
  112. $this->shouldWrite("\e[m / .___/_/ /_/ .___/\e[0m");
  113. $this->shouldWrite("\e[m/_/ /_/\e[0m");
  114. $this->shouldHavePersisted();
  115. $this->cli->draw("php");
  116. }
  117. /**
  118. * Ensure we don't draw an image unless the filename matches exactly.
  119. * https://github.com/thephpleague/climate/issues/155
  120. * @doesNotPerformAssertions
  121. */
  122. public function testDraw2()
  123. {
  124. $this->draw404();
  125. $this->cli->draw("the-leag");
  126. }
  127. }