requiredKey = 'value'; $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Key requiredKey is expected to be set and not to be null'); Utils::assign($object, [], ['requiredKey']); } }