4

Hi I'm trying to cxreate an API test for my custom module and I'm getting this error:

Fatal error: Class 'Magento\TestFramework\TestCase\WebapiAbstract' not found in /var/www/html/app/code/Wakanda/QuoteApi/Test/Api/CustomerQuoteTest.php on line 8

<?php 

namespace Wakanda\QuoteApi\Test\Api;

use Magento\TestFramework\TestCase\WebapiAbstract;
use Magento\Framework\Webapi\Rest\Request;

class CustomerQuoteTest extends WebapiAbstract
{
    public function testGetList()
    {
        $serviceInfo = [
            'rest' => [
                'resourcePath' => '',
                'httpMethod' => Request::HTTP_METHOD_GET,
            ],
        ];

        $response = $this->_webApiCall($serviceInfo);

        $this->assertArrayHasKey('search_criteria', $response);
        $this->assertArrayHasKey('item', $response);

        $this->assertTrue($response['total_count'] > 0);
        $this->assertTrue(count($response['total_count']) > 0);

        $this->assertNotNull($response['items'][0]['name']);
    }
}

Any help will be appreciated

0

Are you missing the dev folder?

In particular this file?

https://github.com/magento/magento2/blob/2.3/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php

| improve this answer | |
  • 1
    The file is there. Some of magento core tests are referencing it. I literally copied one of the tests and it still couldn't find it – CED-MAN Jun 17 '19 at 17:05
0

It seems like you're not using the phpunit config files located in dev/tests/api-functional.

If you want to execute the REST API functional tests, first copy the phpunit_rest.xml.dist to phpunit_rest.xml in the directory dev/tests/api-functional, then do the same for the install-config-mysql.php.dist (copy to install-config-mysql.php)

After that try executing the api functional tests from the integration tests folder:

cd dev/tests/integration
 ../../../vendor/bin/phpunit -c ../api-functional/phpunit_rest.xml

For me this was the solution. When I tried to execute phpunit_rest.xml directly from the API functional testing folder, I got this error.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.