首页 > 解决方案 > 在受保护的 dataProvider 方法中获取固定装置

问题描述

我在我的 Codeception Cest 类中使用dataProvider 受保护的方法。
可以在 dataProvider 方法中获取固定装置吗?例如:

class PageCest
{
   /**
    * @dataProvider pageProvider
    */
    public function staticPages(AcceptanceTester $I, \Codeception\Example $example)
    {
        $I->amOnPage($example['url']);
        $I->see($example['title'], 'h1');
        $I->seeInTitle($example['title']);
    }

    /**
     * @return array
     */
    protected function pageProvider(): array
    {

        // Here I want to use some like $I->grabFixture()

        return [
            ['url'=>"/", 'title'=>"Welcome"],
            ['url'=>"/info", 'title'=>"Info"],
            ['url'=>"/about", 'title'=>"About Us"],
            ['url'=>"/contact", 'title'=>"Contact Us"]
        ];
    }
}

标签: phpcodeception

解决方案


推荐阅读