1. Go to this page and download the library: Download open-dxp/test-foundation 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/ */
open-dxp / test-foundation example snippets
declare(strict_types=1);
namespace Acme\BlogBundle\Tests\Application;
use Acme\BlogBundle\AcmeBlogBundle;
use OpenDxp\HttpKernel\BundleCollection\BundleCollection;
use OpenDxp\TestFoundation\Kernel\TestKernel as BaseTestKernel;
final class TestKernel extends BaseTestKernel
{
public function registerBundlesToCollection(BundleCollection $collection): void
{
$collection->addBundle(new AcmeBlogBundle());
}
}
declare(strict_types=1);
use OpenDxp\TestFoundation\TestCase;
pest()->extend(TestCase::class)->in('Feature');
declare(strict_types=1);
use Acme\BlogBundle\Manager\PostManager;
use OpenDxp\TestFoundation\Container;
it('boots with the bundle and its services', function () {
expect(Container::get(PostManager::class))->toBeInstanceOf(PostManager::class);
});
declare(strict_types=1);
namespace App\Tests;
use App\Kernel;
use OpenDxp\TestFoundation\Kernel\Testable;
final class TestKernel extends Kernel
{
use Testable;
}
use DAMA\DoctrineTestBundle\PHPUnit\SkipDatabaseRollback;
use OpenDxp\TestFoundation\DatabaseSnapshot;
use OpenDxp\TestFoundation\EnvironmentTestCase;
#[SkipDatabaseRollback]
abstract class FullPageCacheWithoutRollbackTestCase extends EnvironmentTestCase
{
protected function setUp(): void
{
parent::setUp();
DatabaseSnapshot::save();
}
protected function tearDown(): void
{
DatabaseSnapshot::restore();
parent::tearDown();
}
protected static function environment(): string
{
return 'full_page_cache';
}
}
use OpenDxp\TestFoundation\PHPUnit\BootKernelTrait;
use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;
final class InstallSearchIndex implements Extension
{
use BootKernelTrait;
public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void
{
$kernel = self::bootKernel();
// install the index
$kernel->shutdown();
}
}