graphql-php/tests/UtilsTest.php

24 lines
590 B
PHP
Raw Permalink Normal View History

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