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