StdinFileInfoTest.php 4.6 KB

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