Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jun 8, 2021
1 parent cd66294 commit 18ae7ea
Show file tree
Hide file tree
Showing 4 changed files with 887 additions and 4 deletions.
18 changes: 14 additions & 4 deletions system/Publisher/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public static function discover($directory = 'Publishers'): array
return [];
}

// Loop over each file checking to see if it is a Primer
foreach ($files as $file)
// Loop over each file checking to see if it is a Publisher
foreach (array_unique($files) as $file)
{
$className = $locator->findQualifiedNameFromPath($file);

Expand Down Expand Up @@ -228,8 +228,10 @@ private static function wipeDirectory(string $directory)
$attempts = 10;
while ((bool) $attempts && ! delete_files($directory, true, false, true))
{
// @codeCoverageIgnoreStart
$attempts--;
usleep(100000); // .1s
// @codeCoverageIgnoreEnd
}

@rmdir($directory);
Expand Down Expand Up @@ -270,6 +272,13 @@ private static function safeCopyFile(string $from, string $to, bool $replace): v
unlink($to);
}

// Make sure the directory exists
$directory = pathinfo($to, PATHINFO_DIRNAME);
if (! is_dir($directory))
{
mkdir($directory, 0775, true);
}

// Allow copy() to throw errors
copy($from, $to);
}
Expand Down Expand Up @@ -311,10 +320,11 @@ public function __destruct()
* This method should be reimplemented by
* child classes intended for discovery.
*
* @return void
* @return bool
*/
public function publish()
{
return $this->addPath('/')->merge(true);
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -686,7 +696,7 @@ public function merge(bool $replace = true): bool
$this->errors = [];

// Get the file from source for special handling
$sourced = self::matchFiles($this->getFiles(), $this->source);
$sourced = self::filterFiles($this->getFiles(), $this->source);

// Handle everything else with a flat copy
$this->files = array_diff($this->files, $sourced);
Expand Down
Loading

0 comments on commit 18ae7ea

Please sign in to comment.