This repository has been archived by the owner on Jan 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Database: add support to delete generated database dumps after-scenario.
If WordHat is configured to generate a DB dump during its run, WordHat was leaving alot of files littering up PHP's temporary folder. Sorry! See #227
- Loading branch information
Showing
6 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace PaulGibbs\WordpressBehatExtension\Context\Traits; | ||
|
||
/** | ||
* Provides driver agnostic logic (helper methods) relating to a filesystem or files. | ||
*/ | ||
trait FilesystemAwareContextTrait | ||
{ | ||
use BaseAwarenessTrait; | ||
|
||
/** | ||
* Delete specified file. | ||
* | ||
* @param string $abspath Absolute path to a file, to delete. | ||
*/ | ||
public function deleteFile(string $abspath) | ||
{ | ||
$this->getDriver()->filesystem->deleteFile($abspath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace PaulGibbs\WordpressBehatExtension\Driver\Element\Wpcli; | ||
|
||
use RuntimeException; | ||
use PaulGibbs\WordpressBehatExtension\Driver\Element\BaseElement; | ||
|
||
/** | ||
* WP-CLI driver element for manipulating the filesystem. | ||
*/ | ||
class FilesystemElement extends BaseElement | ||
{ | ||
/** | ||
* Delete specified file. | ||
* | ||
* @param string $abspath Absolute path to a file, to delete. | ||
*/ | ||
public function deleteFile(string $abspath) | ||
{ | ||
if (empty($abspath)) { | ||
return; | ||
} | ||
|
||
$delete_cmd = sprintf('@unlink(%s);', escapeshellarg($abspath)); | ||
$this->drivers->getDriver()->wpcli('eval', $delete_cmd, ['--skip-wordpress']); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace PaulGibbs\WordpressBehatExtension\Driver\Element\Wpphp; | ||
|
||
use RuntimeException; | ||
use PaulGibbs\WordpressBehatExtension\Driver\Element\BaseElement; | ||
|
||
/** | ||
* WP-API driver element for manipulating the filesystem. | ||
*/ | ||
class FilesystemElement extends BaseElement | ||
{ | ||
/** | ||
* Delete specified file. | ||
* | ||
* @param string $abspath Absolute path to a file, to delete. | ||
*/ | ||
public function deleteFile(string $abspath) | ||
{ | ||
if (empty($abspath) || ! is_file($abspath) || ! is_readable($abspath)) { | ||
return; | ||
} | ||
|
||
wp_delete_file($abspath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters