Reputation: 41
I am working on Zend framework , i have set up everything but in the unit testing i get a fatal error:
c:\xampp\htdocs\zend\module\Album\test>phpunit PHP Catchable fatal error: Arugment 1 passed to Zend\ServiceManager\ServiceManager::__construct() must be of the type array, object given, called in C:\xampp\htdocs\zend\module\Album\test\Bootstrap.php on line 53 and defined in c:\xampp\htdocs\zend\vendorframework\zend-servicemanager\src\ServiceManager.php on line 144
Bootstrap.php Line 52-58:
$config = ArrayUtils::merge($baseConfig, $testConfig);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
static::$config = $config;
ServiceManager.php Line 144-148:
public function __construct(array $config = [])
{
$this->creationContext = $this;
$this->configure($config = []);
}
Some advice please???
Upvotes: 2
Views: 317
Reputation: 6401
$serviceManager = new ServiceManager(new ServiceManagerConfig());
Arugment 1 passed to Zend\ServiceManager\ServiceManager::__construct() must be of the type array, object given
The error is telling you that ServiceManager
expects an array as an argument. The argument you are passing is new ServiceManagerConfig()
, which is an object.
It's a version mis-match.
In zendframework/zend-servicemanager
~2.0
the ServiceManager
constructor requires an object.
In zendframework/zend-servicemanager
~3.0
the ServiceManager
constructor requires an array.
If you are using the zf skeleton application, make sure you are using the correct version.
Upvotes: 1