-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the PHPFUI\ConstantContact package | ||
* | ||
* (c) Bruce Wells | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source | ||
* code | ||
*/ | ||
class FactoryTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testSetFactory() : void | ||
{ | ||
$this->assertNull(\PHPFUI\ConstantContact\Client::getGuzzleFactory()); | ||
$callable = [GrahamCampbell\GuzzleFactory\GuzzleFactory::class, 'make']; | ||
\PHPFUI\ConstantContact\Client::setGuzzleFactory($callable); | ||
$this->assertEquals($callable, \PHPFUI\ConstantContact\Client::getGuzzleFactory()); | ||
\PHPFUI\ConstantContact\Client::setGuzzleFactory(null); | ||
$client = new \PHPFUI\ConstantContact\Client('clientAPIKey', 'clientSecret', 'redirectURI'); | ||
$guzzle = $client->getGuzzleClient('body', ['header1' => 'HEADER1']); | ||
$this->assertTrue($guzzle instanceof \GuzzleHttp\Client); | ||
$config = $guzzle->getConfig('body'); | ||
$this->assertEquals('body', $config); | ||
$config = $guzzle->getConfig('headers'); | ||
$this->assertIsArray($config); | ||
$this->assertArrayHasKey('header1', $config); | ||
$this->assertContains('HEADER1', $config); | ||
$this->assertArrayHasKey('Cache-Control', $config); | ||
\PHPFUI\ConstantContact\Client::setGuzzleFactory($callable); | ||
$guzzle = $client->getGuzzleClient('body', ['header1' => 'HEADER1']); | ||
$this->assertTrue($guzzle instanceof \GuzzleHttp\Client); | ||
$config = $guzzle->getConfig('body'); | ||
$this->assertEquals('body', $config); | ||
$config = $guzzle->getConfig('headers'); | ||
$this->assertIsArray($config); | ||
$this->assertArrayHasKey('header1', $config); | ||
$this->assertContains('HEADER1', $config); | ||
$this->assertArrayHasKey('Cache-Control', $config); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -67,8 +67,8 @@ public function testHydration() : void | |
$this->assertEquals('[email protected]', $contacts->contacts[0]->email_address->address); | ||
$this->assertEquals('[email protected]', $contacts->contacts[1]->email_address->address); | ||
$time = new \PHPFUI\ConstantContact\DateTime("2024-11-08T10:54:32Z"); | ||
$this->assertEquals("{$time}", "{$contacts->contacts[0]->created_at}"); | ||
$this->assertEquals("{$time}", "{$contacts->contacts[1]->created_at}"); | ||
$this->assertEquals((string)$time, (string)$contacts->contacts[0]->created_at); | ||
$this->assertEquals((string)$time, (string)$contacts->contacts[1]->created_at); | ||
$newJson = $contacts->getJSON(); | ||
$this->assertJson($newJson); | ||
$newDataArray = $contacts->toArray(); | ||
|
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