yireo/shopware6-integration-test-helper
Composer 安装命令:
composer require yireo/shopware6-integration-test-helper
包简介
Utilities to help you test your Shopware plugins
README 文档
README
Shopware 6 plugin and library to help you build PHPUnit-based integration tests easier
Features
- Custom PHPUnit bootstrap
- Support for various environment variables
- Various PHP traits
assertBundleIsInstalled(string $bundleName)assertServiceExists(string $serviceId)assertEntityExtensionExists(string $entityExtensionClass)
- PHP class
\Yireo\IntegrationTestHelper\Test\Integration\AbstractTestCase- Includes all PHP traits already
Installation
Install this plugin and activate it:
composer require yireo/shopware6-integration-test-helper --dev bin/console plugin:refresh bin/console plugin:install --activate YireoIntegrationTestHelper
PHPUnit configuration
Next, configure your PHPUnit file to use the file vendor/yireo/shopware6-integration-test-helper/src/test_bootstrap.php as a bootstrap. Also configure the DATABASE_URL (pointing to a different database than your regular Shopware database).
An example PHPUnit file is here:
<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="vendor/yireo/shopware6-integration-test-helper/src/test_bootstrap.php" colors="true" cacheResult="false"> <php> <ini name="error_reporting" value="E_ALL"/> <server name="KERNEL_CLASS" value="Shopware\Core\Kernel"/> <env name="FORCE_INSTALL" value="1"/> <env name="FORCE_INSTALL_PLUGINS" value="1"/> <env name="FORCE_INSTALL_ADDITIONAL_PLUGINS" value="YireoExample"/> <env name="APP_ENV" value="test"/> <env name="APP_DEBUG" value="1"/> <env name="APP_SECRET" value="s$cretf0rt3st"/> <env name="SHELL_VERBOSITY" value="-1"/> <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" /> <env name="LOCK_DSN" value="flock" /> <env name="DATABASE_URL" value="mysql://root:root@mysql:3306/shopware6_test" /> </php> </phpunit>
Instead of using the PHPUnit file for this, you could also add the environment variables to a file .env.test instead.
- When
FORCE_INSTALLis1, Shopware will do a reinstallation; - When
FORCE_INSTALL_PLUGINSis1, plugins will be refreshed, installed and activated; - When
FORCE_INSTALL_ADDITIONAL_PLUGINScontains a comma-separate list of plugins, each plugin will be installed and activated. Make sure to include at least your own plugin (in this exampleYireoExample);
Usage of PHP parent class
namespace Swag\Example\Test\Integration; use Yireo\IntegrationTestHelper\Test\Integration\AbstractTestCase; class BasicPluginTest extends AbstractTestCase { public function testIfBundleIsRegistered() { $this->assertBundleIsInstalled(); } }
Usage of PHP traits
namespace Swag\Example\Test\Integration; use PHPUnit\Framework\TestCase; use Shopware\Core\Framework\Test\TestCaseBase\IntegrationTestBehaviour; use Yireo\IntegrationTestHelper\Traits\AssertBundleIsInstalled; class BasicPluginTest extends TestCase { use IntegrationTestBehaviour; use AssertBundleIsInstalled; public function getName(): string { return self::class; // Shopware 6.5 requires you to implement this method } public function testIfBundleIsRegistered() { $this->assertBundleIsInstalled(); } }
yireo/shopware6-integration-test-helper 适用场景与选型建议
yireo/shopware6-integration-test-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 yireo/shopware6-integration-test-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yireo/shopware6-integration-test-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 58
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-19