首頁 > 後端開發 > php教程 > 答:我如何運行特定的phinx seeder並在phpunit中取得產生的記錄?

答:我如何運行特定的phinx seeder並在phpunit中取得產生的記錄?

DDD
發布: 2024-09-13 20:16:10
原創
864 人瀏覽過

In this answer was solving a problem that I had: Running a phinx seeder upon phpunit:

Answer: How I can run specific phinx seeder and get the generated records in phpunit? answer re: How I can run specific phinx seeder and get the generated records in phpunit?
Answer: How I can run specific phinx seeder and get the generated records in phpunit?
0
Answer: How I can run specific phinx seeder and get the generated records in phpunit?

I had a case as the one you mention, I needed to run the seeder upon a mysql db at my unit test, thus I did following steps:

STEP1: Extending the Phinx\Db\Adapter\MysqlAdapter to accept an existing PDO connection*

namespace Tests
use Phinx\Db\Adapter\MysqlAdapter;

class TestAdapter extends MysqlAdapter
{
    public function __construct(\PDO
登入後複製
Open Full Answer

The answer above also gives solutions at this problem as well:
How given a PDO instance I can make a MysqlConnectionAdapter as well?

Feel free to provide improvements or suggestions to the mentioned problem. This was a solution of mine that may have some caveats.

以上是答:我如何運行特定的phinx seeder並在phpunit中取得產生的記錄?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:dev.to
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板