-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0163512
commit a8f3321
Showing
3 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
namespace Shimoning\DskCvs\Tests\Unit\Entities; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Shimoning\DskCvs\Constants\CompanyCode; | ||
use Shimoning\DskCvs\Constants\RecordType; | ||
use Shimoning\DskCvs\Entities\Record; | ||
use Shimoning\DskCvs\Utilities\Csv; | ||
|
||
class RecordTest extends TestCase | ||
{ | ||
/** | ||
* Entity 作成 | ||
* @return void | ||
*/ | ||
public function test_test() | ||
{ | ||
$string = \file_get_contents(\dirname(\dirname(__DIR__)) . '/data/csv/test.csv'); | ||
$result = Csv::toArray($string); | ||
$length = count($result); | ||
|
||
/** @var Record[] */ | ||
$records = []; | ||
for ($i = 1; $i < $length; $i++) { | ||
$records[] = new Record($result[$i]); | ||
} | ||
|
||
// 01,20240112,1815,EAN91929023252070000010123499900199999900106050,000001,01234999001,0,10605,010,"�Z�u���|�C���u��",110001,0,20240117 | ||
$this->assertEquals( | ||
RecordType::PRELIMINARY, | ||
$records[0]->getRecordType(), | ||
'record_type', | ||
); | ||
|
||
$this->assertEquals( | ||
'20240112', | ||
$records[0]->getReceivedDate()?->get(), | ||
'received_date', | ||
); | ||
$this->assertEquals( | ||
'1815', | ||
$records[0]->getReceivedTime()?->get(), | ||
'received_time', | ||
); | ||
$this->assertEquals( | ||
'2024-01-12 18:15:00', | ||
$records[0]->getReceivedDateTime()?->format('Y-m-d H:i:s'), | ||
'received_datetime', | ||
); | ||
|
||
$this->assertEquals( | ||
'91929023252070000010123499900199999900106050', | ||
$records[0]->getBarcode()?->getBarcode(), | ||
'barcode.barcode', | ||
); | ||
|
||
$this->assertEquals( | ||
'000001', | ||
$records[0]->getUserData1(), | ||
'user_data1', | ||
); | ||
$this->assertEquals( | ||
'01234999001', | ||
$records[0]->getUserData2(), | ||
'user_data1', | ||
); | ||
|
||
$this->assertFalse( | ||
$records[0]->hasRevenueStamp(), | ||
'revenue_stamp', | ||
); | ||
$this->assertSame( | ||
10605, | ||
$records[0]->getAmount(), | ||
'user_data1', | ||
); | ||
|
||
$this->assertEquals( | ||
CompanyCode::SEVEN_ELEVEN, | ||
$records[0]->getCompanyCode(), | ||
'company_code', | ||
); | ||
$this->assertEquals( | ||
'セブン−イレブン', | ||
$records[0]->getCompanyName(), | ||
'company_name', | ||
); | ||
|
||
$this->assertEquals( | ||
'110001', | ||
$records[0]->getShopCode(), | ||
'shop_code', | ||
); | ||
|
||
$this->assertNull( | ||
$records[0]->getPaysDate()?->get(), | ||
'pays_date', | ||
); | ||
$this->assertEquals( | ||
'20240117', | ||
$records[0]->getCreatedDate()?->get(), | ||
'created_date', | ||
); | ||
|
||
// 支払い予定日が null じゃないケース | ||
$this->assertEquals( | ||
'20240124', | ||
$records[11]->getPaysDate()?->get(), | ||
'pays_date', | ||
); | ||
} | ||
|
||
/** | ||
* 本番に近いデータ | ||
* | ||
* @return void | ||
*/ | ||
public function test_virtual() | ||
{ | ||
$string = \file_get_contents(\dirname(\dirname(__DIR__)) . '/data/csv/syuno.csv'); | ||
$result = Csv::toArray($string); | ||
$length = count($result); | ||
|
||
/** @var Record[] */ | ||
$records = []; | ||
for ($i = 1; $i < $length; $i++) { | ||
$records[] = new Record($result[$i]); | ||
} | ||
|
||
$this->assertEquals( | ||
RecordType::PRELIMINARY, | ||
$records[0]->getRecordType(), | ||
'record_type', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
���,���[��,���[����,�o�[�R�[�h���,���[�U�[�g�p���P,���[�U�[�g�p���Q,�t���O,���z,�R���r�j�{���R�[�h,�R���r�j��,�R���r�j�X�܃R�[�h,�U����,�f�[�^�쐬�� | ||
01,20231215,0826,EAN91929023252070678901234565918099999900069468,067890,12345659180,0,6946,010,"�Z�u���|�C���u��",458762,0,20231216 | ||
01,20231215,0908,EAN91929023252070678901234569171099999900145549,067890,12345691710,0,14554,010,"�Z�u���|�C���u��",349731,0,20231216 | ||
01,20231215,2035,EAN91929023252070678901234569188099999910793622,067890,12345691880,1,79362,010,"�Z�u���|�C���u��",001815,0,20231216 | ||
01,20231215,0908,EAN91929023252070678901234569644099999900060506,067890,12345696440,0,6050,020,"���[�\��",266376,0,20231216 | ||
01,20231215,0958,EAN91929023252070678901234569201099999900509222,067890,12345692010,0,50922,020,"���[�\��",228950,0,20231216 | ||
01,20231215,1104,EAN91929023252070678901234568439099999910743584,067890,12345684390,1,74358,020,"���[�\��",056064,0,20231216 | ||
01,20231215,0829,EAN91929023252070678901234568658099999900091065,067890,12345686580,0,9106,030,"�t�@�~���[�}�[�g",123063,0,20231216 | ||
01,20231215,1118,EAN91929023252070678901234569183099999900165588,067890,12345691830,0,16558,030,"�t�@�~���[�}�[�g",121724,0,20231216 | ||
01,20231215,1130,EAN91929023252070678901234569360099999910691201,067890,12345693600,1,69120,030,"�t�@�~���[�}�[�g",124394,0,20231216 | ||
01,20231215,1610,EAN91929023252070678901234569854099999910648001,067890,12345698540,1,64800,820,"�o�����o����",000000,0,20231216 | ||
01,20231215,1917,EAN91929023252070678901234568273099999900056502,067890,12345682730,0,5650,830,"�y�V��s�R���r�j�x��",000000,0,20231216 | ||
01,20231215,1641,EAN91929023252070678901234569329099999900045707,067890,12345693290,0,4570,890,"������T�[�r�X",786194,0,20231218 | ||
01,20231216,1103,EAN91929023252070678901234570073099999900120228,067890,12345700730,0,12022,890,"������T�[�r�X",821731,0,20231218 | ||
01,20231217,1914,EAN91929023252070678901234569710099999900097870,067890,12345697100,0,9787,820,"�o�����o����",000000,0,20231218 | ||
12,20231215,0000,EAN91929023252070678901234569233099999900512445,067890,12345692330,0,51244,910,"�X�U��",551704,20231225,20231218 | ||
12,20231215,0000,EAN91929023252070678901234569282099999900107267,067890,12345692820,0,10726,910,"�X�U��",158205,20231225,20231218 | ||
12,20231215,0000,EAN91929023252070678901234567901099999900238284,067890,12345679010,0,23828,911,"�X�U�ցi�����j",011106,20231225,20231218 | ||
12,20231215,0000,EAN91929023252070678901234568514099999910636507,067890,12345685140,1,63650,911,"�X�U�ցi�����j",500700,20231225,20231218 | ||
12,20231215,0000,EAN91929023252070678901234568527099999900069469,067890,12345685270,0,6946,911,"�X�U�ցi�����j",011106,20231225,20231218 | ||
12,20231216,0000,EAN91929023252070678901234569869099999900095925,067890,12345698690,0,9592,910,"�X�U��",024607,20231225,20231218 | ||
01,20231218,1323,EAN91929023252070678901234570001099999900289782,067890,12345700010,0,28978,780,"�����@�o�`�x",000000,0,20231219 | ||
01,20231219,0816,EAN91929023252070678901234569998099999911782002,067890,12345699980,1,178200,760,"�Z�R�}",010485,0,20231220 | ||
02,20231215,0829,EAN91929023252070678901234568658099999900091065,067890,12345686580,0,9106,030,"�t�@�~���[�}�[�g",123063,20231225,20231220 | ||
02,20231215,1118,EAN91929023252070678901234569183099999900165588,067890,12345691830,0,16558,030,"�t�@�~���[�}�[�g",121724,20231225,20231220 | ||
02,20231215,1130,EAN91929023252070678901234569360099999910691201,067890,12345693600,1,69120,030,"�t�@�~���[�}�[�g",124394,20231225,20231220 | ||
02,20231215,1610,EAN91929023252070678901234569854099999910648001,067890,12345698540,1,64800,820,"�o�����o����",000000,20240109,20231221 | ||
02,20231215,1917,EAN91929023252070678901234568273099999900056502,067890,12345682730,0,5650,830,"�y�V��s�R���r�j�x��",000000,20240109,20231221 | ||
02,20231215,1641,EAN91929023252070678901234569329099999900045707,067890,12345693290,0,4570,890,"������T�[�r�X",786194,20240109,20231221 | ||
01,20231221,1357,EAN91929023252070678901234567739099999900152626,067890,12345677390,0,15262,820,"�o�����o����",000000,0,20231222 | ||
02,20231215,0826,EAN91929023252070678901234565918099999900069468,067890,12345659180,0,6946,010,"�Z�u���|�C���u��",458762,20240109,20231222 | ||
02,20231215,0908,EAN91929023252070678901234569171099999900145549,067890,12345691710,0,14554,010,"�Z�u���|�C���u��",349731,20240109,20231222 | ||
02,20231215,2035,EAN91929023252070678901234569188099999910793622,067890,12345691880,1,79362,010,"�Z�u���|�C���u��",001815,20240109,20231222 | ||
01,20231222,1319,EAN91929023252070678901234570875099999900145061,067890,12345708750,0,14506,050,"�f�C���[���}�U�L",287779,0,20231223 | ||
01,20231222,1418,EAN91929023252070678901234570043099999900087821,067890,12345700430,0,8782,050,"�f�C���[���}�U�L",282327,0,20231223 | ||
01,20231223,1115,EAN91929023252070678901234570501099999900075199,067890,12345705010,0,7519,080,"�~�j�X�g�b�v",052702,0,20231224 | ||
01,20231223,1140,EAN91929023252070678901234570284099999900107601,067890,12345702840,0,10760,080,"�~�j�X�g�b�v",003766,0,20231224 | ||
01,20231223,1220,EAN91929023252070678901234570654099999900141156,067890,12345706540,0,14115,760,"�Z�R�}",010447,0,20231225 | ||
01,20231224,1130,EAN91929023252070678901234571121099999900146140,067890,12345711210,0,14614,810,"�k�h�m�d�@�o�����i�����[",000000,0,20231225 | ||
01,20231224,1511,EAN91929023252070678901234561506099999900006800,067890,12345615060,0,680,820,"�o�����o����",000000,0,20231225 | ||
02,20231215,0908,EAN91929023252070678901234569644099999900060506,067890,12345696440,0,6050,020,"���[�\��",266376,20240109,20231225 | ||
02,20231215,0958,EAN91929023252070678901234569201099999900509222,067890,12345692010,0,50922,020,"���[�\��",228950,20240109,20231225 | ||
02,20231215,1104,EAN91929023252070678901234568439099999910743584,067890,12345684390,1,74358,020,"���[�\��",056064,20240109,20231225 | ||
01,20231225,0942,EAN91929023252070678901234566713099999910712804,067890,12345667130,1,71280,530,"�o�����a",000134,0,20231226 | ||
01,20231225,1143,EAN91929023252070678901234571148099999900124404,067890,12345711480,0,12440,760,"�Z�R�}",011155,0,20231226 | ||
02,20231216,1103,EAN91929023252070678901234570073099999900120228,067890,12345700730,0,12022,890,"������T�[�r�X",821731,20240109,20231226 | ||
02,20231217,1914,EAN91929023252070678901234569710099999900097870,067890,12345697100,0,9787,820,"�o�����o����",000000,20240109,20231226 | ||
02,20231218,1323,EAN91929023252070678901234570001099999900289782,067890,12345700010,0,28978,780,"�����@�o�`�x",000000,20240109,20231226 | ||
02,20231219,0816,EAN91929023252070678901234569998099999911782002,067890,12345699980,1,178200,760,"�Z�R�}",010485,20240109,20231226 | ||
01,20231226,1130,EAN91929023252070678901234566770099999910854507,067890,12345667700,1,85450,080,"�~�j�X�g�b�v",003100,0,20231227 | ||
02,20231221,1357,EAN91929023252070678901234567739099999900152626,067890,12345677390,0,15262,820,"�o�����o����",000000,20240109,20231229 | ||
02,20231222,1319,EAN91929023252070678901234570875099999900145061,067890,12345708750,0,14506,050,"�f�C���[���}�U�L",287779,20240109,20231229 | ||
02,20231222,1418,EAN91929023252070678901234570043099999900087821,067890,12345700430,0,8782,050,"�f�C���[���}�U�L",282327,20240109,20231229 | ||
02,20231223,1115,EAN91929023252070678901234570501099999900075199,067890,12345705010,0,7519,080,"�~�j�X�g�b�v",052702,20240109,20231229 | ||
02,20231223,1140,EAN91929023252070678901234570284099999900107601,067890,12345702840,0,10760,080,"�~�j�X�g�b�v",003766,20240109,20231229 | ||
02,20231223,1220,EAN91929023252070678901234570654099999900141156,067890,12345706540,0,14115,760,"�Z�R�}",010447,20240109,20231229 | ||
02,20231224,1130,EAN91929023252070678901234571121099999900146140,067890,12345711210,0,14614,810,"�k�h�m�d�@�o�����i�����[",000000,20240109,20231229 | ||
02,20231224,1511,EAN91929023252070678901234561506099999900006800,067890,12345615060,0,680,820,"�o�����o����",000000,20240109,20231229 | ||
02,20231225,0942,EAN91929023252070678901234566713099999910712804,067890,12345667130,1,71280,530,"�o�����a",000134,20240109,20231229 | ||
02,20231225,1143,EAN91929023252070678901234571148099999900124404,067890,12345711480,0,12440,760,"�Z�R�}",011155,20240109,20231229 |