ejaculated_dateの重複エラーをcatch
This commit is contained in:
@@ -265,4 +265,19 @@ class CheckinCsvImporterTest extends TestCase
|
||||
$this->assertSame(1, $user->ejaculations()->count());
|
||||
$this->assertEquals(Ejaculation::SOURCE_CSV, $ejaculation->source);
|
||||
}
|
||||
|
||||
public function testDontThrowUniqueKeyViolation()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
factory(Ejaculation::class)->create([
|
||||
'user_id' => $user->id,
|
||||
'ejaculated_date' => Carbon::create(2020, 1, 23, 6, 1, 0, 'Asia/Tokyo')
|
||||
]);
|
||||
|
||||
$this->expectException(CsvImportException::class);
|
||||
$this->expectExceptionMessage('2 行 : すでにこの日時のチェックインデータが存在します。');
|
||||
|
||||
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/date.utf8.csv');
|
||||
$importer->execute();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user