-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The NoopFileLocator will be used as the default MintwareDe\NativeCron\Filesystem\CrontabFileLocatorInterface. This change will fix the error when installing the bundle without configure the service before.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# Changelog | ||
|
||
## v1.0.1 | ||
Added a NoopFileLocator to prevent errors when installing the bundle. | ||
|
||
## v1.0.0 | ||
Initial release |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MintwareDe\NativeCronBundle\Filesystem; | ||
|
||
use MintwareDe\NativeCron\Filesystem\CrontabFileLocatorInterface; | ||
|
||
class NoopFileLocator implements CrontabFileLocatorInterface | ||
{ | ||
public const EXCEPTION_MSG = 'You need to specify a CrontabFileLocatorInterface. Check the README at https://github.com/mintware-de/native-cron-bundle.'; | ||
|
||
public function locateDropInCrontab(string $name): string | ||
{ | ||
throw new \Exception(self::EXCEPTION_MSG); | ||
} | ||
|
||
public function locateUserCrontab(string $username): string | ||
{ | ||
throw new \Exception(self::EXCEPTION_MSG); | ||
} | ||
|
||
public function locateSystemCrontab(): string | ||
{ | ||
throw new \Exception(self::EXCEPTION_MSG); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MintwareDe\NativeCronBundle\Tests\Filesystem; | ||
|
||
use MintwareDe\NativeCron\Filesystem\CrontabFileLocatorInterface; | ||
use MintwareDe\NativeCronBundle\Filesystem\NoopFileLocator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NoopFileLocatorTest extends TestCase | ||
{ | ||
private NoopFileLocator $locator; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->locator = new NoopFileLocator(); | ||
self::assertInstanceOf(CrontabFileLocatorInterface::class, $this->locator); | ||
|
||
self::expectException(\Exception::class); | ||
self::expectExceptionMessage(NoopFileLocator::EXCEPTION_MSG); | ||
} | ||
|
||
public function testLocateDropInCrontabShouldThrow(): void | ||
{ | ||
$this->locator->locateDropInCrontab(''); | ||
} | ||
|
||
public function testLocateUserCrontabShouldThrow(): void | ||
{ | ||
$this->locator->locateUserCrontab(''); | ||
} | ||
|
||
public function testLocateSystemCrontabShouldThrow(): void | ||
{ | ||
$this->locator->locateSystemCrontab(); | ||
} | ||
} |