| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace Tests\Services\WarehouseService;
- use App\OracleBasCustomer;
- use App\Services\OwnerService;
- use App\Services\WarehouseService;
- use App\Warehouse;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Tests\TestCase;
- class GetWareHouseByCodeTest extends TestCase
- {
- use RefreshDatabase;
- /** @var WarehouseService $service */
- private $service;
- private $data;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->service = app('WarehouseService');
- $basCustomers = OracleBasCustomer::query()->selectRaw('CustomerId,Descr_C')->where('Customer_Type','WH')->get();
- $this->data['basCustomers'] = $basCustomers;
- $this->data['codes'] = $basCustomers->map(function ($basCustomer){
- return $basCustomer->customerid;
- });
- }
- /**
- * @test
- */
- public function getWareHouseByCodeTest()
- {
- $wareHouses = $this->service->getWareHouseByCode($this->data['codes']);
- $this->assertNotEmpty($wareHouses);
- foreach ($wareHouses as $wareHouse) {
- $basCustomer = $this->data['basCustomers']->where('customerid',$wareHouse->code)->where('descr_c',$wareHouse->name);
- $this->assertNotEmpty($basCustomer);
- }
- foreach ($this->data['basCustomers'] as $basCustomer) {
- $wareHouse = $wareHouses->where('name',$basCustomer['descr_c'])->where('code',$basCustomer['customerid']);
- $this->assertNotEmpty($wareHouse);
- }
- }
- public function tearDown(): void
- {
- cache()->flush();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|