提供Symfony \ Component \ Security \ Core \ SecurityContext类的Silex \ WebTestCase自2.6版以来不推荐使用,将在3.0中删除

时间:2015-06-04 09:48:23

标签: silex symfony

这是测试类

class CampaignControllerTest extends WebTestCase
{
    public function createApplication()
    {
        $app = CommonFunction::getApplication();
        $app['debug'] = true;
        $app['exception_handler']->disable();

        $app['session.storage'] = $app->share(function() {
            return new MockArraySessionStorage();
        });

        $app['session.test'] = true;

        return $app;
    }

    public function testInitialPage()
    {
        $client = $this->createClient();
        $crawler = $client->request('GET', '/');

        $this->assertEquals(1,1);
    }
}

当phpUnit收到此错误时,知道如何修复它吗?

    There was 1 error:

1) CampaignControllerTest::testInitialPage
The Symfony\Component\Security\Core\SecurityContext class is deprecated since version 2.6 and will be removed in 3.0. Use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage or Symfony\Component\Security\Core\Authorization\AuthorizationChecker instead.

/home/ariful1/imoney/formapply/vendor/symfony/security/Core/SecurityContext.php:14
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:76
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:126
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:83
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:327
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:126
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:83
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:252
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:264
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:126
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:83
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:113
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:126
/home/ariful1/imoney/formapply/vendor/pimple/pimple/lib/Pimple.php:83
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:540
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Application.php:188
/home/ariful1/imoney/formapply/vendor/silex/silex/src/Silex/Application.php:538
/home/ariful1/imoney/formapply/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php:81
/home/ariful1/imoney/formapply/vendor/symfony/browser-kit/Client.php:327
/home/ariful1/imoney/formapply/tests/FormApply/Test/Controller/CampaignControllerTest.php:26

我使用的是silex 1.2.x和phpunit 4.3。*。

1 个答案:

答案 0 :(得分:1)

去年在symfony框架中突然出现了这个问题。 final solution用于引导新的错误处理程序,该错误处理程序在运行测试时捕获弃用错误。您可以采用相同的解决方案或以其他方式配置错误报告,同时进行测试以忽略E_USER_DEPRECATED错误。