如何解决一些特殊的字符破坏了我在laravel中的单元测试
我正在使用工厂模型来测试我的应用,但是特殊字符给我一些问题,并且
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 举报,一经查实,本站将立刻删除。