|
6 | 6 | use Aternos\IO\Exception\CreateFileException; |
7 | 7 | use Aternos\IO\Exception\IOException; |
8 | 8 | use Aternos\IO\Exception\ReadException; |
| 9 | +use Aternos\IO\Exception\RewindException; |
9 | 10 | use Aternos\IO\Exception\SeekException; |
10 | 11 | use Aternos\IO\Exception\StatException; |
11 | 12 | use Aternos\IO\Exception\TruncateException; |
@@ -116,6 +117,38 @@ public function testSetPositionThrowsException(): void |
116 | 117 | $file->setPosition(-1); |
117 | 118 | } |
118 | 119 |
|
| 120 | + /** |
| 121 | + * @return void |
| 122 | + * @throws CreateDirectoryException |
| 123 | + * @throws CreateFileException |
| 124 | + * @throws IOException |
| 125 | + */ |
| 126 | + public function testRewindPosition(): void |
| 127 | + { |
| 128 | + $file = $this->getVolatileFile(); |
| 129 | + $file->write('test'); |
| 130 | + $this->assertEquals(4, $file->getPosition()); |
| 131 | + $file->rewindPosition(); |
| 132 | + $this->assertEquals(0, $file->getPosition()); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * @return void |
| 137 | + * @throws CreateDirectoryException |
| 138 | + * @throws CreateFileException |
| 139 | + * @throws IOException |
| 140 | + * @throws ReflectionException |
| 141 | + */ |
| 142 | + public function testRewindPositionThrowsException(): void |
| 143 | + { |
| 144 | + $file = $this->getVolatileFile(); |
| 145 | + $reflectionFile = new ReflectionObject($file); |
| 146 | + $socketResource = $reflectionFile->getProperty('socketResource'); |
| 147 | + $socketResource->setValue($file, fopen('php://output', 'w')); |
| 148 | + $this->expectException(RewindException::class); |
| 149 | + $file->rewindPosition(); |
| 150 | + } |
| 151 | + |
119 | 152 | /** |
120 | 153 | * @throws CreateDirectoryException |
121 | 154 | * @throws IOException |
|
0 commit comments