2

私は次のような自明な小さなPHPUnitテストを持っています:

<?php
namespace VNN\PressboxBundle\Tests\Entity;
namespace VNN\PressboxBundle\Entity;

use VNN\PressboxBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Phactory\Sql\Phactory;

class UserTest extends EntityTest
{
    public function testCreate()
    {   
        Phactory::reset();
    }   
}

私がそれを実行しようとすると、私はこれを取得します:

There was 1 error:

1) VNN\PressboxBundle\Entity\UserTest::testCreate
ErrorException: Runtime Notice: Non-static method Phactory\Sql\Phactory::reset() should not be called statically, assuming $this from incompatible context in /Users/jason/Web/pressbox/src/VNN/PressboxBundle/Tests/Entity/UserTest.php line 13

どうしたの?すべてのドキュメントはそれを静的に呼び出します。

それが違いを生むのであれば、私はSymfony2.0でこれを行っています。

4

3 に答える 3

0

ドキュメントには、渡したオブジェクトに基づいてインスタンス化されるような個々の実装ではなく、Phactory直下のトップレベルクラスを使用する必要があると記載されています。変化するlib/Phactory/Sql/PhactoryPDOsetConnection

use Phactory\Sql\Phactory;

require_once 'Phactory/lib/Phactory.php';

useメインクラスはグローバル名前空間にあり、ステートメントは必要ありません。

于 2012-10-31T22:05:47.890 に答える
0

現在のバージョン 0.3.2 は、文書化されている静的メソッド構造と下位互換性がありません。

これが重大なコミットです: https://github.com/chriskite/phactory/commit/d3b60eeedea955ab7b5803ec29446d19888d3849

残念ながら、ドキュメントはhttp://phactory.orgで更新されておらず、pearhub リポジトリは利用できなくなりました。

例としてテストを見ていきます: https://github.com/chriskite/phactory/blob/next/tests/Phactory/Sql/PhactoryTest.php

于 2014-03-29T18:16:58.250 に答える