Skip to content

Commit 0f88c2f

Browse files
authored
Merge pull request #8 from factorio-item-browser/feature/icon-size
feature/icon-size
2 parents ebda897 + b2a02f6 commit 0f88c2f

File tree

16 files changed

+76
-18
lines changed

16 files changed

+76
-18
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ language: php
33
matrix:
44
fast_finish: true
55
include:
6-
- php: 7.2
7-
- php: 7.3
6+
- php: '7.2'
7+
- php: '7.3'
88

99
cache:
1010
directories:
@@ -14,7 +14,8 @@ install:
1414
- composer install --prefer-dist --no-interaction --no-suggest
1515

1616
script:
17-
- vendor/bin/phpunit --coverage-clover=coverage.xml
17+
- vendor/bin/phpunit --testsuite=unit-test --coverage-clover=coverage.xml
18+
- vendor/bin/phpunit --testsuite=serializer-test
1819
- vendor/bin/coverage-check coverage.xml 100
1920
- vendor/bin/phpcs -np --colors
2021
- vendor/bin/phpstan analyse --no-interaction

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2.1.0 - 2019-07-15
4+
5+
### Added
6+
7+
- Attribute `size` to the generic icon response.
8+
39
## 2.0.0 - 2019-04-07
410

511
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ $apiClient->sendRequest($modListRequest); // Non-blocking
125125
/* @var ItemRandomResponse $randomItemsResponse */
126126
$randomItemsResponse = $apiClient->fetchResponse($randomItemRequest); // Blocking
127127
/* @var ModListResponse $modListResponse */
128-
$modListResponse = $apiClient->fetchResponse($modListRequest); // Non-blocking
128+
$modListResponse = $apiClient->fetchResponse($modListRequest); // Blocking
129129

130130
// Do something with the received data.
131131
var_dump($randomItemsResponse->getItems());

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"ext-json": "*",
24-
"bluepsyduck/common": "^1.0",
24+
"bluepsyduck/test-helper": "^1.0",
2525
"phpstan/phpstan": "^0.11",
2626
"phpstan/phpstan-phpunit": "^0.11",
2727
"phpstan/phpstan-strict-rules": "^0.11",
@@ -51,9 +51,11 @@
5151
"phpcbf": "phpcbf -p --colors",
5252
"phpcs": "phpcs -p --colors",
5353
"phpstan": "phpstan analyse --no-interaction --ansi",
54-
"phpunit": "phpunit --colors=always --coverage-html=test/log --coverage-clover=test/log/clover.xml",
54+
"test-unit": "phpunit --testsuite unit-test --colors=always --coverage-html=test/coverage --coverage-clover=test/coverage/clover.xml",
55+
"test-serialize": "phpunit --testsuite serializer-test --colors=always",
5556
"test": [
56-
"@phpunit",
57+
"@test-unit",
58+
"@test-serialize",
5759
"@coverage-check",
5860
"@phpcs",
5961
"@phpstan"

config/serializer/Entity.Icon.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ FactorioItemBrowser\Api\Client\Entity\Icon:
66
type: array<FactorioItemBrowser\Api\Client\Entity\Entity>
77
content:
88
type: base64
9+
size:
10+
type: int

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" ?>
22
<phpunit colors="true">
33
<testsuites>
4-
<testsuite name="FactorioItemBrowser\Api\Client">
4+
<testsuite name="unit-test">
55
<directory>test/src</directory>
66
</testsuite>
7-
<testsuite name="FactorioItemBrowser\Api\Client Serializer">
7+
<testsuite name="serializer-test">
88
<directory>test/serializer</directory>
99
</testsuite>
1010
</testsuites>

src/Entity/Icon.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ class Icon
2424
*/
2525
protected $content = '';
2626

27+
/**
28+
* The size of the icon.
29+
* @var int
30+
*/
31+
protected $size = 0;
32+
2733
/**
2834
* Sets the entities of the entity.
2935
* @param array|Entity[] $entities
@@ -74,4 +80,24 @@ public function getContent(): string
7480
{
7581
return $this->content;
7682
}
83+
84+
/**
85+
* Sets the size of the icon.
86+
* @param int $size
87+
* @return $this
88+
*/
89+
public function setSize(int $size): self
90+
{
91+
$this->size = $size;
92+
return $this;
93+
}
94+
95+
/**
96+
* Returns the size of the icon.
97+
* @return int
98+
*/
99+
public function getSize(): int
100+
{
101+
return $this->size;
102+
}
77103
}

test/serializer/Entity/IconTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ protected function getObject(): object
3333

3434
$result = new Icon();
3535
$result->setEntities([$entity1, $entity2])
36-
->setContent('mno');
36+
->setContent('mno')
37+
->setSize(42);
3738

3839
return $result;
3940
}
@@ -56,6 +57,7 @@ protected function getData(): array
5657
],
5758
],
5859
'content' => 'bW5v',
60+
'size' => 42,
5961
];
6062
}
6163
}

test/serializer/Response/Generic/GenericIconResponseTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ class GenericIconResponseTest extends SerializerTestCase
2424
protected function getObject(): object
2525
{
2626
$icon1 = new Icon();
27-
$icon1->setContent('abc');
27+
$icon1->setContent('abc')
28+
->setSize(42);
2829

2930
$icon2 = new Icon();
30-
$icon2->setContent('def');
31+
$icon2->setContent('def')
32+
->setSize(1337);
3133

3234
$result = new GenericIconResponse();
3335
$result->setIcons([$icon1, $icon2]);
@@ -46,10 +48,12 @@ protected function getData(): array
4648
[
4749
'entities' => [],
4850
'content' => 'YWJj',
51+
'size' => 42,
4952
],
5053
[
5154
'entities' => [],
5255
'content' => 'ZGVm',
56+
'size' => 1337,
5357
],
5458
],
5559
];

test/src/ApiClientFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace FactorioItemBrowserTest\Api\Client;
66

7-
use BluePsyduck\Common\Test\ReflectionTrait;
7+
use BluePsyduck\TestHelper\ReflectionTrait;
88
use FactorioItemBrowser\Api\Client\ApiClient;
99
use FactorioItemBrowser\Api\Client\ApiClientFactory;
1010
use FactorioItemBrowser\Api\Client\Client\Options;

0 commit comments

Comments
 (0)