Changeset View
Changeset View
Standalone View
Standalone View
src/tests/TestCaseTrait.php
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | protected function assertEntitlements($object, $expected) | ||||
}) | }) | ||||
->toArray(); | ->toArray(); | ||||
sort($skus); | sort($skus); | ||||
Assert::assertSame($expected, $skus); | Assert::assertSame($expected, $skus); | ||||
} | } | ||||
/** | |||||
* Assert content of the SKU element in an API response | |||||
* | |||||
* @param string $sku_title The SKU title | |||||
* @param array $result The result to assert | |||||
* @param array $other Other items the SKU itself does not include | |||||
*/ | |||||
protected function assertSkuElement($sku_title, $result, $other = []): void | |||||
{ | |||||
$sku = Sku::withEnvTenantContext()->where('title', $sku_title)->first(); | |||||
$this->assertSame($sku->id, $result['id']); | |||||
$this->assertSame($sku->title, $result['title']); | |||||
$this->assertSame($sku->name, $result['name']); | |||||
$this->assertSame($sku->description, $result['description']); | |||||
$this->assertSame($sku->cost, $result['cost']); | |||||
$this->assertSame($sku->units_free, $result['units_free']); | |||||
$this->assertSame($sku->period, $result['period']); | |||||
$this->assertSame($sku->active, $result['active']); | |||||
foreach ($other as $key => $value) { | |||||
$this->assertSame($value, $result[$key]); | |||||
} | |||||
$this->assertCount(8 + count($other), $result); | |||||
} | |||||
protected function backdateEntitlements($entitlements, $targetDate, $targetCreatedDate = null) | protected function backdateEntitlements($entitlements, $targetDate, $targetCreatedDate = null) | ||||
{ | { | ||||
$wallets = []; | $wallets = []; | ||||
$ids = []; | $ids = []; | ||||
foreach ($entitlements as $entitlement) { | foreach ($entitlements as $entitlement) { | ||||
$ids[] = $entitlement->id; | $ids[] = $entitlement->id; | ||||
$wallets[] = $entitlement->wallet_id; | $wallets[] = $entitlement->wallet_id; | ||||
▲ Show 20 Lines • Show All 526 Lines • Show Last 20 Lines |