Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPunit我可以';t回滚_Phpunit - Fatal编程技术网

PHPunit我可以';t回滚

PHPunit我可以';t回滚,phpunit,Phpunit,我的交易有问题。我必须在setup()打开一个,到目前为止,我可以这样做,然后使用TearDown()回滚它。问题是我无法从teardown()访问我的连接($dbh) 请尝试使用文档一节中介绍的setUpBeforeClass()和tearDownAfterClass()模板方法 class PanneauTest extends TestCase { private $http; private $token; private $dbh; protecte

我的交易有问题。我必须在
setup()
打开一个,到目前为止,我可以这样做,然后使用
TearDown()
回滚它。问题是我无法从
teardown()
访问我的连接
($dbh)


请尝试使用文档一节中介绍的
setUpBeforeClass()
tearDownAfterClass()
模板方法
class PanneauTest extends TestCase
{
    private $http;
    private $token;
    private $dbh;


    protected function setUp(): void
    {
        $this->http = new GuzzleHttp\Client(['base_uri' => 
    'http://localhost/rocourt/01-Backend/api/v1/public/']);

        $this->token = User::login('toto', '1234');

        $this->dbh = getConnection();
        $this->dbh->beginTransaction();
    }

    protected function tearDown(): void
    {
        //I can't use the dbh->rollback()from this function 
    }