-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from codebar-ag/feature-tickets
Feature Tickets
- Loading branch information
Showing
27 changed files
with
496 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
|
||
use CodebarAg\Zendesk\ZendeskConnector; | ||
|
||
it('will throw an exception if a subdomain is not set', closure: function () { | ||
$connector = new ZendeskConnector; | ||
$connector->resolveBaseUrl(); | ||
|
||
})->throws('No subdomain provided.', 500); | ||
|
||
it('will not throw an exception if a subdomain is set', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->resolveBaseUrl(); | ||
|
||
})->expectNotToPerformAssertions(); | ||
|
||
it('will return the base path', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$path = $connector->resolveBaseUrl(); | ||
|
||
expect($path)->toBe('https://codebarsolutionsag.zendesk.com/api/v2'); | ||
|
||
}); | ||
|
||
it('will throw an exception if an auth method is not set', closure: function () { | ||
config([ | ||
'zendesk.auth.method' => null, | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->throws('No authentication method provided.', 500); | ||
|
||
it('will throw an exception if an auth method invalid', closure: function () { | ||
config([ | ||
'zendesk.auth.method' => 'not-a-valid-method', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->throws('Invalid authentication method provided.', 500); | ||
|
||
it('will not throw an exception if an auth method valid', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => 'test-token', | ||
'zendesk.auth.password' => 'test-password', | ||
]); | ||
|
||
config([ | ||
'zendesk.auth.method' => 'token', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
config([ | ||
'zendesk.auth.method' => 'basic', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->expectNotToPerformAssertions(); | ||
|
||
it('will throw an exception if a token is not provided when using the token method', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.method' => 'token', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => null, | ||
'zendesk.auth.password' => null, | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->throws('No API token provided for token authentication.', 500); | ||
|
||
it('will not throw an exception if a token is provided when using the token method', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.method' => 'token', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => 'test-token', | ||
'zendesk.auth.password' => null, | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->expectNotToPerformAssertions(); | ||
|
||
it('will throw an exception if a password is not provided when using the basic method', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.method' => 'basic', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => null, | ||
'zendesk.auth.password' => null, | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->throws('No password provided for basic authentication.', 500); | ||
|
||
it('will not throw an exception if a password is provided when using the password method', closure: function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.method' => 'basic', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => null, | ||
'zendesk.auth.password' => 'test-password', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
$connector->setAuth(); | ||
|
||
})->expectNotToPerformAssertions(); | ||
|
||
it('will compile the correct authentication string for token method', function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.method' => 'token', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => 'test-token', | ||
'zendesk.auth.password' => null, | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
|
||
$token = $connector->setAuth(); | ||
|
||
expect($token)->toBe('[email protected]/token:test-token'); | ||
}); | ||
|
||
it('will compile the correct authentication string for basic method', function () { | ||
config([ | ||
'zendesk.subdomain' => 'codebarsolutionsag', | ||
'zendesk.auth.method' => 'basic', | ||
'zendesk.auth.email_address' => '[email protected]', | ||
'zendesk.auth.api_token' => null, | ||
'zendesk.auth.password' => 'test-password', | ||
]); | ||
|
||
$connector = new ZendeskConnector; | ||
|
||
$token = $connector->setAuth(); | ||
|
||
expect($token)->toBe('[email protected]:test-password'); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.