| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace Tests\Services\OwnerService;
- use App\OracleBasCustomer;
- use App\Services\OwnerService;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Tests\TestCase;
- class GetOwnerByCodesTest extends TestCase
- {
- use RefreshDatabase;
- /** @var OwnerService $service */
- private $service;
- private $data;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->service = app('OwnerService');
- $basCustomers = OracleBasCustomer::query()->selectRaw('customerid')->where('Customer_Type','OW')->get();
- $this->data = $basCustomers->map(function($basCustomer){
- return $basCustomer->customerid;
- });
- }
- /**
- * @test
- */
- public function getOwnerByCodesNormal(){
- $owners = $this->service->getOwnerByCodes($this->data);
- if(empty($owners)){
- $this->assertEmpty($owners);
- $this->assertEmpty($this->data);
- return;
- };
- $this->assertEquals($owners->count(),$this->data->count());
- foreach ($this->data as $datum) {
- $owner = $owners->where('code',$datum);
- $this->assertNotNull($owner);
- }
- }
- public function tearDown(): void
- {
- cache()->flush();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|