由于initializeProxy()不兼容,Symfony测试环境无法正常工作

时间:2018-02-22 17:34:49

标签: symfony doctrine

我刚刚尝试过第一次使用我的symfony 3.4.4应用程序的测试环境。

# bin/console cache:clear --env=test

Fatal error: Declaration of DoctrineORMEntityManager_00000000172a5a75000000013cf6d6a8f17b02056250ecf67e0f41484de53fd3::initializeProxy() must be compatible with ProxyManager\Proxy\LazyLoadingInterface::initializeProxy(): bool in /var/www/symfony/var/cache/test/appTestDebugProjectContainer.php on line 5031

In appTestDebugProjectContainer.php line 5031:

  Compile Error: Declaration of DoctrineORMEntityManager_00000000172a5a75000000013cf6d6a8f17b02056250ecf67e0f41484de53fd3::initializeProxy() must be compatible with ProxyManager\Proxy\La  
  zyLoadingInterface::initializeProxy(): bool   

我的应用在开发和测试环境中运行良好。我第一次发布vendor/bin/simple-phpunit时发生了错误。

以下是我的套餐output of composer show -i

config.yml:

framework:
    #esi: ~
    #translator: { fallbacks: ['%locale%'] }
    translator: ~
    secret: '%secret%'
    router:
        resource: '%kernel.root_dir%/config/routing.yml'
        strict_requirements: ~
    form: ~
    csrf_protection: ~
    validation: { enable_annotations: true }
    #serializer: { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale: '%locale%'
    trusted_hosts: ~
    session:
        # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
        handler_id:  session.handler.native_file
        save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
    fragments: ~
    http_method_override: true
    assets: 
        json_manifest_path: '%kernel.project_dir%/web/build/manifest.json'
    php_errors:
        log: true

学说配置

doctrine:
    dbal:
        driver: pdo_mysql
        host: '%database_host%'
        port: '%database_port%'
        dbname: '%database_name%'
        user: '%database_user%'
        password: '%database_password%'
        charset: utf8mb4
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci
        types:
            enuminterval: AppBundle\DBAL\EnumIntervalType
        mapping_types:
            enum: string
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

和我的config_test.yml

imports:
    - { resource: config_dev.yml }

framework:
    test: ~
    session:
        storage_id: session.storage.mock_file
    profiler:
        collect: false

web_profiler:
    toolbar: false
    intercept_redirects: false

swiftmailer:
    disable_delivery: true

config_dev.yml:

imports:
    - { resource: config.yml }

framework:
    router:
        resource: '%kernel.root_dir%/config/routing_dev.yml'
        strict_requirements: true
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: true
    intercept_redirects: false

我的phpunit.xml.dist非常标准:

<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="vendor/autoload.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
        <server name="KERNEL_CLASS" value="AppKernel" />
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>src</directory>
            <exclude>
                <directory>src/*Bundle/Resources</directory>
                <directory>src/*/*Bundle/Resources</directory>
                <directory>src/*/Bundle/*Bundle/Resources</directory>
            </exclude>
        </whitelist>
    </filter>
</phpunit>

0 个答案:

没有答案