graphql-php/tests/UtilsTest.php

24 lines
590 B
PHP
Raw Normal View History

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