簡體   English   中英

如何處理“ PHPUnit_Framework_TestCase”類未找到錯誤?

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

我正在嘗試整合到Visa Direct API。 我決定在PHP中使用它。 但是,當我從它們提供的示例代碼進行一些測試時,我陷入了Fatal error: Class 'PHPUnit_Framework_TestCase' not found錯誤。

自從我通過phpunit --version檢查時,我就安裝了PHPUnit。 I get PHPUnit 5.6.2 by Sebastian Bergmann and contributors.

下面是我使用PHPUnit的代碼,有人可以將我的錯誤指示給我嗎? 謝謝。

<?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");
    }
}

您可以只使用TestCase類,這樣您可以說:

use PHPUnit\Framework\TestCase;

class MVisaTest extends TestCase {

  // your tests goes here

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM