TestGetBatchByCodes.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Tests\Services\BatchService;
  3. use App\Batch;
  4. use App\Services\BatchService;
  5. use Illuminate\Foundation\Testing\RefreshDatabase;
  6. use Tests\TestCase;
  7. class TestGetBatchByCodes extends TestCase
  8. {
  9. // use RefreshDatabase;
  10. /** @var BatchService $service */
  11. private $service;
  12. private $data = [];
  13. public function setUp(): void
  14. {
  15. parent::setUp(); // TODO: Change the autogenerated stub
  16. $this->service = app('BatchService');
  17. $batch = factory(Batch::class)->create();
  18. $this->data['batch'] = $batch;
  19. }
  20. /**
  21. * @test
  22. */
  23. public function getBatchByCodes()
  24. {
  25. $batch = $this->service->getBatchByCodes([$this->data['batch']['code']])->first();
  26. $this->assertNotNull($batch);
  27. $this->assertEquals($batch['code'],$this->data['batch']['code']);
  28. $this->assertEquals($batch['type'],$this->data['batch']['type']);
  29. $this->assertEquals($batch['wms_type'],$this->data['batch']['wms_type']);
  30. $this->assertEquals($batch['status'],$this->data['batch']['status']);
  31. $this->assertEquals($batch['wms_status'],$this->data['batch']['wms_status']);
  32. $this->assertEquals($batch['remark'],$this->data['batch']['remark']);
  33. $this->assertEquals($batch['owner_id'],$this->data['batch']['owner_id']);
  34. }
  35. public function tearDown(): void
  36. {
  37. $this->data['batch']->delete();
  38. parent::tearDown(); // TODO: Change the autogenerated stub
  39. }
  40. }