3737#[CoversClass(Executor::class)]
3838class ExecutorTest extends TestCase
3939{
40+ /**
41+ * @link \DatabaseBackup\Executor\Executor::implementedEvents()
42+ */
4043 #[Test]
4144 public function testImplementedEvents (): void
4245 {
46+ $ expected = [
47+ 'Backup.afterExport ' => 'afterExport ' ,
48+ 'Backup.afterImport ' => 'afterImport ' ,
49+ 'Backup.beforeExport ' => 'beforeExport ' ,
50+ 'Backup.beforeImport ' => 'beforeImport ' ,
51+ ];
4352 $ result = new FakeExecutor ()->implementedEvents ();
4453
45- $ this ->assertContains ('beforeExport ' , $ result );
46- $ this ->assertContains ('afterExport ' , $ result );
47- $ this ->assertContains ('beforeImport ' , $ result );
48- $ this ->assertContains ('afterImport ' , $ result );
54+ $ this ->assertSame ($ expected , $ result );
4955 }
5056
57+ /**
58+ * @link \DatabaseBackup\Executor\Executor::findBinary()
59+ */
5160 #[Test]
5261 #[TestWith(['/usr/bin/mariadb ' , 'mariadb ' ])]
5362 #[TestWith(['/usr/bin/mysql ' , 'mysql ' ])]
5463 #[TestWith(['/usr/bin/gzip ' , Compression::Gzip])]
5564 #[RunInSeparateProcess]
56- public function testFindBinary (string $ expectedBinary , string | Compression $ name ): void
65+ public function testFindBinary (string $ expectedBinary , Compression | string $ name ): void
5766 {
5867 Mockery::spy ('overload:Symfony\Component\Process\ExecutableFinder ' )
5968 ->shouldReceive ('find ' )
@@ -65,11 +74,14 @@ public function testFindBinary(string $expectedBinary, string|Compression $name)
6574 $ this ->assertSame ($ expectedBinary , $ result );
6675 }
6776
77+ /**
78+ * @link \DatabaseBackup\Executor\Executor::findBinary()
79+ */
6880 #[Test]
6981 #[TestWith(['/customPath/mariadb ' , 'mariadb ' ])]
7082 #[TestWith(['/customPath/mysql ' , 'mysql ' ])]
7183 #[TestWith(['/customPath/gzip ' , Compression::Gzip])]
72- public function testFindBinaryFromConfiguration (string $ expectedBinary , string | Compression $ binaryName ): void
84+ public function testFindBinaryFromConfiguration (string $ expectedBinary , Compression | string $ binaryName ): void
7385 {
7486 $ binaryName = $ binaryName instanceof Compression ? lcfirst ($ binaryName ->name ) : $ binaryName ;
7587 Configure::write (config: 'DatabaseBackup.binaries. ' . $ binaryName , value: '/customPath/ ' . $ binaryName );
@@ -80,17 +92,22 @@ public function testFindBinaryFromConfiguration(string $expectedBinary, string|C
8092 $ this ->assertSame ($ expectedBinary , $ result );
8193 }
8294
95+ /**
96+ * @link \DatabaseBackup\Executor\Executor::findBinary()
97+ */
8398 #[Test]
8499 public function testFindBinaryWithNoExistingBinary (): void
85100 {
86101 $ this ->expectException (InvalidArgumentException::class);
87- $ this ->expectExceptionMessage (sprintf (
88- 'Binary for `noExisting` not found. Set path manually: `%s` ' ,
89- 'Configure::write( \'DatabaseBackup.binaries.noExisting \', \'/path/to/noExisting \') '
90- ));
102+ $ this ->expectExceptionMessage (
103+ 'Binary for `noExisting` not found. Set path manually: `Configure::write( \'DatabaseBackup.binaries.noExisting \', \'/path/to/noExisting \')` ' ,
104+ );
91105 new FakeExecutor ()->findBinary ('noExisting ' );
92106 }
93107
108+ /**
109+ * @link \DatabaseBackup\Executor\Executor::findBinary()
110+ */
94111 #[Test]
95112 public function testFindBinaryWithCompressionNone (): void
96113 {
@@ -99,6 +116,9 @@ public function testFindBinaryWithCompressionNone(): void
99116 new FakeExecutor ()->findBinary (Compression::None);
100117 }
101118
119+ /**
120+ * @link \DatabaseBackup\Executor\Executor::getCommand()
121+ */
102122 #[Test]
103123 #[TestWith(['"${:BINARY}" "${:DB_NAME}" .dump > "${:FILENAME}" ' , OperationType::Export, Compression::None])]
104124 #[TestWith(['"${:BINARY}" "${:DB_NAME}" .dump | "${:COMPRESSION_BINARY}" > "${:FILENAME}" ' , OperationType::Export, Compression::Gzip])]
@@ -113,6 +133,9 @@ public function testGetCommand(string $expectedCommand, OperationType $Operation
113133 $ this ->assertSame ($ expectedCommand , $ result );
114134 }
115135
136+ /**
137+ * @link \DatabaseBackup\Executor\Executor::runProcess()
138+ */
116139 #[Test]
117140 #[TestWith(['"${:BINARY}" "${:DB_NAME}" .dump > "${:FILENAME}" ' , 'filename.sql ' , OperationType::Export])]
118141 #[TestWith(['"${:BINARY}" "${:DB_NAME}" .dump | "${:COMPRESSION_BINARY}" > "${:FILENAME}" ' , 'filename.sql.gz ' , OperationType::Export])]
@@ -202,6 +225,9 @@ public function testRunProcess(string $expectedCommand, string $filename, Operat
202225 $ this ->assertSame ($ Process , $ result );
203226 }
204227
228+ /**
229+ * @link \DatabaseBackup\Executor\Executor::runProcess()
230+ */
205231 #[Test]
206232 #[RunInSeparateProcess]
207233 public function testRunProcessOnFailure (): void
0 commit comments