问题描述
我正在使用工厂模型来测试我的应用,但是特殊字符给我一些问题,并且
use RefreshDatabase;
请勿在测试之前将我的数据库恢复为状态!
这是我的工厂:
class TransactionFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Transaction::class;
/**
* Define the model's default state.
*
* @return array
*/
public function deFinition()
{
return [
//
'customer' => '1','date' => '10/10/2010','value' => '€1.00',];
}
}
这是我测试中失败的函数:
class GetReportTest extends TestCase
{
protected $tableHeader=['id','customer','date','value'];
protected $rows;//=[['1','1','10/10/2010','EUR 55.201818920353']];
protected $tableName='transactions';
//protected $transaction;
use RefreshDatabase;
public function testDatabaseCustomer1()
{
$transaction = Transaction::factory()->create();
// Make call to application...
$this->assertDatabaseHas($this->tableName,[
'customer' => $transaction->id,]);
$this->assertDeleted($transaction);
}
}
> • Tests\Unit\GetReportTest > database customer1 Failed asserting
> that a row in the table [transactions] does not match the attributes {
> "id": 1 }.
> Found similar results: [
> {
> "id": 1,> "customer": 1,> "date": "10\/10\/2010",> "value": "\u20ac1.00"
> } ].
我可以在哪里解决此问题? 并且数据库的非还原链接到此错误吗?
谢谢
'charset' => 'utf8mb4','collation' => 'utf8mb4_unicode_ci',
并且数据库位于:
InnoDB utf8mb4_unicode_ci
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)