ToolsTestTraitTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Tools\Test\TestCase\TestSuite;
  3. use Tools\TestSuite\TestCase;
  4. class ToolsTestTraitTest extends TestCase {
  5. /**
  6. * @return void
  7. */
  8. public function setUp() {
  9. parent::setUp();
  10. $this->serverArgBackup = !empty($_SERVER['argv']) ? $_SERVER['argv'] : null;
  11. $_SERVER['argv'] = [];
  12. }
  13. /**
  14. * @return void
  15. */
  16. public function tearDown() {
  17. parent::tearDown();
  18. $_SERVER['argv'] = $this->serverArgBackup;
  19. }
  20. /**
  21. * MimeTest::testOsFix()
  22. *
  23. * @return void
  24. */
  25. public function testOsFix() {
  26. $string = "Foo\r\nbar";
  27. $result = $this->osFix($string);
  28. $expected = "Foo\nbar";
  29. $this->assertSame($expected, $result);
  30. }
  31. /**
  32. * ToolsTestTraitTest::testIsDebug()
  33. *
  34. * @return void
  35. */
  36. public function testIsDebug() {
  37. $result = $this->isDebug();
  38. $this->assertFalse($result);
  39. $_SERVER['argv'] = ['--debug'];
  40. $result = $this->isDebug();
  41. $this->assertTrue($result);
  42. }
  43. /**
  44. * ToolsTestTraitTest::testIsVerbose()
  45. *
  46. * @return void
  47. */
  48. public function testIsVerbose() {
  49. $_SERVER['argv'] = ['--debug'];
  50. $result = $this->isVerbose();
  51. $this->assertFalse($result);
  52. $_SERVER['argv'] = ['-v'];
  53. $result = $this->isVerbose();
  54. $this->assertTrue($result);
  55. $_SERVER['argv'] = ['-vv'];
  56. $result = $this->isVerbose();
  57. $this->assertTrue($result);
  58. $_SERVER['argv'] = ['-v', '-vv'];
  59. $result = $this->isVerbose();
  60. $this->assertTrue($result);
  61. $_SERVER['argv'] = ['-v'];
  62. $result = $this->isVerbose(true);
  63. $this->assertFalse($result);
  64. $_SERVER['argv'] = ['-vv'];
  65. $result = $this->isVerbose(true);
  66. $this->assertTrue($result);
  67. $_SERVER['argv'] = ['-v', '-vv'];
  68. $result = $this->isVerbose(true);
  69. $this->assertTrue($result);
  70. }
  71. }