webit / test-tools

Web-IT 测试工具

0.1.0 2016-01-07 13:55 UTC

This package is auto-updated.

Last update: 2024-09-20 21:42:11 UTC


README

单元/行为测试工具

独立的 Symfony Bundle 配置测试

创建您的 AppKernel

use Webit\Tests\Behaviour\Bundle\Kernel as BaseKernel;

class AppKernel extends BaseKernel
{
    public function registerBundles()
    {
        return array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new My\BrandNewBundle();
        ); // array of your Bundles
    }
}

创建您的 FeatureContext 并注册 Kernel

use Webit\Tests\Behaviour\Bundle\BundleConfigurationContext;

class FeatureContext extends BundleConfigurationContext
{
    public function __construct()
    {
        parent::__construct(new AppKernel());
    }
}

场景示例

Feature: MyBrandNewBundle configuration feature
  In order to set up MyBrandNew library with Symfony Application
  As a developer
  I need Bundle Configuration / Extension
  
  Background:
    Given the configuration contains:
    """
    framework:
        secret: "my-secret-hash"
        
    my_brand_new: ~
    """
  
  Scenario: Basic configuration
    When I bootstrap the application
    Then there should be following services defined:
    """
    my_service_one, my_service_two, my_service_three
    """
    And there should be following aliases defined:
    | service                    | alias              |
    | my_service.default_service | my_service.service |
    And all given services should be reachable

创建您需要的场景(针对不同的配置选项)。请随意在您的上下文中添加任何其他检查(步骤)。