-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2b419b
commit 8f3c060
Showing
7 changed files
with
149 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/vendor/ | ||
.php-cs-fixer.cache | ||
.phpunit.result.cache |
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,26 @@ | ||
DOCKER_INTERNAL ?= 8 | ||
DOCKER = $(shell docker ps 2> /dev/null) | ||
|
||
check-docker: | ||
ifndef DOCKER | ||
$(error "DOCKER is unavailable on your system") | ||
endif | ||
|
||
phpunit: check-docker | ||
docker pull prestashop/docker-internal-images:${DOCKER_INTERNAL} | ||
@docker run --rm \ | ||
--name phpunit \ | ||
-e PS_DOMAIN=localhost \ | ||
-e PS_ENABLE_SSL=0 \ | ||
-e PS_DEV_MODE=1 \ | ||
-e XDEBUG_MODE=coverage \ | ||
-e XDEBUG_ENABLED=1 \ | ||
-v ${PWD}:/var/www/html/test-lib \ | ||
-w /var/www/html/test-lib \ | ||
prestashop/docker-internal-images:${DOCKER_INTERNAL} \ | ||
sh -c " \ | ||
service mariadb start && \ | ||
service apache2 start && \ | ||
_PS_ROOT_DIR_=/var/www/html/ vendor/bin/phpunit \ | ||
" | ||
@echo phpunit passed |
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="tests/bootstrap.php" | ||
colors="true" | ||
stopOnFailure="false" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
> | ||
<testsuites> | ||
<testsuite name="Integration"> | ||
<directory suffix="Test.php">tests/Integration</directory> | ||
</testsuite> | ||
</testsuites> | ||
<logging/> | ||
</phpunit> |
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,37 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prestashop\ModuleLibMboInstaller\Installer; | ||
use Prestashop\ModuleLibMboInstaller\Presenter; | ||
|
||
class InstallationTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
if (version_compare(_PS_VERSION_, '8.0.0', '<')) { | ||
global $kernel; | ||
$moduleManager = $kernel->getContainer()->get('prestashop.module.manager'); | ||
$moduleManager->uninstall('ps_mbo', true); | ||
} | ||
} | ||
|
||
public function testModuleIsInstalled() | ||
{ | ||
$mboStatusBeforeInstall = (new Presenter())->present(); | ||
|
||
// Expect module to be unknown | ||
$this->assertFalse($mboStatusBeforeInstall['isInstalled']); | ||
$this->assertFalse($mboStatusBeforeInstall['isEnabled']); | ||
|
||
// Install it... | ||
$this->assertTrue((new Installer(_PS_VERSION_))->installModule()); | ||
|
||
// Expect module to be installed now | ||
$mboStatusAfterInstall = (new Presenter())->present(); | ||
$this->assertTrue($mboStatusAfterInstall['isPresentOnDisk']); | ||
$this->assertTrue($mboStatusAfterInstall['isInstalled']); | ||
// CheckMe: MBO appears as disabled on PS 1.7 | ||
// $this->assertTrue($mboStatusAfterInstall['isEnabled']); | ||
$this->assertIsString($mboStatusAfterInstall['version']); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
if (!getenv('_PS_ROOT_DIR_')) { | ||
echo "[ERROR] Define _PS_ROOT_DIR_ with the path to PrestaShop folder\n"; | ||
exit(1); | ||
} | ||
|
||
if (!defined('_PS_ADMIN_DIR_')) { | ||
define('_PS_ADMIN_DIR_', '/admin'); | ||
} | ||
|
||
if (!defined('_PS_MODE_DEV_')) { | ||
define('_PS_MODE_DEV_', true); | ||
} | ||
|
||
$rootDirectory = getenv('_PS_ROOT_DIR_'); | ||
require_once $rootDirectory . '/config/config.inc.php'; | ||
|
||
global $kernel; | ||
if (!$kernel) { | ||
require_once _PS_ROOT_DIR_ . '/app/AppKernel.php'; | ||
$kernel = new \AppKernel('dev', true); | ||
$kernel->boot(); | ||
} |