相关疑难解决方法(0)

Symfony2 - 使用FOSUserBundle进行测试

我会用FOSUserBundle为Symfony2写一个测试.

目前我尝试了一些方法,没有人工作.

我需要一个像"createAuthClient"这样的函数.

这是我的基础课.我发布它是因为你可以更好地理解我的问题.

<?php
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\BrowserKit\Cookie;

class WebTestMain extends WebTestCase
{
    protected static $container;

    static protected function createClient(array $options = array(), array $server = array())
    {
        $client = parent::createClient($options, $server);

        self::$container = self::$kernel->getContainer();

        return $client;
    }

    static function createAuthClient(array $options = array(), array $server = array())
    {
        // see lines below with my tries
    }
}
Run Code Online (Sandbox Code Playgroud)

第一次尝试:

if(static::$kernel === null)
{
    static::$kernel = static::createKernel($options);
    static::$kernel->boot();
}
if(static::$container === null)
{
    self::$container = self::$kernel->getContainer();
}

$parameters …
Run Code Online (Sandbox Code Playgroud)

authentication phpunit unit-testing symfony fosuserbundle

12
推荐指数
2
解决办法
6143
查看次数