| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Tests\Services\LogisticService;
- use App\Logistic;
- use App\OracleBasCustomer;
- use App\Services\LogisticService;
- use App\Services\OracleBasCustomerService;
- 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');
- $logistic = factory(Logistic::class)->create();
- $OracleBasCustomer = factory(OracleBasCustomer::class)->make(['customer_type' => 'CA','customerid'=>$logistic->code]);
- $this->mock(OracleBasCustomerService::class,function ($mock)use($OracleBasCustomer){
- $mock->shouldReceive('first')->andReturn($OracleBasCustomer);
- });
- $this->data['baseCustomers'] = $OracleBasCustomer;
- $this->data['logistic'] = $logistic;
- }
- /**
- * @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
- {
- foreach ($this->data['baseCustomers'] as $baseCustomer) {
- cache()->forget('getLogisticByCode_'.$baseCustomer['customerid']);
- }
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|