Product module tests updated

This commit is contained in:
4Giedrius committed 2015-03-26 14:15:07 +02:00
1 parent 257dc0a7b9
commit db69400a94
2 files changed
+42 -4

No files matched your search

+18 -1
View File
@@ -206,7 +206,11 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
$serviceMock->expects($this->atLeastOnce())
->method('createProduct')
->will($this->returnValue($newProductId));
$di = new \Box_Di();
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$this->api->setService($serviceMock);
$result = $this->api->prepare($data);
@@ -324,6 +328,11 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
->method('createAddon')
->will($this->returnValue($newAddonId));
$di = new \Box_Di();
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$this->api->setService($serviceMock);
@@ -550,6 +559,9 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
$di = new \Box_Di();
$di['db'] = $dbMock;
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setService($serviceMock);
$this->api->setDi($di);
@@ -632,6 +644,11 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
->method('createCategory')
->will($this->returnValue($newCategoryId));
$di = new \Box_Di();
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$this->api->setService($serviceMock);
$result = $this->api->category_create($data);
+24 -3
View File
@@ -83,6 +83,11 @@ class GuestTest extends \PHPUnit_Framework_TestCase {
->method('toApiArray')
->will($this->returnValue(array()));
$di = new \Box_Di();
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$this->api->setService($serviceMock);
$result = $this->api->get($data);
$this->assertInternalType('array', $result);
@@ -104,6 +109,11 @@ class GuestTest extends \PHPUnit_Framework_TestCase {
->method('toApiArray')
->will($this->returnValue(array()));
$di = new \Box_Di();
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$this->api->setService($serviceMock);
$result = $this->api->get($data);
$this->assertInternalType('array', $result);
@@ -121,7 +131,11 @@ class GuestTest extends \PHPUnit_Framework_TestCase {
$serviceMock->expects($this->atLeastOnce())
->method('findOneActiveBySlug')
->will($this->returnValue($model ));
$di = new \Box_Di();
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$this->api->setService($serviceMock);
$this->setExpectedException('\Box_Exception', 'Product not found');
@@ -187,6 +201,9 @@ class GuestTest extends \PHPUnit_Framework_TestCase {
$di = new \Box_Di();
$di['db'] = $dbMock;
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
@@ -206,7 +223,9 @@ class GuestTest extends \PHPUnit_Framework_TestCase {
$di = new \Box_Di();
$di['db'] = $dbMock;
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$arr = array(
@@ -237,7 +256,9 @@ class GuestTest extends \PHPUnit_Framework_TestCase {
$di = new \Box_Di();
$di['db'] = $dbMock;
$di['array_get'] = $di->protect(function (array $array, $key, $default = '') use ($di) {
return isset ($array[$key]) ? $array[$key] : $default;
});
$this->api->setDi($di);
$arr = array(