mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 14:23:44 +02:00
Add test for service option exporter
This commit is contained in:
47
tests/Assertions/NestedObjectAssertionsTrait.php
Normal file
47
tests/Assertions/NestedObjectAssertionsTrait.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Tests\Assertions;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit_Util_InvalidArgumentHelper;
|
||||
|
||||
trait NestedObjectAssertionsTrait
|
||||
{
|
||||
/**
|
||||
* Assert that an object value matches an expected value.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $expected
|
||||
* @param object $object
|
||||
*/
|
||||
public function assertObjectNestedValueEquals(string $key, $expected, $object)
|
||||
{
|
||||
if (! is_object($object)) {
|
||||
throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'object');
|
||||
}
|
||||
|
||||
Assert::assertEquals($expected, object_get_strict($object, $key, '__TEST_FAILURE'), 'Assert that an object value equals a provided value.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that an object contains a nested key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param object $object
|
||||
*/
|
||||
public function assertObjectHasNestedAttribute(string $key, $object)
|
||||
{
|
||||
if (! is_object($object)) {
|
||||
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object');
|
||||
}
|
||||
|
||||
Assert::assertNotEquals('__TEST_FAILURE', object_get_strict($object, $key, '__TEST_FAILURE'), 'Assert that an object contains a nested key.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user