I learn to use Unit test in Yii2 with Codeception, and try to check if a billing is a "daily" billing from a merchant's setting.
$this->biller->merchant->detail->rule_type == self::PERIODIC_MODE_DAILY
I don't know how to mock that rule_type value if I use a Stub::make() function.
What I tried so far is using the nested array like this (doesn't work) :
$billing = Stub::make(Billing::class, [
'status' => Billing::STATUS_ACTIVE,
'set_periodic_by' => Billing::SET_PERIODIC_BY_MERCHANT,
'biller' => [
'merchant' => [
'detail' => [
'rule_type' => Billing::PERIODIC_MODE_DAILY,
]
]
]
]);
And I also tried to mock each of the object model using another Stub::make()
$billing = Stub::make(Billing::class, [
'status' => Billing::STATUS_ACTIVE,
'set_periodic_by' => Billing::SET_PERIODIC_BY_MERCHANT,
'getBiller' => Stub::make(Biller::class, [
'getMerchant' => Stub::make(Merchant::class, [
'getDetail' => Stub::make(MerchantDetail::class, [
'rule_type' => Billing::PERIODIC_MODE_DAILY,
])
])
])
]);
How do I properly create a "nested" function return values using Stub? Any comment or answer is always welcome.
Casting the nested array to (object) will do
$billing = Stub::make(Billing::class, [
'status' => Billing::STATUS_ACTIVE,
'set_periodic_by' => Billing::SET_PERIODIC_BY_MERCHANT,
'getBiller' => (object) [
'merchant' => (object) [
'detail' => (object) [
'rule_type' => Billing::PERIODIC_MODE_DAILY,
]
]
]
]);
Related
I'm trying to change instance type but since I have updated to SDK3 this script fails. I don't know what I'm doing wrong with waiters.
$client = new Ec2Client(self::getCredentials());
$client->stopInstances(array(
'InstanceIds' => $instanceIds,
));
$client->waitUntil('stopped', [
'InstanceId' => $instanceId,
]);
$client->ModifyInstanceAttribute(array(
'InstanceId' => $instanceId,
'Attribute' => 'instanceType',
'Value' => $instanceType
));
$client->startInstances(array(
'InstanceIds' => $instanceIds,
));
$client->waitUntil('running', [
'InstanceId' => $instanceId,
]);
I finally found the solution.
The problem was that InstanceId param was wrong... You have to use an array of instaces Ids.
$client->waitUntil('InstanceStopped', [
'InstanceIds' => array($instanceId),
]);
$client->waitUntil('InstanceRunning', [
'InstanceIds' => array($instanceId),
]);
According this doc, DynamoDB supports map (M) and list (L) types, but when I'm trying to create a table with (L) type, I'm getting an error:
ValidationException (client): 1 validation error detected: Value 'L' at 'attributeDefinitions.2.member.attributeType' failed to satisfy constraint: Member must satisfy enum value set: [B, N, S]
It is happening after adding ThreadReplyIds attribute to a Table info:
[
'AttributeDefinitions' => [
[
'AttributeName' => 'UserId',
'AttributeType' => 'N',
],
[
'AttributeName' => 'ThreadReplyIds', // <<---
'AttributeType' => 'L',
],
[
'AttributeName' => 'Title',
'AttributeType' => 'S',
],
],
'KeySchema' => [
[
'AttributeName' => 'UserId',
'KeyType' => 'HASH',
],
[
'AttributeName' => 'Title',
'KeyType' => 'RANGE',
],
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 5,
],
'TableName' => 'Thread',
]
My goal is to store a list or set of integer values for ThreadReplyIds.
What am I doing wrong?
At first, I thought it might be the version of the SDK that you are using. But after some reading through the documentation, it seems that when creating a table, the AttributeType for any AttributeDefinition can only be one of 'S|N|B' (meaning 'String', 'Number', or 'Binary'). Reference: PHP SDK DynamoDB AttributeDefinition.
This makes sense, since you can't use a List in your KeySchema anyway. It is therefore unnecessary to define an Attribute for your List when creating the table. You can always add this Attribute to whatever data you want when Putting or Updating Items in your table after it has been created. See here: PHP SDK DynamoDB PutItem
I have the Problem when creating an salesorder with Vtiger Webservice,
The sales order is created but somehow the tax is not added.
I thought it has something to do with the parameter : hdnTaxType
Cause even if I add this value 'group' it does not apply the Tax to the Salesorder.
I have to manually add The Taxtype 'group' then the system adds the tax.
thats why i tried to add values like:
'tax1' => '7.00',
and
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
nothing so far did help...
has anybody an Idea what the problem is?
Thank you
Tobi
$salesOrder =[
'lastname' => $customer['lastname'],
'subject' => 'Order from 01.01.1018',
'sostatus' => '1',
'assigned_user_id' => '',
'bill_street' => 'Rechunngsstrasse 123',
'ship_street' =>'Lieferungsstrasse 123',
'productid' => '14x4325',
'currency_id' => '21x1',
'carrier' => 'DHL',
'txtAdjustment' => '13',
'salescommission' => '12',
'exciseduty' => '15',
'hdnTaxType' => 'group',
'tax1' => '7.00',
'hdnS_H_Amount' => '22.22',
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
'LineItems' => [
0 => [
"taxid" => "33x1",
'productid'=>'14x6',
'listprice'=>'20.53',
'quantity'=>'3',
'comment' => "Product123"
]
]
Webservices in Vtiger are not complete.
In this case you can register your own webservice that makes your queries, or check the SalesOrder in the after-save event
I'm starting a migration from Laravel 4.2 to Laravel 5.5 and am starting with my customized config files.
One of my config files needs to know the request method being used (GET,POST,DELETE,PUT) and in laravel 4.2 I just simple used this command:
if (Request::isMethod('POST')) {
* do stuff *
}
In Laravel 5.5, it throws an error:
Class 'Request' not found {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Class 'Request' not found at /vagrant/config/api.php:8)
I added:
use Illuminate\Http\Request;
Then tried changing the code to:
if ($request->isMethod('POST')) {
* do stuff *
}
and then I get this:
Call to a member function method() on null {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to a member function method() on null at /vagrant/config/api.php:4)
I also tried putting use Illuminate\Http\Request into the default controller, thinking that it's likely I can't put the use statement in the config file, but still no joy.
Can anyone give me a hand?
Here is an example of the config file:
if (Request::isMethod('POST')) {
$methodArray = [
'endpoint1' => [
'param1' => 'value1',
'param2' => 'value2',
]
],[
'endpoint2' => [
'param1' => 'value1',
'param2' => 'value2',
]
];
} else if (Request::isMethod('GET')) {
$methodArray = [
'endpoint3' => [
'param1' => 'value1',
'param2' => 'value2',
]
],[
'endpoint4' => [
'param1' => 'value1',
'param2' => 'value2',
]
];
}
i am trying to use BjyAuthroize with my zfcUser and doctrine 2 ORM
as the clue to bind doctrine to bjyauthorize i used
i use the module samUser
in my
however i am getting the following error messages;
Uncaught exception
'Zend\ServiceManager\Exception\ServiceNotFoundException' with message
'Zend\ServiceManager\ServiceManager::get was unable to fetch or create
an instance for My\Doctrine\Common\Persistence\ObjectManager' in
C:\wamp\www\testChat\vendor\zendframework\zend-servicemanager\src\ServiceManager.php
in my config authoload bjyauthorize.global.php file
return [
'bjyauthorize' => [
// set the 'guest' role as default (must be defined in a role provider)
'default_role' => 'guest',
/* this module uses a meta-role that inherits from any roles that should
* be applied to the active user. the identity provider tells us which
* roles the "identity role" should inherit from.
* for ZfcUser, this will be your default identity provider
*/
'identity_provider' => \BjyAuthorize\Provider\Identity\ZfcUserZendDb::class,
/* If you only have a default role and an authenticated role, you can
* use the 'AuthenticationIdentityProvider' to allow/restrict access
* with the guards based on the state 'logged in' and 'not logged in'.
*
* 'default_role' => 'guest', // not authenticated
* 'authenticated_role' => 'user', // authenticated
* 'identity_provider' => \BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider::class,
*/
/* role providers simply provide a list of roles that should be inserted
* into the Zend\Acl instance. the module comes with two providers, one
* to specify roles in a config file and one to load roles using a
* Zend\Db adapter.
*/
'role_providers' => [
/* here, 'guest' and 'user are defined as top-level roles, with
* 'admin' inheriting from user
*/
\BjyAuthorize\Provider\Role\Config::class => [
'guest' => [],
'user' => ['children' => [
'admin' => [],
]],
],
// this will load roles from the user_role table in a database
// format: user_role(role_id(varchar], parent(varchar))
\BjyAuthorize\Provider\Role\ZendDb::class => [
'table' => 'user_role',
'identifier_field_name' => 'id',
'role_id_field' => 'role_id',
'parent_role_field' => 'parent_id',
],
// this will load roles from
// the 'BjyAuthorize\Provider\Role\ObjectRepositoryProvider' service
\BjyAuthorize\Provider\Role\ObjectRepositoryProvider::class => [
// class name of the entity representing the role
'role_entity_class' => 'My\Role\Entity',
// service name of the object manager
'object_manager' => 'My\Doctrine\Common\Persistence\ObjectManager',
],
],
// resource providers provide a list of resources that will be tracked
// in the ACL. like roles, they can be hierarchical
'resource_providers' => [
\BjyAuthorize\Provider\Resource\Config::class => [
'pants' => [],
],
],
/* rules can be specified here with the format:
* [roles (array], resource, [privilege (array|string], assertion])
* assertions will be loaded using the service manager and must implement
* Zend\Acl\Assertion\AssertionInterface.
* *if you use assertions, define them using the service manager!*
*/
'rule_providers' => [
\BjyAuthorize\Provider\Rule\Config::class => [
'allow' => [
// allow guests and users (and admins, through inheritance)
// the "wear" privilege on the resource "pants"
[['guest', 'user'], 'pants', 'wear'],
],
// Don't mix allow/deny rules if you are using role inheritance.
// There are some weird bugs.
'deny' => [
// ...
],
],
],
/* Currently, only controller and route guards exist
*
* Consider enabling either the controller or the route guard depending on your needs.
*/
'guards' => [
/* If this guard is specified here (i.e. it is enabled], it will block
* access to all controllers and actions unless they are specified here.
* You may omit the 'action' index to allow access to the entire controller
*/
\BjyAuthorize\Guard\Controller::class => [
['controller' => 'index', 'action' => 'index', 'roles' => ['guest','user']],
['controller' => 'index', 'action' => 'stuff', 'roles' => ['user']],
// You can also specify an array of actions or an array of controllers (or both)
// allow "guest" and "admin" to access actions "list" and "manage" on these "index",
// "static" and "console" controllers
[
'controller' => ['index', 'static', 'console'],
'action' => ['list', 'manage'],
'roles' => ['guest', 'admin'],
],
[
'controller' => ['search', 'administration'],
'roles' => ['staffer', 'admin'],
],
['controller' => 'zfcuser', 'roles' => []],
// Below is the default index action used by the ZendSkeletonApplication
// ['controller' => 'Application\Controller\Index', 'roles' => ['guest', 'user']],
],
/* If this guard is specified here (i.e. it is enabled], it will block
* access to all routes unless they are specified here.
*/
\BjyAuthorize\Guard\Route::class => [
['route' => 'zfcuser', 'roles' => ['user']],
['route' => 'zfcuser/logout', 'roles' => ['user']],
['route' => 'zfcuser/login', 'roles' => ['guest']],
['route' => 'zfcuser/register', 'roles' => ['guest']],
// Below is the default index action used by the ZendSkeletonApplication
['route' => 'home', 'roles' => ['guest', 'user']],
],
],
],
];
My\Doctrine\Common\Persistence\ObjectManager is just a placeholder for whatever service you will use.
Where you write you are using Doctrine, you need to specify whatever your object manager is called.
For example, you could probably use
doctrine.entitymanager.orm_default
Once you fix this, you will probably notice that you have other placeholders in there too. For example, My\Role\Entity.
I recommend you take a good look at:
https://github.com/bjyoungblood/BjyAuthorize
Good luck! This at least, will fix your object manager naming issue.