Skip to content

Commit

Permalink
Merge pull request #58 from asgoodasnu/develop
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
StephanAltmann authored Jun 27, 2023
2 parents fb91016 + 15e4894 commit d2961af
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 72 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
day: saturday
time: "01:00"
timezone: Europe/Berlin
open-pull-requests-limit: 5
4 changes: 2 additions & 2 deletions .github/workflows/PHPStan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.2'
tools: pecl
extensions: gd
coverage: xdebug
Expand All @@ -32,4 +32,4 @@ jobs:

- name: PHPStan
run: |
vendor/bin/phpstan analyse src/ tests/ --level 7
vendor/bin/phpstan analyse
6 changes: 3 additions & 3 deletions .github/workflows/PHPUnit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
- uses: actions/checkout@v1
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.2'
tools: pecl
extensions: amqp
coverage: xdebug
- uses: php-actions/composer@v5
with:
php_version: '7.4'
php_version: '8.2'
- name: PHPUnit
run: |
php vendor/bin/simple-phpunit -v --coverage-clover clover-coverage.xml --coverage-html coverage_html --log-junit coverage_html/junit.xml
php vendor/bin/phpunit -v --coverage-clover clover-coverage.xml --coverage-html coverage_html --log-junit coverage_html/junit.xml
4 changes: 2 additions & 2 deletions .github/workflows/php-cs-fixer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
steps:
- uses: actions/checkout@master
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.16.7
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist --diff --dry-run
args: --config=.php-cs-fixer.dist.php --diff --dry-run
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
composer.lock
.phpunit.result.cache
/var/
.php_cs.cache
.php-cs-fixer.cache
clover-coverage.xml
coverage_html
akeneo_test.php
13 changes: 7 additions & 6 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
$finder = PhpCsFixer\Finder::create()
->in('src')
->in('tests')
->notPath('src/Migrations/migration.tpl')
;
return PhpCsFixer\Config::create()

$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@Symfony' => true,
'full_opening_tag' => false,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => true,
'no_unused_imports' => true,
'psr4' => true,
'psr0' => true,
'array_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => true,
'linebreak_after_opening_tag' => true,
'logical_operators' => true,
Expand All @@ -22,4 +23,4 @@
]
])
->setFinder($finder)
;
;
2 changes: 1 addition & 1 deletion .php-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0
8.2
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.0.10","version":"2.19.2:v2.19.2#d5c737c2e18ba502b75b44832b31fe627f82e307","indent":" ","lineEnding":"\n","rules":{"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"braces":{"allow_single_line_anonymous_class_with_empty_body":true,"allow_single_line_closure":true},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"single_line":true},"clean_namespace":true,"concat_space":true,"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":true,"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"psr4":true,"psr0":true,"logical_operators":true,"native_function_invocation":{"include":["@compiler_optimized"],"scope":"namespaced"}},"hashes":{"src\/SymfonyHttpClientAkeneoApi.php":2581952814,"src\/AkeneoApi.php":1258073027,"src\/AkeneoApiException.php":2016424705,"src\/AkeneoApiAuthenticator.php":887019445,"src\/AsgoodasnewAkeneoApiBundle.php":4163687312,"src\/AkeneoApiAuthorizationFailedException.php":1343015636,"src\/CategoryTreeBuilder.php":825527685,"src\/Model\/CategoryItem.php":1332300364,"src\/CachedSymfonyHttpClientAkeneoApi.php":4011265375,"src\/AkeneoApiProductNotFoundException.php":3791779645,"src\/DependencyInjection\/AsgoodasnewAkeneoApiExtension.php":3036891623,"src\/DependencyInjection\/Configuration.php":1543385153,"tests\/CachedSymfonyHttpClientAkeneoApiTest.php":3844322349,"tests\/FunctionalTest.php":3011293549,"tests\/AkeneoApiExceptionTest.php":3262758670,"tests\/AkeneoApiAuthenticatorTest.php":1947111084,"tests\/CategoryTreeBuilderTest.php":3622523499,"tests\/Model\/CategoryItemTest.php":1832717425,"tests\/SymfonyHttpClientAkeneoApiTest.php":2917959106}}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ vendor: composer.json

cs:
# Running PHP-CS-Fixer
@symfony php vendor/bin/php-cs-fixer fix
PHP_CS_FIXER_IGNORE_ENV=1 symfony php vendor/bin/php-cs-fixer fix

analyse:
# Running PHPStan static code analyse
@symfony php vendor/bin/phpstan analyse src/ tests/ --level 7
@symfony php vendor/bin/phpstan analyse

test-coverage:
@symfony php vendor/bin/simple-phpunit -v --coverage-clover clover-coverage.xml --coverage-html coverage_html --log-junit coverage_html/junit.xml
@symfony php vendor/bin/phpunit -v --coverage-clover clover-coverage.xml --coverage-html coverage_html --log-junit coverage_html/junit.xml

