fix: refresh live room availability during create flow
This commit is contained in:
1 parent
a73e8a593f
commit
cdce7d57e0
26 files changed
+1976
-54
No files matched your search
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\BusProNet\XmlLoader;
|
||||
|
||||
use App\BusProNet\Model\BaseData;
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\XmlLoader\HotelLoader;
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\BusProNet\XmlParser\TravelParser;
|
||||
use League\Flysystem\FilesystemOperator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
|
||||
class TravelLoaderTest extends TestCase
|
||||
{
|
||||
public function testPatchRoomAvailabilitiesAppliesLiveRoomDataToMatchingRooms(): void
|
||||
{
|
||||
$loader = $this->createLoader();
|
||||
|
||||
$travel = new Travel();
|
||||
|
||||
$patchedRoom = new Room();
|
||||
$patchedRoom->id = 1;
|
||||
$patchedRoom->available = 2;
|
||||
$patchedRoom->status = 'Frei';
|
||||
$patchedRoom->price = 100.0;
|
||||
|
||||
$otherRoom = new Room();
|
||||
$otherRoom->id = 2;
|
||||
$otherRoom->available = 1;
|
||||
$otherRoom->status = 'Frei';
|
||||
$otherRoom->price = 150.0;
|
||||
|
||||
$travel->rooms = [$patchedRoom, $otherRoom];
|
||||
|
||||
$liveRoom = new Room();
|
||||
$liveRoom->id = 1;
|
||||
$liveRoom->available = 0;
|
||||
$liveRoom->status = 'Anfrage';
|
||||
$liveRoom->price = 110.0;
|
||||
$liveRoom->label = 'Live room';
|
||||
$liveRoom->category = 'Live category';
|
||||
|
||||
$loader->patchRoomAvailabilities($travel, new BaseData([
|
||||
1 => $liveRoom,
|
||||
]));
|
||||
|
||||
$this->assertSame(0, $travel->rooms[0]->available);
|
||||
$this->assertSame('Anfrage', $travel->rooms[0]->status);
|
||||
$this->assertSame(110.0, $travel->rooms[0]->price);
|
||||
$this->assertSame('Live room', $travel->rooms[0]->label);
|
||||
$this->assertSame('Live category', $travel->rooms[0]->category);
|
||||
|
||||
$this->assertSame(1, $travel->rooms[1]->available);
|
||||
$this->assertSame('Frei', $travel->rooms[1]->status);
|
||||
$this->assertSame(150.0, $travel->rooms[1]->price);
|
||||
}
|
||||
|
||||
private function createLoader(): TravelLoader
|
||||
{
|
||||
return new TravelLoader(
|
||||
$this->createMock(HotelLoader::class),
|
||||
$this->createMock(TravelParser::class),
|
||||
'https://example.com',
|
||||
new ArrayAdapter(),
|
||||
$this->createMock(FilesystemOperator::class),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user