1. Go to this page and download the library: Download prestaflow/php-library library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
prestaflow / php-library example snippets
class MigrationBaselineSuite extends TestsSuite
{
protected $psVersion = '1.7.8.11'; // static: pinned at class level
public function init(): void
{
// ...or fluent: pinned at boot time
$this->onVersion($_ENV['SHOP_UNDER_TEST'] ?? '1.7.8.11');
$this->importPage('BackOffice\Login');
}
}
protected ?string $shopUrl = 'http://localhost:8093/';
protected ?string $backOfficeUrl = 'admin123/'; // relative: appended to the effective shop URL
use PrestaFlow\Library\Exceptions\BackOfficeTimeoutException;
use PrestaFlow\Library\Tests\TestsSuite;
use PrestaFlow\Library\Visual\PageSnapshot;
TestsSuite::scopeBrowserFilesTo('picker-'.$jobId);
$browser = TestsSuite::getBrowser(force: true);
TestsSuite::applyEnvironment($browser, TestsSuite::getPage(), $boUrl); // Basic Auth, headers, cookies
$suite = new MyBackOfficeVisualSuite(loadGlobals: true, getBrowser: false);
try {
$where = $suite->openBackOfficeCheckpoint(['name' => 'picker', 'menu' => '#subtab-AdminProducts']);
$result = (new PageSnapshot())->captureCurrent(TestsSuite::getPage());
} catch (BackOfficeTimeoutException $e) {
// the back office did not answer in time: readable message
} catch (\RuntimeException $e) {
// run error, readable message: credentials refused, unexpected page, menu entry not found
} catch (\Exception $e) {
// raw chrome-php error from captureCurrent() (OperationTimedOut, EvaluationFailed, ScreenshotFailed…)
} finally {
$suite->closeBackOfficeSession();
TestsSuite::resetBrowser();
TestsSuite::clearEnvironment();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.