タグ列のテスト
This commit is contained in:
parent
272e7ecc61
commit
24a5017334
@ -79,7 +79,11 @@ class CheckinCsvImporter
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mb_strlen($tag) > 255) {
|
if (mb_strlen($tag) > 255) {
|
||||||
$errors[] = "{$line} 行 : {$column}列は255文字以内にしてください。";
|
$errors[] = "{$line} 行 : {$column}は255文字以内にしてください。";
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
if (strpos($tag, "\n") !== false) {
|
||||||
|
$errors[] = "{$line} 行 : {$column}に改行を含めることはできません。";
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +91,8 @@ class CheckinCsvImporter
|
|||||||
$tagIds[] = $tag->id;
|
$tagIds[] = $tag->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ejaculation->tags()->sync($tagIds);
|
|
||||||
|
|
||||||
$ejaculation->save();
|
$ejaculation->save();
|
||||||
|
$ejaculation->tags()->sync($tagIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($errors)) {
|
if (!empty($errors)) {
|
||||||
|
@ -168,4 +168,67 @@ class CheckinCsvImporterTest extends TestCase
|
|||||||
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/link-not-url.utf8.csv');
|
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/link-not-url.utf8.csv');
|
||||||
$importer->execute();
|
$importer->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTag1UTF8()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
|
||||||
|
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/tag1.utf8.csv');
|
||||||
|
$importer->execute();
|
||||||
|
$ejaculation = $user->ejaculations()->first();
|
||||||
|
$tags = $ejaculation->tags()->get();
|
||||||
|
|
||||||
|
$this->assertSame(1, $user->ejaculations()->count());
|
||||||
|
$this->assertCount(1, $tags);
|
||||||
|
$this->assertEquals('貧乳', $tags[0]->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTag2UTF8()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
|
||||||
|
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/tag2.utf8.csv');
|
||||||
|
$importer->execute();
|
||||||
|
$ejaculation = $user->ejaculations()->first();
|
||||||
|
$tags = $ejaculation->tags()->get();
|
||||||
|
|
||||||
|
$this->assertSame(1, $user->ejaculations()->count());
|
||||||
|
$this->assertCount(2, $tags);
|
||||||
|
$this->assertEquals('貧乳', $tags[0]->name);
|
||||||
|
$this->assertEquals('巨乳', $tags[1]->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTagOverLengthUTF8()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$this->expectException(CsvImportException::class);
|
||||||
|
$this->expectExceptionMessage('3 行 : タグ1は255文字以内にしてください。');
|
||||||
|
|
||||||
|
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/tag-over-length.utf8.csv');
|
||||||
|
$importer->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTagCantAcceptJumpedColumnUTF8()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
|
||||||
|
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/tag-jumped-column.utf8.csv');
|
||||||
|
$importer->execute();
|
||||||
|
$ejaculation = $user->ejaculations()->first();
|
||||||
|
$tags = $ejaculation->tags()->get();
|
||||||
|
|
||||||
|
$this->assertSame(1, $user->ejaculations()->count());
|
||||||
|
$this->assertCount(1, $tags);
|
||||||
|
$this->assertEquals('貧乳', $tags[0]->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTagCantAcceptMultilineUTF8()
|
||||||
|
{
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$this->expectException(CsvImportException::class);
|
||||||
|
$this->expectExceptionMessage('2 行 : タグ1に改行を含めることはできません。');
|
||||||
|
|
||||||
|
$importer = new CheckinCsvImporter($user, __DIR__ . '/../../fixture/Csv/tag-multiline.utf8.csv');
|
||||||
|
$importer->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
2
tests/fixture/Csv/.editorconfig
vendored
Normal file
2
tests/fixture/Csv/.editorconfig
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.csv]
|
||||||
|
end_of_line = crlf
|
2
tests/fixture/Csv/tag-jumped-column.utf8.csv
vendored
Normal file
2
tests/fixture/Csv/tag-jumped-column.utf8.csv
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
日時,タグ1,タグ3
|
||||||
|
2020/01/23 06:01,貧乳,巨乳
|
|
3
tests/fixture/Csv/tag-multiline.utf8.csv
vendored
Normal file
3
tests/fixture/Csv/tag-multiline.utf8.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
日時,タグ1
|
||||||
|
2020/01/23 06:01,"複数行の
|
||||||
|
タグ"
|
|
3
tests/fixture/Csv/tag-over-length.utf8.csv
vendored
Normal file
3
tests/fixture/Csv/tag-over-length.utf8.csv
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
日時,タグ1
|
||||||
|
2020/01/23 06:01,ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||||
|
2020/01/23 06:02,ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooox
|
|
2
tests/fixture/Csv/tag1.utf8.csv
vendored
Normal file
2
tests/fixture/Csv/tag1.utf8.csv
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
日時,タグ1
|
||||||
|
2020/01/23 06:01,貧乳
|
|
2
tests/fixture/Csv/tag2.utf8.csv
vendored
Normal file
2
tests/fixture/Csv/tag2.utf8.csv
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
日時,タグ1,タグ2
|
||||||
|
2020/01/23 06:01,貧乳,巨乳
|
|
Loading…
Reference in New Issue
Block a user