Skip to content

Instantly share code, notes, and snippets.

@MarkLL
Last active January 23, 2017 11:24
Show Gist options
  • Save MarkLL/71db98b6522487286226bfea5ad0dcc0 to your computer and use it in GitHub Desktop.
Save MarkLL/71db98b6522487286226bfea5ad0dcc0 to your computer and use it in GitHub Desktop.
Testing results

Asumming you have enable BasicAuth in your MAutic server and ...

Make sure you have the correct MauticApiTestCase that has:

protected function getAuth()
{
  $this->config = include __DIR__.'/../local.config.php';
  $authMethod   = isset($this->config['AuthMethod']) ? $this->config['AuthMethod'] : 'OAuth';
  
  $apiAuth = new ApiAuth();
  $auth = $apiAuth->newAuth($this->config, $authMethod );

as this is where the AuthMethod field is used. In the real world, you would instantiate an auth instance like:

$settings = array(
      'userName'   => '',             // Create a new user       
      'password'   => '',             // Make it a secure password
  );
  
  // Initiate the auth object specifying to use BasicAuth
  $apiAuth = new ApiAuth();
  $auth = $apiAuth->newAuth($settings, 'BasicAuth');

Basic Authentication

for basicAuth test, this is the test config I use.

local.config.php

<?php
return array(
    'AuthMethod' => 'BasicAuth',
    'userName'   => 'admin',
    'password'   => 'password',
    'baseUrl'    => 'http://mautic-test.dev',
    'callback'   => 'http://mautic-api.dev/',
    'apiUrl'     => 'http://mautic-test.dev/api/',
    'testEmail'  => 'notexisting@email.com',
);

Result of BasicAuth tests:

C:\MarkLL\api-library>phpunit -v
PHPUnit 4.7.3 by Sebastian Bergmann and contributors.

Runtime:        PHP 7.0.13
Configuration:  C:\MarkLL\api-library\phpunit.xml

..............................................................  62 / 214 ( 28%)
.............................................................. 124 / 214 ( 57%)
.............................................................. 186 / 214 ( 86%)
............................

Time: 19.65 minutes, Memory: 14.00Mb

OK (214 tests, 1985 assertions)

OAuth2 Authentication

local.config.php

<?php
return array(
    'AuthMethod'   => 'OAuth',
    'version'      => 'OAuth2',
    'clientKey'    => '2_310evwm7wqioxxxxxxxxxxxxxxxxok0s8wo84sg0ccgk4',
    'clientSecret' => '4bxr5oadc0ow800zzzzzzzzzzzz8okkg4og4w00g',
    'accessToken'  => 'ZmFjODFjNWM5MzM3YTU2OTcyZsssssssssssssssssN2Q1MjdmOTI4NzUwZThhMWYyNg',
    'refreshToken' => 'MjI2ODUzNDkwYTBhMDNhNjgggggggggggE3YzU4M2RmZWI5ZQ'
    'baseUrl'      => 'http://mautic-test.dev',
    'callback'     => 'http://mautic-api.dev/',
    'apiUrl'       => 'http://mautic-test.dev/api/',
    'testEmail'    => 'notexisting@email.com',
);

Result of OAuth2 tests:

C:\Test\MarkLL\api-library>phpunit -v
PHPUnit 4.7.3 by Sebastian Bergmann and contributors.

Runtime:        PHP 7.0.13
Configuration:  C:\MarkLL\api-library\phpunit.xml

..............................................................  62 / 214 ( 28%)
.............................................................. 124 / 214 ( 57%)
.............................................................. 186 / 214 ( 86%)
............................

Time: 13.81 minutes, Memory: 14.00Mb

OK (214 tests, 1976 assertions)

OAuth1a Authentication

local.config.php

<?php
return array(
    'AuthMethod'        => 'OAuth',
    'version'           => 'OAuth1a',
    'clientKey'         => 'ul2fqqqqqqqqqqqqqqqqqqqqqqswko0kk4',
    'clientSecret'      => 'udkl4ocm5eok0gggggggggggggggggggsoc4og0k',
    'accessToken'       => '3npi5ujuxaaaaaaaaaaaaaaaagck8w4cgs',
    'accessTokenSecret' => '69k08o8csetttttttttttttttk4os8sow8sc',
    'baseUrl'           => 'http://mautic-test.dev',
    'callback'          => 'http://mautic-api.dev/',
    'apiUrl'            => 'http://mautic-test.dev/api/',
    'testEmail'         => 'notexisting@email.com',
);

Result of OAuth1a tests - WITH Oath1a Fix (:

C:\MarkLL\api-library>phpunit -v
PHPUnit 4.7.3 by Sebastian Bergmann and contributors.

Runtime:        PHP 7.0.13
Configuration:  C:\Test\MarkLL\api-library\phpunit.xml
              123456            7        8    9         01 2
..............FFFFFF............F........F....F.........FF.F..  62 / 214 ( 28%)
..........................FFFFFF..................FFFFFFF..... 124 / 214 ( 57%)
FF.F.............................FFFFFF.............FFFF...... 186 / 214 ( 86%)
............F..FFFFF........

..............FFFFFF............F........F....F..........F.F..  62 / 214 ( 28%)
..........................FFFFFF..................FFFFFFF..... 124 / 214 ( 57%)
.F.F.............................FFFFFF.............FFFF...... 186 / 214 ( 86%)
............F..FFFFF........

Time: 11.3 minutes, Memory: 16.00Mb

There were 44 failures:

1) Mautic\Tests\Api\CampaignsTest::testGetListOfSpecificIds
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:75
C:\Test\MarkLL\api-library\tests\Api\CampaignsTest.php:199

2) Mautic\Tests\Api\CampaignsTest::testCreateGetAndDelete
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\CampaignsTest.php:205

