-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from PrestaShopCorp/refactor/phpunit-target
refactor: phpunit setup
- Loading branch information
Showing
14 changed files
with
169 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: "3.7" | ||
services: | ||
phpunit: | ||
container_name: phpunit-dev | ||
image: prestashop/docker-internal-images:nightly | ||
working_dir: /var/www/html/modules/ps_accounts | ||
environment: | ||
- PS_DOMAIN=localhost | ||
- PS_ENABLE_SSL=0 | ||
- PS_DEV_MODE=1 | ||
volumes: | ||
- ./:/var/www/html/modules/ps_accounts | ||
entrypoint: [ | ||
"/bin/sh", "-c", " \ | ||
service mysql start && \ | ||
php -d memory_limit=-1 ../../bin/console prestashop:module install ps_accounts && \ | ||
chown -R www-data:www-data ../../var/logs && \ | ||
apache2-foreground | ||
" | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace PrestaShop\Module\PsAccounts\Tests\Unit; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\ORM\OptimisticLockException; | ||
use Exception; | ||
use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient; | ||
use PrestaShop\Module\PsAccounts\DTO\UpdateShop; | ||
use PrestaShop\Module\PsAccounts\Provider\ShopProvider; | ||
use PrestaShop\Module\PsAccounts\Tests\TestCase; | ||
use PrestaShop\PrestaShop\Adapter\Meta\ShopUrlDataConfiguration; | ||
use PrestaShopBundle\Entity\Shop; | ||
|
||
class HookActionObjectShopUpdateAfterTest extends TestCase | ||
{ | ||
/** | ||
* @not_a_test | ||
* | ||
* @throws Exception | ||
* @throws OptimisticLockException | ||
*/ | ||
public function itShouldUpdateBoBaseUrlInBoContext() | ||
{ | ||
// TODO: spy on update shop api call boBaseUrl | ||
///** @var AccountsClient $tokenRepos */ | ||
$apiClient = $this->getMockBuilder(AccountsClient::class) | ||
->setConstructorArgs([ | ||
$this->module->getParameter('ps_accounts.accounts_api_url'), | ||
$this->module->getService(ShopProvider::class) | ||
]) | ||
->setMethods(['updateUserShop']) | ||
->getMock(); | ||
|
||
// Replace with mocked version | ||
//$this->module->getServiceContainer()->getContainer()->set(AccountsClient::class, $apiClient); | ||
|
||
// $this->assertEquals('toto', | ||
// $this->module->getService(AccountsClient::class) | ||
// ->updateUserShop(new UpdateShop([ | ||
// 'shopId' => 1, | ||
// 'name' => 'foo', | ||
// 'domain' => 'my.shop', | ||
// 'sslDomain' => 'my.secure.shop', | ||
// 'virtualUri' => 'bar', | ||
// 'physicalUri' => 'baz', | ||
// 'boBaseUrl' => 'base.url', | ||
// ])) | ||
// ); | ||
|
||
$apiClient->expects($this->once()) | ||
->method('updateUserShop') | ||
->willReturnCallback(function (UpdateShop $updateShopDto) { | ||
$boBaseUrl = $updateShopDto->boBaseUrl; | ||
error_log('############### ' . $boBaseUrl); | ||
}); | ||
|
||
/** @var ShopUrlDataConfiguration $shopUrlData */ | ||
$shopUrlData = $this->module->getContainer()->get('prestashop.adapter.meta.shop_url.configuration'); | ||
|
||
$shopUrlData->updateConfiguration([ | ||
"domain" => 'foo.com', | ||
"domain_ssl" => 'foo.secure.com', | ||
"physical_uri" => '/', | ||
]); | ||
|
||
// /** @var EntityManagerInterface $entityManager */ | ||
// $entityManager = $this->module->getContainer()->get('doctrine.orm.entity_manager'); | ||
// | ||
// $shopRepository = $entityManager->getRepository(Shop::class); | ||
// | ||
// /** @var Shop $shop */ | ||
// $shop = $shopRepository->findOneBy(['id' => 1]); | ||
// | ||
// // FIXME: update shop domain | ||
// $shop->setName('Test PrestaShop'); | ||
// | ||
// $entityManager->persist($shop); | ||
// $entityManager->flush(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
<?php | ||
@include (__DIR__ . '/local_config.php'); | ||
|
||
// depends on BE | FE context | ||
if (!defined('_PS_ADMIN_DIR_')) { | ||
define('_PS_ADMIN_DIR_', ''); | ||
define('_PS_ADMIN_DIR_', '/admin'); | ||
} | ||
|
||
$rootDirectory = getenv('_PS_ROOT_DIR_') ?: __DIR__ . '/../../..'; | ||
$projectDir = __DIR__ . '/../'; | ||
if (!defined('_PS_MODE_DEV_')) { | ||
define('_PS_MODE_DEV_', true); | ||
} | ||
|
||
$rootDirectory = getenv('_PS_ROOT_DIR_') ?: __DIR__ . '/../../..'; | ||
require_once $rootDirectory . '/config/config.inc.php'; | ||
require_once $projectDir . '/vendor/autoload.php'; | ||
|
||
//$projectDir = __DIR__ . '/../'; | ||
//require_once $projectDir . '/vendor/autoload.php'; | ||
|
||
// FIXME: load kernel when necessary | ||
global $kernel; | ||
if(!$kernel){ | ||
require_once _PS_ROOT_DIR_.'/app/AppKernel.php'; | ||
$kernel = new \AppKernel('dev', true); | ||
$kernel->boot(); | ||
} |