我如何处理Class' PHPUnit_Framework_TestCase'找不到错误?

时间:2016-10-31 12:12:09

标签: php phpunit

我正在尝试整合签证直接API。我决定在PHP中使用它。但是,当我从他们提供的示例代码中进行一些测试时,我遇到了Fatal error: Class 'PHPUnit_Framework_TestCase' not found错误。

我通过phpunit --version .. I get PHPUnit 5.6.2 by Sebastian Bergmann and contributors.

检查后安装了PHPUnit

下面是我使用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");
    }
}

1 个答案:

答案 0 :(得分:3)

您只需使用 TestCase 类,就可以说:

use PHPUnit\Framework\TestCase;

class MVisaTest extends TestCase {

  // your tests goes here

}