Problems testing with PHPUnit and factories

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems testing with PHPUnit and factories

Simon Walter
Hi all,

I am having a problem where factories that I have declared in the config
files or Module.php files are not being created:

return array(
     'service_manager' => array(
         'factories' => array(
             'log' => 'Log\Service\Factory\Log'
         ),
     )
);

"Zend\ServiceManager\ServiceManager::get was unable to fetch or create
an instance for log"

My main "Application" module's factories work fine with PHPUnit. My new
"Log" module's factories do not. Both work fine when accessing via
Apache (index.php).

Any ideas?

Thanks,

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Problems testing with PHPUnit and factories

jeremiah
The string literal you are using is not a fully qualified class name. That could be your issue. Consider using the new ::class syntax instead:

'log' => \Log\Service\Factory\Log::class

Jeremiah

On Feb 21, 2016, at 11:18 PM, Simon Walter <[hidden email]> wrote:

Hi all,

I am having a problem where factories that I have declared in the config files or Module.php files are not being created:

return array(
   'service_manager' => array(
       'factories' => array(
           'log' => 'Log\Service\Factory\Log'
       ),
   )
);

"Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for log"

My main "Application" module's factories work fine with PHPUnit. My new "Log" module's factories do not. Both work fine when accessing via Apache (index.php).

Any ideas?

Thanks,

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Problems testing with PHPUnit and factories

Simon Walter
No, that's not a problem. I just tried it. Also it works fine elsewhere - only when using from PHPUnit I see problems. It could be I have not set up my Bootstrap.php file correctly. Though, it looks like everything is loading correctly.

Simon

On 2016/02/22 16:36, Jeremiah Small wrote:
The string literal you are using is not a fully qualified class name. That could be your issue. Consider using the new ::class syntax instead:

'log' => \Log\Service\Factory\Log::class

Jeremiah

On Feb 21, 2016, at 11:18 PM, Simon Walter <[hidden email]> wrote:

Hi all,

I am having a problem where factories that I have declared in the config files or Module.php files are not being created:

return array(
   'service_manager' => array(
       'factories' => array(
           'log' => 'Log\Service\Factory\Log'
       ),
   )
);

"Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for log"

My main "Application" module's factories work fine with PHPUnit. My new "Log" module's factories do not. Both work fine when accessing via Apache (index.php).

Any ideas?

Thanks,

Simon

Reply | Threaded
Open this post in threaded view
|

Re: Problems testing with PHPUnit and factories

Stefano Torresi-2
Hey, just FYI, this list is the framework development list.
For general help please use [hidden email].
I suggest posting your question there, with a link to a pastebin of your phpunit bootstrap and all relevant configuration files.

Cheers.
Reply | Threaded
Open this post in threaded view
|

Re: Problems testing with PHPUnit and factories

Simon Walter
Thanks. Yes, I did think it was odd. I thought I was subscribed to both. When I sent an email to general, nothing showed up. So I thought it was for announcements or something.

Sorry about that. I will look into what is going on with my subscriptions.

Simon

On 2016/02/22 20:27, Stefano Torresi wrote:
Hey, just FYI, this list is the framework development list.
For general help please use [hidden email].
I suggest posting your question there, with a link to a pastebin of your phpunit bootstrap and all relevant configuration files.

Cheers.