Skip to content

Commit 0399d09

Browse files
EmanFateenimdhemy
andauthored
chore(monetization): Introduce ConvertedRegionPrice (#249)
Co-authored-by: Dhemy <[email protected]>
1 parent f2e86e8 commit 0399d09

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Imdhemy\GooglePlay\Monetization\Domain;
6+
7+
use Imdhemy\GooglePlay\ValueObjects\Money;
8+
9+
/**
10+
* Represents the converted region price.
11+
*
12+
* {@link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization/convertRegionPrices#convertedregionprice}
13+
*/
14+
final readonly class ConvertedRegionPrice
15+
{
16+
public function __construct(
17+
public string $regionCode,
18+
public Money $price,
19+
public Money $taxAmount,
20+
) {
21+
}
22+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Monetization\Domain;
6+
7+
use Imdhemy\GooglePlay\Monetization\Domain\ConvertedRegionPrice;
8+
use Imdhemy\GooglePlay\ValueObjects\Money;
9+
use Tests\TestCase;
10+
11+
final class ConvertedRegionPriceTest extends TestCase
12+
{
13+
/** @test */
14+
public function instantiate(): void
15+
{
16+
$data = [
17+
'regionCode' => 'DE',
18+
'price' => [
19+
'currencyCode' => 'EUR',
20+
'units' => '4',
21+
'nanos' => 490000000,
22+
],
23+
'taxAmount' => [
24+
'currencyCode' => 'EUR',
25+
'units' => '0',
26+
'nanos' => 0,
27+
],
28+
];
29+
30+
$actual = $this->normalizer->normalize($data, ConvertedRegionPrice::class);
31+
32+
$this->assertInstanceOf(ConvertedRegionPrice::class, $actual);
33+
$this->assertEquals('DE', $actual->regionCode);
34+
$this->assertEquals(new Money('EUR', '4', 490000000), $actual->price);
35+
$this->assertEquals(new Money('EUR', '0', 0), $actual->taxAmount);
36+
}
37+
}

tests/ValueObjects/EmptyResponseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class EmptyResponseTest extends TestCase
1414
public function get_response()
1515
{
1616
$originalResponse = new Response();
17+
1718
$response = new EmptyResponse($originalResponse);
19+
1820
$this->assertSame($originalResponse, $response->getResponse());
1921
}
2022
}

tests/ValueObjects/PriceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public function from_array_to_array()
3232
];
3333

3434
$price = Price::fromArray($attributes);
35-
$this->assertInstanceOf(Price::class, $price);
3635

36+
$this->assertInstanceOf(Price::class, $price);
3737
$this->assertEquals($attributes, $price->toArray());
3838
}
3939

tests/ValueObjects/SubscriptionCancelSurveyResultTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function from_array()
1818
];
1919

2020
$surveyResult = SubscriptionCancelSurveyResult::fromArray($attr);
21+
2122
$this->assertInstanceOf(SubscriptionCancelSurveyResult::class, $surveyResult);
2223
}
2324

@@ -48,6 +49,7 @@ public function it_can_be_converted_into_an_array()
4849
];
4950

5051
$surveyResult = SubscriptionCancelSurveyResult::fromArray($attr);
52+
5153
$this->assertEquals($attr, $surveyResult->toArray());
5254
}
5355
}

0 commit comments

Comments
 (0)