3) Mautic\Tests\Api\CampaignsTest::testEditPatch
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\CampaignsTest.php:218

4) Mautic\Tests\Api\CampaignsTest::testEditPut
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:138
C:\Test\MarkLL\api-library\tests\Api\CampaignsTest.php:244

5) Mautic\Tests\Api\CampaignsTest::testEventAndSourceDeleteViaPut
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\CampaignsTest.php:252

6) Mautic\Tests\Api\CampaignsTest::testAddAndRemove
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\CampaignsTest.php:299

7) Mautic\Tests\Api\ContactFieldsTest::testCreateGetAndDeleteOfLookupField
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\ContactFieldsTest.php:49

8) Mautic\Tests\Api\CompanyFieldTest::testCreateGetAndDeleteOfLookupField
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\ContactFieldsTest.php:49

9) Mautic\Tests\Api\ContactFieldsTest::testCreateGetAndDeleteOfLookupField
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\ContactFieldsTest.php:49

10) Mautic\Tests\Api\ContactsTest::testGetEvents
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:34
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:126

11) Mautic\Tests\Api\ContactsTest::testGetEventsAdvanced
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:34
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:139

12) Mautic\Tests\Api\ContactsTest::testDncAddInCreate
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:172

13) Mautic\Tests\Api\EmailsTest::testGetListOfSpecificIds
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:75
C:\Test\MarkLL\api-library\tests\Api\EmailsTest.php:111

14) Mautic\Tests\Api\EmailsTest::testCreateGetAndDelete
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\EmailsTest.php:121

15) Mautic\Tests\Api\EmailsTest::testEditPatch
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\EmailsTest.php:146

16) Mautic\Tests\Api\EmailsTest::testEditPut
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\EmailsTest.php:175

17) Mautic\Tests\Api\EmailsTest::testSendToSegment
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\EmailsTest.php:213

18) Mautic\Tests\Api\EmailsTest::testSendToContact
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\EmailsTest.php:250

19) Mautic\Tests\Api\FormsTest::testGetListOfSpecificIds
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:75
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:63

20) Mautic\Tests\Api\FormsTest::testCreateGetAndDelete
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:46
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:68

21) Mautic\Tests\Api\FormsTest::testDeleteFields
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:75

22) Mautic\Tests\Api\FormsTest::testDeleteActions
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:94

23) Mautic\Tests\Api\FormsTest::testEditPatch
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:117

24) Mautic\Tests\Api\FormsTest::testEditPut
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:46
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:138
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:153

25) Mautic\Tests\Api\FormsTest::testFieldAndActionDeleteViaPut
<br />
<b>Warning</b>:  rawurlencode() expects parameter 1 to be string, array given in <b>C:\Test\MarkLL\mautic\vendor\willdurand\oauth-server-bundle\Service\OAuthAbstractServerService.php</b> on line <b>317</b><br />
{"error":{"message":"signature_invalid","code":401}}
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\FormsTest.php:160

26) Mautic\Tests\Api\LeadsTest::testGetEvents
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:34
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:126

27) Mautic\Tests\Api\LeadsTest::testGetEventsAdvanced
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:34
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:139

28) Mautic\Tests\Api\LeadsTest::testDncAddInCreate
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\ContactsTest.php:172

29) Mautic\Tests\Api\PointTriggersTest::testGetListOfSpecificIds
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:75
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:67

30) Mautic\Tests\Api\PointTriggersTest::testCreateGetAndDelete
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:52
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:72

31) Mautic\Tests\Api\PointTriggersTest::testEditPatch
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:52
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:126
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:81

32) Mautic\Tests\Api\PointTriggersTest::testEditPut
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:52
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:138
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:86

33) Mautic\Tests\Api\PointTriggersTest::testEventDeleteViaPut
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:92

34) Mautic\Tests\Api\PointTriggersTest::testDeleteEvents
Array to string conversion
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\PointTriggersTest.php:116

35) Mautic\Tests\Api\RolesTest::testGetListOfSpecificIds
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:75
C:\Test\MarkLL\api-library\tests\Api\RolesTest.php:36

36) Mautic\Tests\Api\RolesTest::testCreateGetAndDelete
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:107
C:\Test\MarkLL\api-library\tests\Api\RolesTest.php:41

37) Mautic\Tests\Api\RolesTest::testEditPatch
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:126
C:\Test\MarkLL\api-library\tests\Api\RolesTest.php:49

38) Mautic\Tests\Api\RolesTest::testEditPut
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:54
C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:138
C:\Test\MarkLL\api-library\tests\Api\RolesTest.php:54

39) Mautic\Tests\Api\StatsTest::testGetTables
Failed asserting that false is true.

C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:82

40) Mautic\Tests\Api\StatsTest::testGetOrderSimple
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:20
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:111

41) Mautic\Tests\Api\StatsTest::testGetOrderAsc
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:20
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:125

42) Mautic\Tests\Api\StatsTest::testGetOrderDesc
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:20
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:139

43) Mautic\Tests\Api\StatsTest::testGetWhereEqual
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:20
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:154

44) Mautic\Tests\Api\StatsTest::testGetWhereGreaterThan
signature_invalid
Failed asserting that true is false.

C:\Test\MarkLL\api-library\tests\Api\MauticApiTestCase.php:44
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:20
C:\Test\MarkLL\api-library\tests\Api\StatsTest.php:174

FAILURES!
Tests: 214, Assertions: 1538, Failures: 44.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment