与phpUnit的命名空间冲突

tquggr8v  于 2023-05-12  发布在  PHP
关注(0)|答案(1)|浏览(88)

要测试的文件:/a/B/c/API/localclass/s/taxinformationrepository.class.phptest:
/a/b/c/api/tests/_helpers/TestTaxInformationRepository_class.php
phpUnit目录位置:
/a/B/c/API/phpUnit/
composer.json:
{

"require": {  

    "phpunit/phpunit": "^9.6"  

},
"autoload": { 
    "psr-4": {"App\\\\": "/a/b/c/api/localclass/s/"} 
}, 
"autoload-dev": {
    "psr-4": {"App\\\\Tests\\\\": "/a/b/c/api/tests/\_helpers/"} 
}

}
TestTaxInformationRepository_class.php:

<?php
namespace App\Tests;

use App\S_TaxInformationRepository;
use PHPUnit\Framework\TestCase;

class TestTaxInformationRepository_class extends TestCase{

    public function GetConceptInputsAnnual_lePasoArrayDevuelveString(): void
    {
        $getConceptInputsAnnualArray=['year' => 2022, 'account' => '4600015', 'accountMatrixPosition' => "when '46000015' then (1)"];
        $taxinformationrepository_class=new S_TaxInformationRepository();
        $resultado=$taxinformationrepository_class->getConceptInputsAnnual($getConceptInputsAnnualArray);
        $this->assertEquals('hola',$resultado);
    }
}

taxinformationrepository.class.php:

<?php

namespace App;

public static function getConceptInputsAnnual($conditionsArray)
    {
        $resultData = [];
        $year                   = $conditionsArray["year"];
        $account                = $conditionsArray["account"];
        $accountMatrixPosition  = $conditionsArray['accountMatrixPosition'];

        $sql = "SELECT tblCO.COCODIGO AS 'col01',
                    tblGM.GMSPCODE AS 'col02',
                    tblCY.CYCCY AS 'col03',
                    '' AS 'col04',
                    CONCAT(SUBSTRING(tblGM.GMOPEDATE,7,2),'/', SUBSTRING(tblGM.GMOPEDATE,5,2), '/',SUBSTRING(tblGM.GMOPEDATE,1,4))  AS 'col05',
                    tblGM.GMVOLUME AS 'col06',
                    tblGM.GMPRICE AS 'col07',
                    (tblGM.GMCORRETAJE + tblGM.GMLIQUIDADORCOM + tblGM.GMCONTRATACIONCOM + tblGM.GMGESTIONCOM + tblGM.GMSCLCOM 
                    + tblGM.GMOTHERSCOM + tblGM.GMCLIENTCOM + tblGM.GMTOBINTAX) AS 'col08', 
                    (tblGM.GMEXCHANGE * tblGM.GMGROSSAMOUNT) AS 'col09',
                    tblGM.GMGROSSAMOUNT AS 'col10',
                    CASE GMSPCODE 
                        {$accountMatrixPosition}
                    END AS 'col11',
                    tblGM.GMISIN AS 'colTo_isin',
                    tblGM.GMCODOPERATION AS 'colTo_opeCode',
                    tblGM.GMTIPOMOV AS 'colTo_isAnulated',
                    tblGM.GMEXCHANGE AS 'colTo_exchangeRate',
                    tblGM.GMCCY AS 'colTo_DivisaCode'
                FROM BAGCMOVEMENT AS tblGM
                    LEFT JOIN (SELECT
                        COSIGNOTITULOS,
                        COCODIGO,
                        ROW_NUMBER() OVER (PARTITION BY COCODIGO ORDER BY COINDEX) AS code_rn
                    FROM BACONCEPTOSTMP) tblCO ON 
                    tblGM.GMTYPE = tblCO.COCODIGO AND tblCO.code_rn = 1
                    LEFT JOIN BACCY AS tblCY ON
                    tblGM.GMCCY = tblCY.CYCODE
                WHERE tblGM.GMSPCODE IN ({$account}) AND
                    tblCO.COSIGNOTITULOS = '+'
                          AND tblCO.COCODIGO IS NOT NULL
                    AND YEAR(CONVERT(DATE, tblGM.GMOPEDATE)) = {$year}
                    ORDER BY tblGM.GMOPEDATE, 'colTo_isin' ASC;";

        $resultData = SQL::fetchAll($sql, 'BACKOFFICE', Config::get('BKDB', 'SQL'));
        return $resultData;
    }

然后我通过命令行运行测试:

-$./vendor/bin/phpunit /home/administrador/Documentos/api-es-front-01/tests/_helpers/TestTaxInformationRepository_class.php

然后我得到以下结果:
PHPUnit 9.6.7由塞巴斯蒂安Bergmann和贡献者编写。
W 1 / 1(100%)
时间:00:00.002,内存:4.00 MB
有1个警告:
1.警告在类“App\Tests\TestTaxInformationRepository_class”中未找到测试。
警告!
测试:1,Assert:0,警告:1.
为什么找不到测试?我期待着这样的东西:
PHPUnit 9.6.7由塞巴斯蒂安Bergmann和贡献者编写。
女1 / 1(100%)
时间:00:00.113,内存:4.00 MB
有1例失败:

  1. App\Tests\TestTaxInformationRepository_class::getConceptInputsAnnual_lePasoArrayDevuelveString
    Assert两个字符串相等失败。
    ---预期
    +实际值
    @@@
  • 你好
    +'(大量数据)'
    /a/B/c/API/tests/_helpers/TestTaxInformationRepository_class.php:14
    失败!
    测试:1,Assert:1、故障:1.
ax6ht2ek

ax6ht2ek1#

我可以通过添加
/**@test
函数前
谢谢!

相关问题