diff --git a/Jenkinsfile b/Jenkinsfile index 1cf51fef..4cb59d92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -306,20 +306,26 @@ void runIntegrationTest(String phpVersion, String client, String psrImplem, Stri unstash "pim_community_dev_${pimVersion}" if ("master" == pimVersion) { + sh "docker pull akeneo/fpm:php-7.1 || true" + sh "docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim --tmpfs=/var/lib/mysql/:rw,noexec,nosuid,size=400m --tmpfs=/tmp/:rw,noexec,nosuid,size=200m -d mysql:5.7" sh "docker run --name elasticsearch -e ES_JAVA_OPTS=\"-Xms256m -Xmx256m\" -d elasticsearch:5" sh "docker run --name akeneo-pim --link mysql:mysql --link elasticsearch:elasticsearch -v \$(pwd):/srv/pim -w /srv/pim -d akeneo/fpm:php-7.1" sh "docker run --name httpd --link akeneo-pim:fpm -v \$(pwd):/srv/pim -v \$(pwd)/docker/httpd.conf:/usr/local/apache2/conf/httpd.conf -v \$(pwd)/docker/akeneo.conf:/usr/local/apache2/conf/vhost.conf -w /srv/pim -d httpd:2.4" + + // Wait for elasticsearch container ready + sh "sleep 20" + sh "docker exec akeneo-pim bin/console pim:install -e prod" } if ("1.7" == pimVersion) { sh "docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim --tmpfs=/var/lib/mysql/:rw,noexec,nosuid,size=400m --tmpfs=/tmp/:rw,noexec,nosuid,size=200m -d mysql:5.5" sh "docker run --name akeneo-pim --link mysql:mysql -v \$(pwd):/srv/pim -v \$(pwd)/docker/akeneo.conf:/etc/apache2/sites-available/000-default.conf:ro -w /srv/pim -d akeneo/apache-php:php-5.6" - } - // Wait for elasticsearch container ready - sh "sleep 20" - sh "docker exec akeneo-pim app/console pim:install -e prod" + // Wait for elasticsearch container ready + sh "sleep 20" + sh "docker exec akeneo-pim app/console pim:install -e prod" + } } unstash "php-api-client_${client}_${psrImplem}_php-${phpVersion}".replaceAll("/", "_") @@ -328,6 +334,8 @@ void runIntegrationTest(String phpVersion, String client, String psrImplem, Stri if ("master" == pimVersion) { docker.image("akeneo/php:${phpVersion}").inside("--link akeneo-pim:akeneo-pim --link httpd:httpd -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -w /home/docker/client --privileged") { sh "sed -i \"s#baseUri: .*#baseUri: 'http://httpd'#g\" etc/parameters.yml" + sh "sed -i \"s#bin_path: .*#bin_path: bin#g\" etc/parameters.yml" + sh "sed -i \"s#version: .*#version: #g\" etc/parameters.yml" sh "sudo ./bin/phpunit -c phpunit.xml.dist --testsuite PHP_Client_Unit_Test_1_8 --log-junit build/logs/phpunit_integration.xml" } } diff --git a/etc/parameters.yml.dist b/etc/parameters.yml.dist index 91a8ea2e..92b174c8 100644 --- a/etc/parameters.yml.dist +++ b/etc/parameters.yml.dist @@ -8,3 +8,5 @@ pim: install_path: '/srv/pim' is_docker: true docker_name: akeneo-pim + bin_path: app + version: '1.7' diff --git a/tests/Common/Api/ApiTestCase.php b/tests/Common/Api/ApiTestCase.php index 47d36a41..5ee6e7cb 100644 --- a/tests/Common/Api/ApiTestCase.php +++ b/tests/Common/Api/ApiTestCase.php @@ -31,7 +31,7 @@ protected function setUp() $installer = new DockerDatabaseInstaller($config['pim']['docker_name']); } - $installer->install($config['pim']['install_path']); + $installer->install($config['pim']['install_path'], $config['pim']['bin_path']); } /** @@ -45,7 +45,7 @@ protected function createClient() $generator = new DockerCredentialGenerator($config['pim']['docker_name']); } - $credentials = $generator->generate($config['pim']['install_path']); + $credentials = $generator->generate($config['pim']['install_path'], $config['pim']['bin_path'], $config['pim']['version']); $clientBuilder = new AkeneoPimClientBuilder($config['api']['baseUri']); return $clientBuilder->buildAuthenticatedByPassword( diff --git a/tests/Common/Api/Product/ListProductApiIntegration.php b/tests/Common/Api/Product/ListProductApiIntegration.php index db4bf38f..5c39ba5b 100644 --- a/tests/Common/Api/Product/ListProductApiIntegration.php +++ b/tests/Common/Api/Product/ListProductApiIntegration.php @@ -102,118 +102,6 @@ public function testAllWithSelectedAttributes() $this->assertSameContent($expectedProduct, $actualProduct); } - public function testAllWithSelectedLocales() - { - $baseUri = $this->getConfiguration()['api']['baseUri']; - $api = $this->createClient()->getProductApi(); - $products = $api->all(10, [ - 'locales' => 'fr_FR', - 'search' => [ - 'categories' => [ - [ - 'operator' => 'IN', - 'value' => ['sandals'], - ] - ] - ] - ]); - - $expectedProduct = $this->sanitizeProductData([ - '_links' => [ - 'self' => [ - 'href' => $baseUri . '/api/rest/v1/products/dance_shoe', - ], - ], - 'identifier' => 'dance_shoe', - 'family' => 'sandals', - 'groups' => [], - 'variant_group' => null, - 'categories' => [ - 'sandals', - ], - 'enabled' => true, - 'values' => [ - 'color' => [ - [ - 'locale' => null, - 'scope' => null, - 'data' => 'greem', - ], - ], - 'description' => [ - [ - 'locale' => 'fr_FR', - 'scope' => 'ecommerce', - 'data' => 'Dansez toute la nuit !', - ], - ], - 'destocking_date' => [ - [ - 'locale' => null, - 'scope' => null, - 'data' => '2017-06-30T00:00:00+00:00', - ], - ], - 'manufacturer' => [ - [ - 'locale' => null, - 'scope' => null, - 'data' => 'Converse', - ], - ], - 'name' => [ - [ - 'locale' => 'fr_FR', - 'scope' => null, - 'data' => 'Chaussure de dance', - ], - ], - 'side_view' => [ - [ - 'locale' => null, - 'scope' => null, - 'data' => '0/4/1/a/041a1570a3cefa2c79872c433f60c2e6301afd60_Akeneo_logo.png', - '_links' => [ - 'download' => [ - 'href' => $baseUri . '/api/rest/v1/media-files/0/4/1/a/041a1570a3cefa2c79872c433f60c2e6301afd60_Akeneo_logo.png/download', - ], - ], - ], - ], - 'size' => [ - [ - 'locale' => null, - 'scope' => null, - 'data' => '40', - ], - ], - 'price' => [ - [ - 'locale' => null, - 'scope' => null, - 'data' => [ - [ - 'amount' => '90.50', - 'currency' => 'USD', - ], - [ - 'amount' => '99.49', - 'currency' => 'EUR', - ], - ], - ], - ], - ], - 'created' => '2017-06-26T07:33:09+00:00', - 'updated' => '2017-06-26T07:33:09+00:00', - 'associations' => [], - ]); - - $actualProduct = $this->sanitizeProductData(iterator_to_array($products)[0]); - - $this->assertSameContent($expectedProduct, $actualProduct); - } - public function testAllWithSelectedScope() { $baseUri = $this->getConfiguration()['api']['baseUri']; diff --git a/tests/CredentialGeneratorInterface.php b/tests/CredentialGeneratorInterface.php index 3772e6f4..84e21efb 100644 --- a/tests/CredentialGeneratorInterface.php +++ b/tests/CredentialGeneratorInterface.php @@ -14,11 +14,13 @@ interface CredentialGeneratorInterface /** * Generates credentials on the PIM. * - * @param string $path path to Akeneo PIM application + * @param string $path path to Akeneo PIM application + * @param string $binPath path to Akeneo PIM binaries + * @param string $pimVersion Akeneo PIM version * * @throws \RuntimeException if an error occured during the generation process * * @return array credentials on the form ['client_id' => 'client', 'secret' => 'secret'] */ - public function generate($path); + public function generate($path, $binPath, $pimVersion); } diff --git a/tests/DatabaseInstallerInterface.php b/tests/DatabaseInstallerInterface.php index f1af367c..a26b79ab 100644 --- a/tests/DatabaseInstallerInterface.php +++ b/tests/DatabaseInstallerInterface.php @@ -15,8 +15,9 @@ interface DatabaseInstallerInterface * Install the database of the PIM. * * @param string $path path to Akeneo PIM application + * @param string $binPath path to Akeneo PIM binaries * * @throws \RuntimeException if an error occured during the PIM install */ - public function install($path); + public function install($path, $binPath); } diff --git a/tests/DockerCredentialGenerator.php b/tests/DockerCredentialGenerator.php index ae58c7e0..26a0bfe6 100644 --- a/tests/DockerCredentialGenerator.php +++ b/tests/DockerCredentialGenerator.php @@ -25,14 +25,15 @@ public function __construct($dockerName) /** * {@inheritdoc} */ - public function generate($path) + public function generate($path, $binPath, $pimVersion) { - $command = sprintf('docker exec %s php %s/app/console pim:oauth-server:create-client -e prod', $this->dockerName, $path); + $label = "1.7" === $pimVersion ? '--label="PHP client credentials"' : '"PHP client credentials"'; + $command = sprintf('docker exec %s php %s/%s/console pim:oauth-server:create-client %s -e prod', $this->dockerName, $path, $binPath, $label); $output = []; exec(escapeshellcmd($command), $output); - if (count($output) !== 3) { + if (count($output) !== 4) { throw new \RuntimeException('An error occurred during the generation of the client id and secret.'); } diff --git a/tests/DockerDatabaseInstaller.php b/tests/DockerDatabaseInstaller.php index 51776245..64d90310 100644 --- a/tests/DockerDatabaseInstaller.php +++ b/tests/DockerDatabaseInstaller.php @@ -25,9 +25,9 @@ public function __construct($dockerName) /** * {@inheritdoc} */ - public function install($path) + public function install($path, $binPath) { - $command = sprintf('docker exec %s php %s/app/console pim:installer:db -e prod', $this->dockerName, $path); + $command = sprintf('docker exec %s php %s/%s/console pim:installer:db -e prod', $this->dockerName, $path, $binPath); $output = []; exec(escapeshellcmd($command), $output, $status); diff --git a/tests/LocalCredentialGenerator.php b/tests/LocalCredentialGenerator.php index 205985f5..b1b82606 100644 --- a/tests/LocalCredentialGenerator.php +++ b/tests/LocalCredentialGenerator.php @@ -14,18 +14,19 @@ class LocalCredentialGenerator implements CredentialGeneratorInterface /** * {@inheritdoc} */ - public function generate($path) + public function generate($path, $binPath, $pimVersion) { if (!is_dir($path)) { throw new \RuntimeException(sprintf('Parameter "path" is not a directory or does not exist, "%s" given.', $path)); } - $command = sprintf('php %s/app/console pim:oauth-server:create-client -e prod', $path); + $label = "1.7" === $pimVersion ? '--label="PHP client credentials"' : '"PHP client credentials"'; + $command = sprintf('php %s/%s/console pim:oauth-server:create-client %s -e prod', $path, $binPath, $label); $output = []; exec(escapeshellcmd($command), $output); - if (count($output) !== 3) { + if (count($output) !== 4) { throw new \RuntimeException('An error occurred during the generation of the client id and secret.'); } diff --git a/tests/LocalDatabaseInstaller.php b/tests/LocalDatabaseInstaller.php index e429c64f..304d9aca 100644 --- a/tests/LocalDatabaseInstaller.php +++ b/tests/LocalDatabaseInstaller.php @@ -14,13 +14,13 @@ class LocalDatabaseInstaller implements DatabaseInstallerInterface /** * {@inheritdoc} */ - public function install($path) + public function install($path, $binPath) { if (!is_dir($path)) { throw new \RuntimeException(sprintf('Parameter "path" is not a directory or does not exist, "%s" given.', $path)); } - $command = sprintf('php %s/app/console pim:installer:db -e prod', $path); + $command = sprintf('php %s/%s/console pim:installer:db -e prod', $path, $binPath); $output = []; exec(escapeshellcmd($command), $output, $status); diff --git a/tests/v1_7/Api/Product/ListProductApiIntegration.php b/tests/v1_7/Api/Product/ListProductApiIntegration.php index 9c8de795..2611ecc5 100644 --- a/tests/v1_7/Api/Product/ListProductApiIntegration.php +++ b/tests/v1_7/Api/Product/ListProductApiIntegration.php @@ -178,6 +178,118 @@ public function testSearchWithSeveralFiltersUsingSearchBuilder() $this->assertSameContent($expectedProduct, $actualProduct); } + public function testAllWithSelectedLocales() + { + $baseUri = $this->getConfiguration()['api']['baseUri']; + $api = $this->createClient()->getProductApi(); + $products = $api->all(10, [ + 'locales' => 'fr_FR', + 'search' => [ + 'categories' => [ + [ + 'operator' => 'IN', + 'value' => ['sandals'], + ] + ] + ] + ]); + + $expectedProduct = $this->sanitizeProductData([ + '_links' => [ + 'self' => [ + 'href' => $baseUri . '/api/rest/v1/products/dance_shoe', + ], + ], + 'identifier' => 'dance_shoe', + 'family' => 'sandals', + 'groups' => [], + 'variant_group' => null, + 'categories' => [ + 'sandals', + ], + 'enabled' => true, + 'values' => [ + 'color' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => 'greem', + ], + ], + 'description' => [ + [ + 'locale' => 'fr_FR', + 'scope' => 'ecommerce', + 'data' => 'Dansez toute la nuit !', + ], + ], + 'destocking_date' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => '2017-06-30T00:00:00+00:00', + ], + ], + 'manufacturer' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => 'Converse', + ], + ], + 'name' => [ + [ + 'locale' => 'fr_FR', + 'scope' => null, + 'data' => 'Chaussure de dance', + ], + ], + 'side_view' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => '0/4/1/a/041a1570a3cefa2c79872c433f60c2e6301afd60_Akeneo_logo.png', + '_links' => [ + 'download' => [ + 'href' => $baseUri . '/api/rest/v1/media-files/0/4/1/a/041a1570a3cefa2c79872c433f60c2e6301afd60_Akeneo_logo.png/download', + ], + ], + ], + ], + 'size' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => '40', + ], + ], + 'price' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => [ + [ + 'amount' => '90.50', + 'currency' => 'USD', + ], + [ + 'amount' => '99.49', + 'currency' => 'EUR', + ], + ], + ], + ], + ], + 'created' => '2017-06-26T07:33:09+00:00', + 'updated' => '2017-06-26T07:33:09+00:00', + 'associations' => [], + ]); + + $actualProduct = $this->sanitizeProductData(iterator_to_array($products)[0]); + + $this->assertSameContent($expectedProduct, $actualProduct); + } + /** * @param string $identifier * diff --git a/tests/v1_8/Api/Product/ListProductApiIntegration.php b/tests/v1_8/Api/Product/ListProductApiIntegration.php index 38523b45..ccd3a93c 100644 --- a/tests/v1_8/Api/Product/ListProductApiIntegration.php +++ b/tests/v1_8/Api/Product/ListProductApiIntegration.php @@ -179,6 +179,118 @@ public function testSearchWithSeveralFiltersUsingSearchBuilder() $this->assertSameContent($expectedProduct, $actualProduct); } + public function testAllWithSelectedLocales() + { + $baseUri = $this->getConfiguration()['api']['baseUri']; + $api = $this->createClient()->getProductApi(); + $products = $api->all(10, [ + 'locales' => 'fr_FR', + 'search' => [ + 'categories' => [ + [ + 'operator' => 'IN', + 'value' => ['sandals'], + ] + ] + ] + ]); + + $expectedProduct = $this->sanitizeProductData([ + '_links' => [ + 'self' => [ + 'href' => $baseUri . '/api/rest/v1/products/dance_shoe', + ], + ], + 'identifier' => 'dance_shoe', + 'family' => 'sandals', + 'groups' => [], + 'variant_group' => null, + 'categories' => [ + 'sandals', + ], + 'enabled' => true, + 'values' => [ + 'color' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => 'greem', + ], + ], + 'description' => [ + [ + 'locale' => 'fr_FR', + 'scope' => 'ecommerce', + 'data' => 'Dansez toute la nuit !', + ], + ], + 'destocking_date' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => '2017-06-30T00:00:00+00:00', + ], + ], + 'manufacturer' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => 'Converse', + ], + ], + 'name' => [ + [ + 'locale' => 'fr_FR', + 'scope' => null, + 'data' => 'Chaussure de dance', + ], + ], + 'side_view' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => '0/4/1/a/041a1570a3cefa2c79872c433f60c2e6301afd60_Akeneo_logo.png', + '_links' => [ + 'download' => [ + 'href' => $baseUri . '/api/rest/v1/media-files/0/4/1/a/041a1570a3cefa2c79872c433f60c2e6301afd60_Akeneo_logo.png/download', + ], + ], + ], + ], + 'size' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => '40', + ], + ], + 'price' => [ + [ + 'locale' => null, + 'scope' => null, + 'data' => [ + [ + 'amount' => '99.49', + 'currency' => 'EUR', + ], + [ + 'amount' => '90.50', + 'currency' => 'USD', + ], + ], + ], + ], + ], + 'created' => '2017-06-26T07:33:09+00:00', + 'updated' => '2017-06-26T07:33:09+00:00', + 'associations' => [], + ]); + + $actualProduct = $this->sanitizeProductData(iterator_to_array($products)[0]); + + $this->assertSameContent($expectedProduct, $actualProduct); + } + /** * @param string $identifier * @@ -282,14 +394,14 @@ protected function getExpectedProducts() 'locale' => null, 'scope' => null, 'data' => [ - [ - 'amount' => '110.00', - 'currency' => 'USD', - ], [ 'amount' => '120.00', 'currency' => 'EUR', ], + [ + 'amount' => '110.00', + 'currency' => 'USD', + ], ], ], ], @@ -531,14 +643,14 @@ protected function getExpectedProducts() 'locale' => null, 'scope' => null, 'data' => [ - [ - 'amount' => '100.49', - 'currency' => 'USD', - ], [ 'amount' => '100.50', 'currency' => 'EUR', ], + [ + 'amount' => '100.49', + 'currency' => 'USD', + ], ], ], ], @@ -631,14 +743,14 @@ protected function getExpectedProducts() 'locale' => null, 'scope' => null, 'data' => [ - [ - 'amount' => '90.50', - 'currency' => 'USD', - ], [ 'amount' => '99.49', 'currency' => 'EUR', ], + [ + 'amount' => '90.50', + 'currency' => 'USD', + ], ], ], ],