Skip to content

Commit

Permalink
Merge pull request #15 from thewulf7/hotfix/getbalance
Browse files Browse the repository at this point in the history
test hotfix
  • Loading branch information
thewulf7 committed Apr 5, 2016
2 parents b1a8027 + 24bf9d2 commit 7e41512
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
21 changes: 11 additions & 10 deletions src/thewulf7/travelPayouts/services/TicketsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,25 @@ public function getHolidaysByRoute()

$arResult['origins'] = array_map(function ($originArray) use ($dataService)
{
$place = $dataService->getPlace($originArray['iata']);
return [
'airport' => $dataService->getAirport($originArray['iata']),
'prices' => array_map(function ($item) use ($dataService)
'origin' => $place,
'prices' => array_map(function ($item) use ($dataService, $place)
{
$ticket = new Ticket();
$ticket
->setValue($item['value'])
->setValue($item['price'])
->setDestination($dataService->getPlace($item['destination']))
->setOrigin($dataService->getPlace($item['origin']))
->setOrigin($place)
->setCurrency('rub')
->setActual($item['actual'])
->setActual(isset($item['actual']) ? $item['actual'] : true)
->setDepartDate(new \DateTime($item['depart_date']))
->setReturnDate(new \DateTime($item['return_date']))
->setFoundAt(new \DateTime($item['found_at']))
->setNumberOfChanges($item['number_of_changes'])
->setDistance($item['distance'])
->setShowToAffiliates($item['show_to_affiliates'])
->setTripClass($item['trip_class']);
->setFoundAt(new \DateTime(isset($item['found_at']) ? $item['found_at'] : ''))
->setNumberOfChanges(isset($item['number_of_changes']) ? $item['number_of_changes'] : 0)
->setDistance(isset($item['distance']) ? $item['distance'] : false)
->setShowToAffiliates(isset($item['show_to_affiliates']) ? $item['show_to_affiliates'] : false)
->setTripClass(isset($item['trip_class']) ? $item['trip_class'] : false);

return $ticket;
}, $originArray['prices']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testGetBalance()
$balance = $this->service->getBalance();

self::assertGreaterThanOrEqual(0, $balance['balance']);
self::assertContains($balance['currency'], ['RUB', 'USD', 'EUR']);
self::assertContains($balance['currency'], ['rub', 'usd', 'eur']);
}

public function testGetPayments()
Expand Down
13 changes: 8 additions & 5 deletions tests/thewulf7/travelPayouts/services/TicketsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,16 @@ public function testGetHolidaysByRoute()
$firstTicket = $holidays['origins'][0]['prices'][0];

self::assertGreaterThan(0, $firstTicket->getValue());
self::assertGreaterThan(0, $firstTicket->getDistance());
if($firstTicket->getDistance() !== false)
{
self::assertGreaterThan(0, $firstTicket->getDistance());
}
}
/** @var \thewulf7\travelPayouts\entity\Airport $airport */
$airport = $holidays['origins'][1]['airport'];
/** @var \thewulf7\travelPayouts\entity\Airport|\thewulf7\travelPayouts\entity\City $place */
$place = $holidays['origins'][1]['origin'];

self::assertNotEmpty($airport->getIata());
self::assertStringMatchesFormat('%c%c%c', $airport->getIata());
self::assertNotEmpty($place->getIata());
self::assertStringMatchesFormat('%c%c%c', $place->getIata());
}

public function testGetCalendar()
Expand Down

0 comments on commit 7e41512

Please sign in to comment.