TestGetBatchByCodes.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. /** @var BatchService $service */
  10. private $service;
  11. private $data = [];
  12. public function setUp(): void
  13. {
  14. parent::setUp(); // TODO: Change the autogenerated stub
  15. $this->service = app('BatchService');
  16. $batch = factory(Batch::class)->create();
  17. $this->data['batch'] = $batch;
  18. }
  19. /**
  20. * @test
  21. */
  22. public function getBatchByCodes()
  23. {
  24. $batch = $this->service->getBatchByCodes([$this->data['batch']['code']])->first();
  25. $this->assertNotNull($batch);
  26. $this->assertEquals($batch['code'],$this->data['batch']['code']);
  27. $this->assertEquals($batch['type'],$this->data['batch']['type']);
  28. $this->assertEquals($batch['wms_type'],$this->data['batch']['wms_type']);
  29. $this->assertEquals($batch['status'],$this->data['batch']['status']);
  30. $this->assertEquals($batch['wms_status'],$this->data['batch']['wms_status']);
  31. $this->assertEquals($batch['remark'],$this->data['batch']['remark']);
  32. $this->assertEquals($batch['owner_id'],$this->data['batch']['owner_id']);
  33. }
  34. public function tearDown(): void
  35. {
  36. $this->data['batch']->delete();
  37. parent::tearDown(); // TODO: Change the autogenerated stub
  38. }
  39. }