| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace Tests\Services\LogisticService;
- use App\OracleBasCustomer;
- use App\Services\LogisticService;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Tests\TestCase;
- class GetLogisticByCodesTest extends TestCase
- {
- use RefreshDatabase;
- /** @var LogisticService $service */
- private $service;
- private $data;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->service = app('LogisticService');
- $baseCustomers = OracleBasCustomer::query()
- ->selectRaw('Customer_Type,CustomerID,Descr_C')
- ->where('Customer_Type','CA')
- ->get();
- $this->data['baseCustomers'] = $baseCustomers;
- $this->data['codes'] = $baseCustomers->map(function($baseCustomer){
- return $baseCustomer->customerid;
- });
- }
- /**
- * @test
- */
- public function getLogisticByCodes()
- {
- $logistics = $this->service->getLogisticByCodes($this->data['codes']);
- $this->assertNotEmpty($logistics);
- foreach ($logistics as $logistic) {
- $baseCustomer = $this->data['baseCustomers']->where('customerid',$logistic->code)->where('descr_c',$logistic->name);
- $this->assertNotEmpty($baseCustomer);
- $this->assertEquals(1,$baseCustomer->count());
- }
- foreach ($this->data['baseCustomers'] as $baseCustomer) {
- $logistic = $logistics->where('code',$baseCustomer['customerid'])->where('name',$baseCustomer['descr_c']);
- $this->assertNotEmpty($logistic);
- $this->assertEquals(1,$logistic->count());
- }
- }
- public function tearDown(): void
- {
- cache()->flush();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|