Yii Framework Forum: functional Codeception test unable to use componets like cache or solr - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

functional Codeception test unable to use componets like cache or solr [Error] Call to a member function get() on null

#1 User is offline   Borner 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 08-August 16

Posted 12 January 2018 - 04:33 AM

Hey,

I have set up codeception unit tests, which works on an simple example test.

Now I tried to build an simple functional test, which looks for an headline on an startpage. The test works on an dummy startpage, where I simply echo some HTML code.
But my "real" application page contains memcache-elements and an solr search.
If I run my functional test, like this:

class StartPageCest
{
    public function _before(\FunctionalTester $I)
    {
        $I->amOnPage(['site/index']);
    }
    public function _after(\FunctionalTester $I)
    {
    }
    public function tryToTest(\FunctionalTester $I)
    {
        $I->see('Hallo', 'h2');  
    }
}


I get the Error
[Error] Call to a member function get() on null
on the following line of the actionIndex:
$result = Yii::$app->cache->get('site_index_result');


It looks like, the cache component is not available on codeception runtime. If I remove that line, the test stops with an similar error near the solr call.

My application config is in ...config/web.php (basic template) and my test-config includes this application-config:
$config =  yii\helpers\ArrayHelper::merge(
    
        require(__DIR__ . '/web.php'),
      
    [
        'id' => 'app-tests',  
    ]
);

return $config;


Any idea, why caching object is not available during functional codeception test?

Thank you.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users