Browse Source

[ADD] Example static mocking test

tags/v1.8.2.4
Adam Bukowski 4 years ago
parent
commit
f0e8e06b30
1 changed files with 32 additions and 0 deletions
  1. +32
    -0
      tests/unit/StaticMockExampleTest.php

+ 32
- 0
tests/unit/StaticMockExampleTest.php View File

@@ -0,0 +1,32 @@
<?php

use AspectMock\Test;

class StaticMockExampleTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;

protected function _before()
{
}

protected function _after()
{
}

// tests
public function testExample()
{
$aclMock = Test::double('Acl', ['get_user' => 'user']);
$contactMock = Test::double('CRM_ContactsCommon', ['get_contact_by_user_id' => 'my_contact']);

$record = \CRM_ContactsCommon::get_my_record();
$this->assertEquals($record, 'my_contact');

$aclMock->verifyInvokedOnce('get_user');
$contactMock->verifyInvoked('get_contact_by_user_id', ['user']);
}
}

Loading…
Cancel
Save