【发布时间】:2021-03-01 18:51:51
【问题描述】:
我的 Codeception 冒险刚刚开始。
即使我声明了 assertEquals() 方法,我也遇到了问题
use PHPUnit\Framework\Assert;
代码测试:
<?php declare(strict_types=1);
namespace Product\TestApi;
use Product\ApiTester;
use Codeception\Util\HttpCode;
use PHPUnit\Framework\Assert;
public function CreateProduct(ApiTester $I)
{
$I->sendPost('/api/product/');
$I->seeResponseCodeIs(HttpCode::CREATED);
$responsePost = $I->grabDataFromResponseByJsonPath('$..product');
$I-$this->assertEquals(4,strlen((string)$responsePost));
$I->seeResponseContainsJson(
[
'category' => 'main',
'product' => 'fish',
]
);
}
}
我收到一个错误:
api/CreateProductCest.php:createProduct
[Error] Call to undefined method Product\TestApi\CreateProductCest::assertEquals()
Scenario Steps:
3. $I->grabDataFromResponseByJsonPath("$..product") at api/CreateProductCest.php:42
2. $I->seeResponseCodeIs(201) at api/CreateProductCest.php:41
1. $I->sendPost("/api/product/") at api/CreateProductCest.php:40
#1 /product-service/modules/Product/tests/api/CreateProductCest.php:43
#2 Product\TestApi\CreateProductCest->createProduct
Artifacts:
Body: {"id":3,"product":"fish","category":"main"}
【问题讨论】:
标签: php codeception