I am trying to build a test with PHPUnit to test my Braintree hook. I have this test case which uses the dataProvider below:
/**
* @covers SubscriptionExpiredHook::processHook()
* @dataProvider dataProvider
*/
public function testProcessHook($subscriptionId)
{
$subscriptionExpiredHook = new SubscriptionExpiredHook($this->siteManager);
$notification = $this->getMockBuilder('Braintree\WebhookNotification')
->disableOriginalConstructor()
->getMock();
$notification->subscription->id = $subscriptionId;
$router = $this->getRouterMock();
$subscriptionExpiredHook->setSubscription(new Subscription($router));
$response = $subscriptionExpiredHook->processHook($notification);
$this->assertEquals(200, $response->getStatusCode());
}
public function dataProvider()
{
return [
[
'subscription_id' => 'CRM1872',
]
];
}
The line that is causing the problem is this:
$subscriptionId = $hook->subscription->id;
...and this is the error I get when I run the test:
1) CRMPiccoBundle\Tests\Braintree\Hooks\SubscriptionExpiredHookTest::testProcessHook with data set #0 ('CRM1872') Indirect modification of overloaded property Mock_WebhookNotification_e65192ec::$subscription has no effect
Is there a way that I can set the subscription id to allow this test to proceed or am I looking at it the wrong way?
Aucun commentaire:
Enregistrer un commentaire