-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from bram123/add-result-data-values
Set extra result data fields
- Loading branch information
Showing
7 changed files
with
88 additions
and
12 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
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
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
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,68 @@ | ||
<?php | ||
|
||
namespace LaminasTest\Diagnostics; | ||
|
||
use InvalidArgumentException; | ||
use Laminas\Diagnostics\Check\ExtensionLoaded; | ||
use Laminas\Diagnostics\Result\FailureInterface; | ||
use Laminas\Diagnostics\Result\SuccessInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use stdClass; | ||
|
||
use function phpversion; | ||
|
||
/** @covers \Laminas\Diagnostics\Check\ExtensionLoaded */ | ||
final class ExtensionLoadedTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider invalidArgumentProvider | ||
* @param mixed $extensionName | ||
*/ | ||
public function testInvalidArguments($extensionName): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
|
||
new ExtensionLoaded($extensionName); | ||
} | ||
|
||
public function testCheck(): void | ||
{ | ||
$check = new ExtensionLoaded('json'); | ||
$result = $check->check(); | ||
|
||
self::assertInstanceof(SuccessInterface::class, $result); | ||
self::assertSame('json ' . phpversion('json'), $result->getData()); | ||
|
||
$check = new ExtensionLoaded(['json', 'xml']); | ||
$result = $check->check(); | ||
|
||
self::assertInstanceof(SuccessInterface::class, $result); | ||
self::assertSame(['json' => phpversion('json'), 'xml' => phpversion('xml')], $result->getData()); | ||
} | ||
|
||
public function testCheckMissingExtension(): void | ||
{ | ||
$check = new ExtensionLoaded('unknown-foo'); | ||
$result = $check->check(); | ||
|
||
self::assertInstanceof(FailureInterface::class, $result); | ||
self::assertSame(['unknown-foo'], $result->getData()); | ||
|
||
$check = new ExtensionLoaded(['unknown-foo', 'unknown-bar']); | ||
$result = $check->check(); | ||
|
||
self::assertInstanceof(FailureInterface::class, $result); | ||
self::assertSame(['unknown-foo', 'unknown-bar'], $result->getData()); | ||
} | ||
|
||
/** | ||
* @return array<int, array<int, mixed>> | ||
*/ | ||
public function invalidArgumentProvider(): array | ||
{ | ||
return [ | ||
[new stdClass()], | ||
[100], | ||
]; | ||
} | ||
} |