Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGuilloux committed Aug 4, 2021
1 parent 4ef520b commit c686254
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 28 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests
name: Static Analysis
on: [pull_request]

jobs:
build-and-test:
phpinsights:
runs-on: ubuntu-18.04
steps:
- name: Checkout 🛎️
Expand All @@ -27,7 +27,30 @@ jobs:
- name: PHPInsights 🔧
run: |
docker-compose exec -T application ./vendor/nunomaduro/phpinsights/bin/phpinsights
docker-compose exec -T application ./vendor/nunomaduro/phpinsights/bin/phpinsights --no-interaction --min-quality=100 --min-architecture=100
phpstan:
runs-on: ubuntu-18.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Start docker 🔧
run: |
docker-compose -f docker-compose.yml -f .github/docker-compose.yml up -d
- name: Cache multiple paths
uses: actions/cache@v2
with:
path: |
**/vendor
key: ${{ runner.os }}-${{ hashFiles('*.lock') }}

- name: Install the dependencies 🔧
run: |
docker-compose exec -T application composer install --prefer-dist --no-interaction --no-progress
- name: PHPStan 🔧
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests
on: [push]

jobs:
build-and-test:
phpunit:
runs-on: ubuntu-18.04
steps:
- name: Checkout 🛎️
Expand Down
7 changes: 6 additions & 1 deletion src/Factory/CookieDecisionMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ public function __invoke(): ?CookieDecisionMetadata
}

$uuid = $metadata['uuid'] ?? null;
$date = new \DateTime($metadata['date'] ?? '');

try {
$date = new \DateTime($metadata['date'] ?? '');
} catch (\Throwable $e) {
return null;
}

if (!\is_string($uuid) || empty($uuid) || !$date instanceof \DateTime) {
return null;
Expand Down
10 changes: 5 additions & 5 deletions tests/Controller/DecisionLogRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testDecisionLog(): void
],
'metadata' => [
'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd',
'date' => '03/11/2020, 17:55:47',
'date' => '2020-11-03 17:55:47',
],
]);

Expand Down Expand Up @@ -58,7 +58,7 @@ public function testDecisionLogPreferencesNotArray(): void
'preferences' => 'BadData',
'metadata' => [
'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd',
'date' => '03/11/2020, 17:55:47',
'date' => '2020-11-03 17:55:47',
],
]);

Expand All @@ -73,7 +73,7 @@ public function testDecisionLogPreferencesWithBadDataInside(): void
],
'metadata' => [
'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd',
'date' => '03/11/2020, 17:55:47',
'date' => '2020-11-03 17:55:47',
],
]);

Expand Down Expand Up @@ -102,7 +102,7 @@ public function testDecisionLogMetadataBadUuid(): void
],
'metadata' => [
'uuid' => false,
'date' => '03/11/2020, 17:55:47',
'date' => '2020-11-03 17:55:47',
],
]);

Expand All @@ -118,7 +118,7 @@ public function testDecisionLogMetadataBadDate(): void
],
'metadata' => [
'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd',
'date' => false,
'date' => '1685463516584684',
],
]);

Expand Down
23 changes: 14 additions & 9 deletions tests/DependencyConfiguration/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,28 @@ public function testInstantiationContainer(): void
'website' => 'Test Website',
'locale' => 'fr',
'privacy_policy' => [
'url' => 'http://privacy_policy',
'url' => [
'absolute' => 'http://privacy_policy',
],
'label' => 'Privacy Policy',
'open_in_new_window' => true,
],
'modal' => [
'header' => 'Modal header',
'related_companies_count' => 2,
'related_companies_privacy_policy_url' => 'http://related_companies_privacy_policy',
'related_companies_privacy_policy_url' => [
'absolute' => 'http://related_companies_privacy_policy',
],
],
'services' => [
'google_tag_manager' => [
'enable' => true,
'name' => 'Google Tag Manager',
'description' => 'Tag management system',
'mandatory' => true,
'conservation' => '6 months',
'initialization_callback' => null,
'predefined' => [
'enable' => true,
'name' => 'Google Tag Manager',
'description' => 'Tag management system',
'mandatory' => true,
'conservation' => '6 months',
'cookies_identifiers' => [],
'predefined' => [
'name' => 'googleTagManager',
'options' => ['id' => 'GTM-TEST'],
],
Expand All @@ -64,6 +68,7 @@ public function testInstantiationContainer(): void
'description' => 'Description of the another service',
'mandatory' => false,
'conservation' => '1 year',
'cookies_identifiers' => [],
'initialization_callback' => 'init_callback()',
],
],
Expand Down
23 changes: 14 additions & 9 deletions tests/TwigExtension/CookiesRegulationTwigExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,28 @@ public function testGetConfig(): void
'website' => 'Test Website',
'locale' => 'fr',
'privacy_policy' => [
'url' => 'http://privacy_policy',
'url' => [
'absolute' => 'http://privacy_policy',
],
'label' => 'Privacy Policy',
'open_in_new_window' => true,
],
'modal' => [
'header' => 'Modal header',
'related_companies_count' => 2,
'related_companies_privacy_policy_url' => 'http://related_companies_privacy_policy',
'related_companies_privacy_policy_url' => [
'absolute' => 'http://related_companies_privacy_policy',
],
],
'services' => [
'google_tag_manager' => [
'enable' => true,
'name' => 'Google Tag Manager',
'description' => 'Tag management system',
'mandatory' => true,
'conservation' => '6 months',
'initialization_callback' => null,
'predefined' => [
'enable' => true,
'name' => 'Google Tag Manager',
'description' => 'Tag management system',
'mandatory' => true,
'conservation' => '6 months',
'cookies_identifiers' => [],
'predefined' => [
'name' => 'googleTagManager',
'options' => ['id' => 'GTM-TEST'],
],
Expand All @@ -63,6 +67,7 @@ public function testGetConfig(): void
'description' => 'Description of the another service',
'mandatory' => false,
'conservation' => '1 year',
'cookies_identifiers' => [],
'initialization_callback' => 'init_callback()',
],
],
Expand Down

0 comments on commit c686254

Please sign in to comment.