Skip to content

Call to undefined method HttpException::getClass() #3286

@zspine

Description

@zspine

API Platform version(s) affected: 2.5.2

Description
I have used '\ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase' to do some functional tests and everything worked fine with api platform core version 2.5.0. After upgrading to v2.5.2 most of my tests started to throw the following exception:

1) App\Tests\Functional\RestApi\AccountResourceTest::testCreateAccountWithAnonymousUser
Error: Call to undefined method Symfony\Component\HttpKernel\Exception\HttpException::getClass()

/srv/app/vendor/api-platform/core/src/Action/ExceptionAction.php:53
/srv/app/vendor/symfony/http-kernel/HttpKernel.php:146
/srv/app/vendor/symfony/http-kernel/HttpKernel.php:68
/srv/app/vendor/symfony/http-kernel/EventListener/ErrorListener.php:59
/srv/app/vendor/api-platform/core/src/EventListener/ExceptionListener.php:52
/srv/app/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126
/srv/app/vendor/symfony/event-dispatcher/EventDispatcher.php:264
/srv/app/vendor/symfony/event-dispatcher/EventDispatcher.php:239
/srv/app/vendor/symfony/event-dispatcher/EventDispatcher.php:73
/srv/app/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168
/srv/app/vendor/symfony/http-kernel/HttpKernel.php:207
/srv/app/vendor/symfony/http-kernel/HttpKernel.php:79
/srv/app/vendor/symfony/http-kernel/Kernel.php:201
/srv/app/vendor/symfony/http-kernel/Client.php:65
/srv/app/vendor/symfony/framework-bundle/Client.php:131
/srv/app/vendor/symfony/browser-kit/Client.php:404
/srv/app/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Client.php:124
/srv/app/tests/Functional/RestApi/AccountResourceTest.php:97

How to reproduce

    public function testCreateAccountWithAnonymousUser()
    {
        $client = self::createClient();
        $client->request('POST', '/api/users', [
            'json' => [ ]
        ]);
        $this->assertResponseStatusCodeSame(401);
    }

Possible Solution
I am not quiet sure though, but I can clearly see some changes on 'ApiPlatform\Core\Action\ExceptionAction' class.

Additional Context
Downgrading the the version to 2.5.0 solves the problem!

P.S. I wish I can be more helpful, but I am not that fluent in English! Sorry about that!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions