Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

III-6154 jenkins changes into dev branch #1797

Draft
wants to merge 12 commits into
base: feature/III-6154
Choose a base branch
from
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'src/',
'tests/',
'web/',
'features/Bootstrap/',
'features/bootstrap/',
'features/State/',
'features/Steps/',
'features/Support/',
Expand Down
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,46 @@ config:
sh ./docker/config.sh

install:
docker-compose exec -T php composer install
docker-compose exec php composer install

migrate:
docker-compose exec -T php ./vendor/bin/doctrine-dbal migrations:migrate --no-interaction
docker-compose exec php ./vendor/bin/doctrine-dbal migrations:migrate --no-interaction

init: install migrate

ci:
docker exec -it php.uitdatabank composer ci
docker-compose exec php composer ci

stan:
docker exec -it php.uitdatabank composer phpstan
docker-compose exec php composer phpstan

cs:
docker exec -it php.uitdatabank composer cs
docker-compose exec php composer cs

cs-fix:
docker exec -it php.uitdatabank composer cs-fix
docker-compose exec php composer cs-fix

test:
docker exec -it php.uitdatabank composer test
docker-compose exec php composer test

test-filter:
docker exec -it php.uitdatabank composer test -- --filter=$(filter)
docker-compose exec php composer test -- --filter=$(filter)

test-group:
docker exec -it php.uitdatabank composer test -- --group=$(group)
docker-compose exec php composer test -- --group=$(group)

feature-init:
docker-compose exec -T php composer feature -- --tags @init
docker-compose exec php composer feature -- --tags @init

feature-tag:
docker exec -it php.uitdatabank composer feature -- --tags $(tag)
docker-compose exec php composer feature -- --tags $(tag)

feature:
docker-compose exec -T php composer feature -- --tags "~@init&&~@external"
docker-compose exec php composer feature -- --tags "~@init&&~@external"

feature-filter:
docker exec -it php.uitdatabank composer feature -- $(path)
docker-compose exec php composer feature -- $(path)

feature-random:
docker-compose exec php composer feature -- --order=random --tags "~@init&&~@external"

40 changes: 0 additions & 40 deletions features/Steps/UtilitySteps.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,44 +47,4 @@ public function iWaitSeconds(int $seconds): void
{
sleep($seconds);
}

/**
* @Given /^I prevent duplicate place creation$/
*/
public function iPreventDuplicatePlaceCreation(): void
{
$configFile = file_get_contents('config.php');

if (str_contains($configFile, "'prevent_duplicate_places_creation' => true")) {
// The config was already on true, so no further changes are required
$this->initialPreventDuplicatePlaceCreationValue = true;
return;
}

$configFile = str_replace(
"'prevent_duplicate_places_creation' => false",
"'prevent_duplicate_places_creation' => true",
$configFile
);

file_put_contents('config.php', $configFile);

$this->initialPreventDuplicatePlaceCreationValue = false;
}

/**
* @Then /^I restore the duplicate configuration/
*/
public function iRestoreTheDuplicateConfigurationOption(): void
{
$configFile = file_get_contents('config.php');

$configFile = str_replace(
"'prevent_duplicate_places_creation' => true",
"'prevent_duplicate_places_creation' => " . ($this->initialPreventDuplicatePlaceCreationValue ? 'true' : 'false'),
$configFile
);

file_put_contents('config.php', $configFile);
}
}
45 changes: 45 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
declare(strict_types=1);

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\AfterFeatureScope;
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
use Behat\Testwork\Hook\Scope\BeforeSuiteScope;
use CultuurNet\UDB3\State\RequestState;
use CultuurNet\UDB3\State\ResponseState;
Expand Down Expand Up @@ -66,11 +68,54 @@ private function getHttpClient(): HttpClient
);
}

private static function disablePreventDuplicatePlaceCreation(): void
{
$configFile = file_get_contents('config.php');

$configFile = str_replace(
"'prevent_duplicate_places_creation' => true",
"'prevent_duplicate_places_creation' => false",
$configFile
);

file_put_contents('config.php', $configFile);
}

private static function enablePreventDuplicatePlaceCreation(): void
{
$configFile = file_get_contents('config.php');

$configFile = str_replace(
"'prevent_duplicate_places_creation' => false",
"'prevent_duplicate_places_creation' => true",
$configFile
);

file_put_contents('config.php', $configFile);
}

/**
* @BeforeSuite
*/
public static function beforeSuite(BeforeSuiteScope $scope): void
{
self::disablePreventDuplicatePlaceCreation();
}

/**
* @BeforeFeature @duplicate
*/
public static function beforeFeatureDuplicate(BeforeFeatureScope $scope): void
{
self::enablePreventDuplicatePlaceCreation();
}

/**
* @AfterFeature @duplicate
*/
public static function afterFeatureDuplicate(AfterFeatureScope $scope): void
{
self::disablePreventDuplicatePlaceCreation();
}

/**
Expand Down
10 changes: 2 additions & 8 deletions features/place/duplicate.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@duplicate
Feature: Test creating places

Background:
Expand All @@ -6,19 +7,15 @@ Feature: Test creating places
And I am authorized as JWT provider v1 user "centraal_beheerder"
And I send and accept "application/json"


Scenario: Allow creating a new place, if a "duplicate" place before was rejected
Given I prevent duplicate place creation
Given I create a random name of 6 characters and keep it as "name"
Given I create a minimal place and save the "id" as "originalPlaceId" then I should get a "201" response code
When I publish the place at "/places/%{originalPlaceId}"
And I reject the place at "/places/%{originalPlaceId}" with reason "Rejected"
Then I wait for the place with url "/places/%{originalPlaceId}" to be indexed
Given I create a minimal place then I should get a "201" response code
Then I restore the duplicate configuration
And I create a minimal place then I should get a "201" response code

Scenario: Be prevented from creating a new place if we already have one on that address
Given I prevent duplicate place creation
Given I create a random name of 6 characters and keep it as "name"
Given I create a minimal place and save the "id" as "originalPlaceId" then I should get a "201" response code
Then I wait for the place with url "/places/%{originalPlaceId}" to be indexed
Expand All @@ -33,10 +30,8 @@ Feature: Test creating places
"duplicatePlaceUri": "%{baseUrl}/place/%{originalPlaceId}"
}
"""
Then I restore the duplicate configuration

Scenario: Be prevented from creating a new place if we already have one on that address when the the address contains special chars
Given I prevent duplicate place creation
Given I create a name that includes special characters of elastic search and keep it as "name"
Given I create a minimal place and save the "id" as "originalPlaceId" then I should get a "201" response code
Then I wait for the place with url "/places/%{originalPlaceId}" to be indexed
Expand All @@ -51,4 +46,3 @@ Feature: Test creating places
"duplicatePlaceUri": "%{baseUrl}/place/%{originalPlaceId}"
}
"""
Then I restore the duplicate configuration
Loading