Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8891ad0

Browse files
committed
Fix tests
1 parent d16f1f0 commit 8891ad0

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

‎src/GridFS/Exception/LogicException.php‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@
1717

1818
namespace MongoDB\GridFS\Exception;
1919

20+
use LogicException as BaseLogicException;
2021
use MongoDB\Exception\Exception;
2122
use MongoDB\GridFS\CollectionWrapper;
2223

2324
use function get_debug_type;
2425
use function sprintf;
2526

26-
class LogicException extends \LogicException implements Exception
27+
class LogicException extends BaseLogicException implements Exception
2728
{
2829
/**
29-
* Thrown when using an unsupported stream mode with fopen('gridfs://...', $mode).
30+
* Throw when a bucket alias is used with global gridfs stream wrapper, but the alias is not registered.
3031
*
3132
* @internal
3233
*/
33-
public static function openModeNotSupported(string $mode): self
34+
public static function bucketAliasNotRegistered(string $alias): self
3435
{
35-
return new self(sprintf('Mode "%s" is not supported by "gridfs://" files. Use one of "r", "rb", "w", or "wb".', $mode));
36+
return new self(sprintf('GridFS stream wrapper has no bucket alias: "%s"', $alias));
3637
}
3738

3839
/**
@@ -58,12 +59,12 @@ public static function invalidContextCollectionWrapper($object): self
5859
}
5960

6061
/**
61-
* Throw when a bucket alias is used with global gridfs stream wrapper, but the alias is not registered.
62+
* Thrown when using an unsupported stream mode with fopen('gridfs://...', $mode).
6263
*
6364
* @internal
6465
*/
65-
public static function bucketAliasNotRegistered(string $alias): self
66+
public static function openModeNotSupported(string $mode): self
6667
{
67-
return new self(sprintf('GridFS stream wrapper has no bucket alias: "%s"', $alias));
68+
return new self(sprintf('Mode "%s" is not supported by "gridfs://" files. Use one of "r", "rb", "w", or "wb".', $mode));
6869
}
6970
}

‎src/GridFS/StreamWrapper.php‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,6 @@ public function getFile(): object
7676
return $this->stream->getFile();
7777
}
7878

79-
/** @return false|array */
80-
public function url_stat(string $path, int $flags)
81-
{
82-
try {
83-
$this->stream_open($path, 'r', 0, $openedPath);
84-
} catch (FileNotFoundException $e) {
85-
return false;
86-
}
87-
88-
return $this->stream_stat();
89-
}
90-
9179
/**
9280
* Register the GridFS stream wrapper.
9381
*
@@ -309,6 +297,18 @@ public function stream_write(string $data): int
309297
return $this->stream->writeBytes($data);
310298
}
311299

300+
/** @return false|array */
301+
public function url_stat(string $path, int $flags)
302+
{
303+
try {
304+
$this->stream_open($path, 'r', 0, $openedPath);
305+
} catch (FileNotFoundException $e) {
306+
return false;
307+
}
308+
309+
return $this->stream_stat();
310+
}
311+
312312
/**
313313
* Returns a stat template with default values.
314314
*/

‎tests/ExamplesTest.php‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ public static function provideExamples(): Generator
9999
'expectedOutput' => $expectedOutput,
100100
];
101101

102+
$expectedOutput = <<<'OUTPUT'
103+
File exists: no
104+
Writing file
105+
File exists: yes
106+
Reading file: Hello, GridFS!
107+
Writing new version of the file
108+
Reading new version of the file: Hello, GridFS! (v2)
109+
Reading previous version of the file: Hello, GridFS!
110+
OUTPUT;
111+
112+
yield 'gridfs-stream-wrapper' => [
113+
'file' => __DIR__ . '/../examples/gridfs-stream-wrapper.php',
114+
'expectedOutput' => $expectedOutput,
115+
];
116+
102117
$expectedOutput = <<<'OUTPUT'
103118
MongoDB\Examples\Persistable\PersistableEntry Object
104119
(
@@ -127,21 +142,6 @@ public static function provideExamples(): Generator
127142
)
128143
OUTPUT;
129144

130-
$expectedOutput = <<<'OUTPUT'
131-
File exists: no
132-
Writing file
133-
File exists: yes
134-
Reading file: Hello, GridFS!
135-
Writing new version of the file
136-
Reading new version of the file: Hello, GridFS! (v2)
137-
Reading previous version of the file: Hello, GridFS!
138-
OUTPUT;
139-
140-
yield 'gridfs-stream-wrapper' => [
141-
'file' => __DIR__ . '/../examples/gridfs-stream-wrapper.php',
142-
'expectedOutput' => $expectedOutput,
143-
];
144-
145145
yield 'persistable' => [
146146
'file' => __DIR__ . '/../examples/persistable.php',
147147
'expectedOutput' => $expectedOutput,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /