|
3 | 3 | namespace Spatie\Snapshots; |
4 | 4 |
|
5 | 5 | use PHPUnit\Framework\ExpectationFailedException; |
6 | | -use ReflectionClass; |
7 | 6 | use ReflectionObject; |
| 7 | +use Spatie\Snapshots\Concerns\SnapshotDirectoryAware; |
| 8 | +use Spatie\Snapshots\Concerns\SnapshotIdAware; |
8 | 9 | use Spatie\Snapshots\Drivers\HtmlDriver; |
9 | 10 | use Spatie\Snapshots\Drivers\JsonDriver; |
10 | 11 | use Spatie\Snapshots\Drivers\ObjectDriver; |
|
14 | 15 |
|
15 | 16 | trait MatchesSnapshots |
16 | 17 | { |
| 18 | + use SnapshotDirectoryAware, SnapshotIdAware; |
| 19 | + |
17 | 20 | protected int $snapshotIncrementor = 0; |
18 | 21 |
|
19 | 22 | protected array $snapshotChanges = []; |
@@ -105,29 +108,6 @@ public function assertMatchesYamlSnapshot($actual): void |
105 | 108 | $this->assertMatchesSnapshot($actual, new YamlDriver()); |
106 | 109 | } |
107 | 110 |
|
108 | | - /* |
109 | | - * Determines the snapshot's id. By default, the test case's class and |
110 | | - * method names are used. |
111 | | - */ |
112 | | - protected function getSnapshotId(): string |
113 | | - { |
114 | | - return (new ReflectionClass($this))->getShortName().'__'. |
115 | | - $this->getName().'__'. |
116 | | - $this->snapshotIncrementor; |
117 | | - } |
118 | | - |
119 | | - /* |
120 | | - * Determines the directory where snapshots are stored. By default a |
121 | | - * `__snapshots__` directory is created at the same level as the test |
122 | | - * class. |
123 | | - */ |
124 | | - protected function getSnapshotDirectory(): string |
125 | | - { |
126 | | - return dirname((new ReflectionClass($this))->getFileName()). |
127 | | - DIRECTORY_SEPARATOR. |
128 | | - '__snapshots__'; |
129 | | - } |
130 | | - |
131 | 111 | /* |
132 | 112 | * Determines the directory where file snapshots are stored. By default a |
133 | 113 | * `__snapshots__/files` directory is created at the same level as the |
|
0 commit comments