2017-02-13 20:50:34 +03:00
|
|
|
<?php
|
2018-09-02 14:39:30 +03:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-02-13 20:50:34 +03:00
|
|
|
namespace GraphQL\Tests;
|
|
|
|
|
2017-07-10 15:50:26 +03:00
|
|
|
use GraphQL\Utils\Utils;
|
2018-07-29 18:43:10 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2017-02-13 20:50:34 +03:00
|
|
|
|
2018-07-29 18:43:10 +03:00
|
|
|
class UtilsTest extends TestCase
|
2017-02-13 20:50:34 +03:00
|
|
|
{
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testAssignThrowsExceptionOnMissingRequiredKey() : void
|
2017-02-13 20:50:34 +03:00
|
|
|
{
|
2018-09-02 14:39:30 +03:00
|
|
|
$object = new \stdClass();
|
2017-02-13 20:50:34 +03:00
|
|
|
$object->requiredKey = 'value';
|
|
|
|
|
2018-07-29 18:43:10 +03:00
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
$this->expectExceptionMessage('Key requiredKey is expected to be set and not to be null');
|
2017-12-21 09:52:43 +03:00
|
|
|
Utils::assign($object, [], ['requiredKey']);
|
2017-02-13 20:50:34 +03:00
|
|
|
}
|
|
|
|
}
|