StdinFileInfoTest.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests;
  13. use PhpCsFixer\StdinFileInfo;
  14. /**
  15. * @author ntzm
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\StdinFileInfo
  20. */
  21. final class StdinFileInfoTest extends TestCase
  22. {
  23. public function testToString(): void
  24. {
  25. $fileInfo = new StdinFileInfo();
  26. self::assertSame('php://stdin', (string) $fileInfo);
  27. }
  28. public function testGetRealPath(): void
  29. {
  30. $fileInfo = new StdinFileInfo();
  31. self::assertSame('php://stdin', $fileInfo->getRealPath());
  32. }
  33. public function testGetATime(): void
  34. {
  35. $fileInfo = new StdinFileInfo();
  36. self::assertSame(0, $fileInfo->getATime());
  37. }
  38. public function testGetBasename(): void
  39. {
  40. $fileInfo = new StdinFileInfo();
  41. self::assertSame('stdin.php', $fileInfo->getBasename());
  42. }
  43. public function testGetCTime(): void
  44. {
  45. $fileInfo = new StdinFileInfo();
  46. self::assertSame(0, $fileInfo->getCTime());
  47. }
  48. public function testGetExtension(): void
  49. {
  50. $fileInfo = new StdinFileInfo();
  51. self::assertSame('.php', $fileInfo->getExtension());
  52. }
  53. public function testGetFileInfo(): void
  54. {
  55. $fileInfo = new StdinFileInfo();
  56. $this->expectException(\BadMethodCallException::class);
  57. $this->expectExceptionMessage('Method "PhpCsFixer\StdinFileInfo::getFileInfo" is not implemented.');
  58. $fileInfo->getFileInfo();
  59. }
  60. public function testGetFilename(): void
  61. {
  62. $fileInfo = new StdinFileInfo();
  63. self::assertSame('stdin.php', $fileInfo->getFilename());
  64. }
  65. public function testGetGroup(): void
  66. {
  67. $fileInfo = new StdinFileInfo();
  68. self::assertSame(0, $fileInfo->getGroup());
  69. }
  70. public function testGetInode(): void
  71. {
  72. $fileInfo = new StdinFileInfo();
  73. self::assertSame(0, $fileInfo->getInode());
  74. }
  75. public function testGetLinkTarget(): void
  76. {
  77. $fileInfo = new StdinFileInfo();
  78. self::assertSame('', $fileInfo->getLinkTarget());
  79. }
  80. public function testGetMTime(): void
  81. {
  82. $fileInfo = new StdinFileInfo();
  83. self::assertSame(0, $fileInfo->getMTime());
  84. }
  85. public function testGetOwner(): void
  86. {
  87. $fileInfo = new StdinFileInfo();
  88. self::assertSame(0, $fileInfo->getOwner());
  89. }
  90. public function testGetPath(): void
  91. {
  92. $fileInfo = new StdinFileInfo();
  93. self::assertSame('', $fileInfo->getPath());
  94. }
  95. public function testGetPathInfo(): void
  96. {
  97. $fileInfo = new StdinFileInfo();
  98. $this->expectException(\BadMethodCallException::class);
  99. $this->expectExceptionMessage('Method "PhpCsFixer\StdinFileInfo::getPathInfo" is not implemented.');
  100. $fileInfo->getPathInfo();
  101. }
  102. public function testGetPathname(): void
  103. {
  104. $fileInfo = new StdinFileInfo();
  105. self::assertSame('stdin.php', $fileInfo->getPathname());
  106. }
  107. public function testGetPerms(): void
  108. {
  109. $fileInfo = new StdinFileInfo();
  110. self::assertSame(0, $fileInfo->getPerms());
  111. }
  112. public function testGetSize(): void
  113. {
  114. $fileInfo = new StdinFileInfo();
  115. self::assertSame(0, $fileInfo->getSize());
  116. }
  117. public function testGetType(): void
  118. {
  119. $fileInfo = new StdinFileInfo();
  120. self::assertSame('file', $fileInfo->getType());
  121. }
  122. public function testIsDir(): void
  123. {
  124. $fileInfo = new StdinFileInfo();
  125. self::assertFalse($fileInfo->isDir());
  126. }
  127. public function testIsExecutable(): void
  128. {
  129. $fileInfo = new StdinFileInfo();
  130. self::assertFalse($fileInfo->isExecutable());
  131. }
  132. public function testIsFile(): void
  133. {
  134. $fileInfo = new StdinFileInfo();
  135. self::assertTrue($fileInfo->isFile());
  136. }
  137. public function testIsLink(): void
  138. {
  139. $fileInfo = new StdinFileInfo();
  140. self::assertFalse($fileInfo->isLink());
  141. }
  142. public function testIsReadable(): void
  143. {
  144. $fileInfo = new StdinFileInfo();
  145. self::assertTrue($fileInfo->isReadable());
  146. }
  147. public function testIsWritable(): void
  148. {
  149. $fileInfo = new StdinFileInfo();
  150. self::assertFalse($fileInfo->isWritable());
  151. }
  152. public function testOpenFile(): void
  153. {
  154. $fileInfo = new StdinFileInfo();
  155. $this->expectException(\BadMethodCallException::class);
  156. $this->expectExceptionMessage('Method "PhpCsFixer\StdinFileInfo::openFile" is not implemented.');
  157. $fileInfo->openFile();
  158. }
  159. }