/** * Initialize test case */ public function setUp() { require_once __DIR__ . '/../Kernel/TestKernel.php'; $kernel = new \TestKernel('test', false); $kernel->boot(); $this->container = $kernel->getContainer(); }
public function test() { $kernel = new TestKernel(); $kernel->boot(); }
class TestKernel extends \Shopware\Kernel { protected function initializeShopware() { $this->shopware = new \TestHelper($this->environment, $this->getConfig(), $this->container); } protected function getConfigPath() { return __DIR__ . '/Configs/Default.php'; } /** * Static method to start boot kernel without leaving local scope in test helper */ public static function start() { $kernel = new self('testing', true); $kernel->boot(); $shopwareBootstrap = $kernel->getShopware()->Bootstrap(); $shopwareBootstrap->Models()->generateAttributeModels(); $shopwareBootstrap->Plugins()->Core()->ErrorHandler()->registerErrorHandler(E_ALL | E_STRICT); /** @var $repository \Shopware\Models\Shop\Repository */ $repository = $shopwareBootstrap->Models()->getRepository('Shopware\\Models\\Shop\\Shop'); $shop = $repository->getActiveDefault(); $shop->registerResources($shopwareBootstrap); // correct router context for url building $kernel->container->get('router')->setContext(new \Shopware\Components\Routing\Context(Shopware()->Shop()->getHost(), Shopware()->Shop()->getBasePath(), Shopware()->Shop()->getSecure())); $_SERVER['HTTP_HOST'] = $shop->getHost(); } } TestKernel::start();