How do I deal with Class 'PHPUnit_Framework_TestCase' not found error?

北战南征 提交于 2019-12-25 08:27:48

问题


I am trying to integrate to visa direct API. I decided to to it in PHP. However, as I am doing some tests from a sample code they have provided, I got stuck at Fatal error: Class 'PHPUnit_Framework_TestCase' not found error.

I have PHPUnit installed since when I check via phpunit --version ..I get PHPUnit 5.6.2 by Sebastian Bergmann and contributors.

Below is my code using PHPUnit, would someone direct me where my mistake is? Thank you.

<?php
class MVisaTest extends \PHPUnit_Framework_TestCase {

    public function setUp() {
        $this->visaAPIClient = new VisaAPIClient;
        $strDate = date('Y-m-d\TH:i:s', time());
        $this->mVisaTransactionRequest = json_encode ([
            "acquirerCountryCode" => "643",
            "acquiringBin" => "400171",
            "amount" => "124.05",
            "businessApplicationId" => "CI",
            "cardAcceptor" => [
            "address" => [
            "city" => "Bangalore",
            "country" => "IND"
        ],
            "idCode" => "ID-Code123",
            "name" => "Card Accpector ABC"
        ],
            "localTransactionDateTime" => $strDate,
            "merchantCategoryCode" => "4829",
            "recipientPrimaryAccountNumber" => "4123640062698797",
            "retrievalReferenceNumber" => "430000367618",
            "senderAccountNumber" => "4541237895236",
            "senderName" => "Mohammed Qasim",
            "senderReference" => "1234",
            "systemsTraceAuditNumber" => "313042",
            "transactionCurrencyCode" => "USD",
            "transactionIdentifier" => "381228649430015"
        ]);
    }

    public function testMVisaTransactions() {
        $baseUrl = "visadirect/";
        $resourcePath = "mvisa/v1/cashinpushpayments";
        $statusCode = $this->visaAPIClient->doMutualAuthCall ( 'post', $baseUrl.$resourcePath, 'M Visa Transaction Test', $this->mVisaTransactionRequest );
        $this->assertEquals($statusCode, "200");
    }
}

回答1:


You can just use TestCase class instead so you can say:

use PHPUnit\Framework\TestCase;

class MVisaTest extends TestCase {

  // your tests goes here

}


来源:https://stackoverflow.com/questions/40341950/how-do-i-deal-with-class-phpunit-framework-testcase-not-found-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!