|
11 | 11 |
|
12 | 12 | namespace Zenstruck\Filesystem\Test\Node; |
13 | 13 |
|
14 | | -use League\Flysystem\UnableToGeneratePublicUrl; |
15 | | -use Zenstruck\Assert; |
16 | 14 | use Zenstruck\Filesystem\Node\File; |
17 | 15 | use Zenstruck\Filesystem\Node\File\DecoratedFile; |
18 | | -use Zenstruck\Filesystem\Node\File\Image; |
19 | 16 |
|
20 | 17 | /** |
21 | 18 | * @author Kevin Bond <kevinbond@gmail.com> |
22 | 19 | */ |
23 | 20 | class TestFile extends TestNode implements File |
24 | 21 | { |
25 | | - use DecoratedFile; |
| 22 | + use DecoratedFile, FileAssertions; |
26 | 23 |
|
27 | 24 | public function __construct(private File $inner) |
28 | 25 | { |
29 | 26 | } |
30 | 27 |
|
31 | | - public function assertContentIs(string $expected): self |
32 | | - { |
33 | | - Assert::that($this->contents())->is($expected); |
34 | | - |
35 | | - return $this; |
36 | | - } |
37 | | - |
38 | | - public function assertContentIsNot(string $expected): self |
39 | | - { |
40 | | - Assert::that($this->contents())->isNot($expected); |
41 | | - |
42 | | - return $this; |
43 | | - } |
44 | | - |
45 | | - public function assertContentContains(string $expected): self |
46 | | - { |
47 | | - Assert::that($this->contents())->contains($expected); |
48 | | - |
49 | | - return $this; |
50 | | - } |
51 | | - |
52 | | - public function assertContentDoesNotContain(string $expected): self |
53 | | - { |
54 | | - Assert::that($this->contents())->doesNotContain($expected); |
55 | | - |
56 | | - return $this; |
57 | | - } |
58 | | - |
59 | | - public function assertMimeTypeIs(string $expected): self |
60 | | - { |
61 | | - Assert::that($this->mimeType())->is($expected); |
62 | | - |
63 | | - return $this; |
64 | | - } |
65 | | - |
66 | | - public function assertMimeTypeIsNot(string $expected): self |
67 | | - { |
68 | | - Assert::that($this->mimeType())->isNot($expected); |
69 | | - |
70 | | - return $this; |
71 | | - } |
72 | | - |
73 | | - public function assertSize(int $expected): self |
74 | | - { |
75 | | - Assert::that($this->size())->is($expected); |
76 | | - |
77 | | - return $this; |
78 | | - } |
79 | | - |
80 | | - public function assertChecksum(string $expected): self |
81 | | - { |
82 | | - Assert::that($this->checksum())->is($expected); |
83 | | - |
84 | | - return $this; |
85 | | - } |
86 | | - |
87 | | - public function dump(): self |
88 | | - { |
89 | | - $what = [ |
90 | | - 'path' => (string) $this->path(), |
91 | | - 'mimeType' => $this->mimeType(), |
92 | | - 'lastModified' => $this->lastModified(), |
93 | | - 'size' => $this->size(), |
94 | | - ]; |
95 | | - |
96 | | - try { |
97 | | - $what['public_url'] = $this->publicUrl(); |
98 | | - } catch (UnableToGeneratePublicUrl) { |
99 | | - } |
100 | | - |
101 | | - if ($this instanceof Image) { |
102 | | - $what['image']['height'] = $this->dimensions()->height(); |
103 | | - $what['image']['width'] = $this->dimensions()->width(); |
104 | | - } |
105 | | - |
106 | | - \function_exists('dump') ? dump($what) : \var_dump($what); |
107 | | - |
108 | | - return $this; |
109 | | - } |
110 | | - |
111 | 28 | protected function inner(): File |
112 | 29 | { |
113 | 30 | return $this->inner; |
|
0 commit comments