From cef69a1545e7eafa4fca1021d1f0f295f97ad314 Mon Sep 17 00:00:00 2001 From: shibafu Date: Sun, 16 Feb 2020 14:49:55 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE=E6=96=87?= =?UTF-8?q?=E5=AD=97=E6=95=B0,=E6=94=B9=E8=A1=8C=E3=81=AA=E3=81=A9?= =?UTF-8?q?=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Unit/Io/CheckinCsvImporterTest.php | 35 +++++++++++++++++++ .../Csv/note-over-length.ascii.utf8.csv | 2 ++ .../fixture/Csv/note-over-length.jp.utf8.csv | 2 ++ tests/fixture/Csv/note.utf8.csv | 5 +++ 4 files changed, 44 insertions(+) create mode 100644 tests/fixture/Csv/note-over-length.ascii.utf8.csv create mode 100644 tests/fixture/Csv/note-over-length.jp.utf8.csv create mode 100644 tests/fixture/Csv/note.utf8.csv diff --git a/tests/Unit/Io/CheckinCsvImporterTest.php b/tests/Unit/Io/CheckinCsvImporterTest.php index 71256d0..b4cecfb 100644 --- a/tests/Unit/Io/CheckinCsvImporterTest.php +++ b/tests/Unit/Io/CheckinCsvImporterTest.php @@ -101,4 +101,39 @@ class CheckinCsvImporterTest extends TestCase $this->fail('期待する例外が発生していません'); } + + public function testNoteUTF8() + { + $user = factory(User::class)->create(); + + $importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/note.utf8.csv'); + $importer->execute(); + $ejaculations = $user->ejaculations()->orderBy('ejaculated_date')->get(); + + $this->assertCount(3, $ejaculations); + $this->assertEquals('The quick brown fox jumps over the lazy dog. 素早い茶色の狐はのろまな犬を飛び越える', $ejaculations[0]->note); + $this->assertEquals("The quick brown fox jumps over the lazy dog.\n素早い茶色の狐はのろまな犬を飛び越える", $ejaculations[1]->note); + $this->assertEquals('The quick brown fox jumps over the "lazy" dog.', $ejaculations[2]->note); + } + + /** + * @dataProvider provideNoteOverLength + */ + public function testNoteOverLength($filename) + { + $user = factory(User::class)->create(); + $this->expectException(CsvImportException::class); + $this->expectExceptionMessage('2 行 : ノートには500文字以下の文字列を指定してください。'); + + $importer = new CheckinCsvImporter($user, $filename); + $importer->execute(); + } + + public function provideNoteOverLength() + { + return [ + 'ASCII Only, UTF8' => [__DIR__ . '/../../fixture/Csv/note-over-length.ascii.utf8.csv'], + 'JP, UTF8' => [__DIR__ . '/../../fixture/Csv/note-over-length.jp.utf8.csv'], + ]; + } } diff --git a/tests/fixture/Csv/note-over-length.ascii.utf8.csv b/tests/fixture/Csv/note-over-length.ascii.utf8.csv new file mode 100644 index 0000000..33d1c37 --- /dev/null +++ b/tests/fixture/Csv/note-over-length.ascii.utf8.csv @@ -0,0 +1,2 @@ +日時,ノート +2020/01/23 06:01,oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooox diff --git a/tests/fixture/Csv/note-over-length.jp.utf8.csv b/tests/fixture/Csv/note-over-length.jp.utf8.csv new file mode 100644 index 0000000..47d4c4e --- /dev/null +++ b/tests/fixture/Csv/note-over-length.jp.utf8.csv @@ -0,0 +1,2 @@ +日時,ノート +2020/01/23 06:01,ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああい diff --git a/tests/fixture/Csv/note.utf8.csv b/tests/fixture/Csv/note.utf8.csv new file mode 100644 index 0000000..a585535 --- /dev/null +++ b/tests/fixture/Csv/note.utf8.csv @@ -0,0 +1,5 @@ +日時,ノート +2020/01/23 06:01,The quick brown fox jumps over the lazy dog. 素早い茶色の狐はのろまな犬を飛び越える +2020/01/23 06:02,"The quick brown fox jumps over the lazy dog. +素早い茶色の狐はのろまな犬を飛び越える" +2020/01/23 06:03,"The quick brown fox jumps over the ""lazy"" dog."