all: cs analyse test-coverage
all: cs test-coverage analyse
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"ext-json": "*",
"symfony/config": "^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/cache": "^5.0",
"symfony/http-client": "^5.0"
"symfony/config": "6.2.*",
"symfony/dependency-injection": "6.2.*",
"symfony/http-kernel": "6.2.*",
"symfony/cache": "6.2.*",
"symfony/http-client": "6.2.*"
},
"autoload": {
"psr-4": {
Expand All @@ -28,8 +28,9 @@
}
},
"require-dev": {
"symfony/phpunit-bridge": "^5.1",
"phpstan/phpstan": "^0.12.42",
"friendsofphp/php-cs-fixer": "^2.16"
"phpunit/phpunit": "^9.5",
"symfony/phpunit-bridge": "6.2.*",
"phpstan/phpstan": "~1.10.21",
"friendsofphp/php-cs-fixer": "3.*"
}
}
1 change: 1 addition & 0 deletions php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xdebug.mode=coverage
10 changes: 6 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
parameters:
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
excludes_analyse:
- vendor/autoload.php
level: 7
paths:
- src
- tests
excludePaths:
- src/DependencyInjection/Configuration.php
ignoreErrors:
- '#PHPDoc tag @throws with type [a-zA-Z0-9\\_\\]| is not subtype of Throwable#'
39 changes: 17 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<ini name="intl.default_locale" value="en" />
<ini name="intl.error_level" value="0" />
<ini name="memory_limit" value="-1" />
</php>
<testsuites>
<testsuite name="Test suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="intl.default_locale" value="en"/>
<ini name="intl.error_level" value="0"/>
<ini name="memory_limit" value="-1"/>
</php>
<testsuites>
<testsuite name="Test suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/AkeneoApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public function getCategories(string $rootCode): CategoryItem;
/**
* @throws AkeneoApiException
*/
public function triggerUpdate(string $identifier, ?string $message = null): void;
public function triggerUpdate(string $identifier, string $message = null): void;
}
11 changes: 5 additions & 6 deletions src/AkeneoApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Throwable;

class AkeneoApiException extends \Exception
{
protected function __construct(string $message = '', Throwable $previous = null)
protected function __construct(string $message = '', \Throwable $previous = null)
{
parent::__construct($message, 0, $previous);
}

public static function fromException(Throwable $throwable): self
public static function fromException(\Throwable $throwable): self
{
if ($throwable instanceof ClientExceptionInterface) {
return self::create('ClientException', $throwable);
Expand All @@ -42,17 +41,17 @@ public static function fromException(Throwable $throwable): self
return self::create('Global error', $throwable);
}

private static function create(string $message, Throwable $throwable): self
private static function create(string $message, \Throwable $throwable): self
{
return new self($message, $throwable);
}

public static function createFailed(Throwable $throwable): self
public static function createFailed(\Throwable $throwable): self
{
return new AkeneoApiAuthorizationFailedException('Authorization failed!', $throwable);
}

public static function createProductNotFound(Throwable $throwable): self
public static function createProductNotFound(\Throwable $throwable): self
{
return new AkeneoApiProductNotFoundException('Product not found!', $throwable);
}
Expand Down
6 changes: 3 additions & 3 deletions src/CachedSymfonyHttpClientAkeneoApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

class CachedSymfonyHttpClientAkeneoApi implements AkeneoApi
{
const A_HOUR = 3600;
const CACHE_KEY_CATEGORIES = 'akeneo-api-bundle-categories';
public const A_HOUR = 3600;
public const CACHE_KEY_CATEGORIES = 'akeneo-api-bundle-categories';

private AkeneoApi $decorated;
private CacheItemPoolInterface $cache;
Expand Down Expand Up @@ -64,7 +64,7 @@ public function getCategories(string $rootCode): CategoryItem
return $item;
}

public function triggerUpdate(string $identifier, ?string $message = null): void
public function triggerUpdate(string $identifier, string $message = null): void
{
$this->decorated->triggerUpdate($identifier);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SymfonyHttpClientAkeneoApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getCategories(string $rootCode): CategoryItem
/**
* @throws AkeneoApiException
*/
public function triggerUpdate(string $identifier, ?string $message = null): void
public function triggerUpdate(string $identifier, string $message = null): void
{
$this->assertProductExists($identifier);

Expand Down
14 changes: 7 additions & 7 deletions tests/SymfonyHttpClientAkeneoApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Asgoodasnew\AkeneoApiBundle\CategoryTreeBuilder;
use Asgoodasnew\AkeneoApiBundle\Model\CategoryItem;
use Asgoodasnew\AkeneoApiBundle\SymfonyHttpClientAkeneoApi;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\Exception\ClientException;
Expand Down Expand Up @@ -82,13 +81,14 @@ public function testGetProduct(): void
}

/**
* @param class-string<Exception> $thrownException
* @param class-string<\Exception> $thrownException
*
* @dataProvider dataProviderExceptions
*
* @throws AkeneoApiProductNotFoundException
* @throws AkeneoApiException
*/
public function testGetProductExceptions(Exception $exception, $thrownException): void
public function testGetProductExceptions(\Exception $exception, $thrownException): void
{
$sku = 'AN12345';

Expand Down Expand Up @@ -122,7 +122,7 @@ public function dataProviderExceptions(): array
{
return [
[new ClientException(new MockResponse()), AkeneoApiProductNotFoundException::class],
[new Exception(), AkeneoApiException::class],
[new \Exception(), AkeneoApiException::class],
];
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public function testGetCategoriesException(): void
'Authorization' => 'Bearer token',
],
])
->willThrowException(new Exception());
->willThrowException(new \Exception());

self::expectException(AkeneoApiException::class);

Expand Down Expand Up @@ -285,7 +285,7 @@ public function testTriggerUpdateExceptionAssertProductExist(): void
],
]
)
->willThrowException(new Exception());
->willThrowException(new \Exception());

self::expectException(AkeneoApiException::class);

Expand Down Expand Up @@ -321,7 +321,7 @@ public function testTriggerUpdateExceptionOnPatch(): void
return $response;
}

throw new Exception();
throw new \Exception();
});

self::expectException(AkeneoApiException::class);
Expand Down

0 comments on commit d2961af

Please sign in to comment.