-
Notifications
You must be signed in to change notification settings - Fork 1
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 #27 from silinternational/develop
Release 0.7.0
- Loading branch information
Showing
6 changed files
with
106 additions
and
23 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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
nbproject/ | ||
.DS_Store | ||
vendor/ | ||
*.local.php | ||
build/ | ||
.vagrant/ | ||
.idea/ | ||
composer.phar | ||
*.db | ||
nbproject/ | ||
.DS_Store | ||
vendor/ | ||
*.local.php | ||
build/ | ||
.vagrant/ | ||
.idea/ | ||
composer.phar | ||
*.db | ||
.phpunit.result.cache |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
it-now: clean install phpunit | ||
it-now: clean install test | ||
|
||
clean: | ||
sudo rm -rf ./vendor | ||
rm -f composer.lock | ||
docker-compose kill | ||
docker system prune -f | ||
|
||
install: | ||
docker-compose run --rm cli bash -c "cd /data;composer install" | ||
docker-compose run --rm cli bash -c "composer install" | ||
|
||
update: | ||
docker-compose run --rm cli bash -c "cd /data;composer update" | ||
docker-compose run --rm cli bash -c "composer update" | ||
|
||
phpunit: | ||
docker-compose run --rm cli bash -c "cd /data/SilMock/tests;./phpunit" | ||
|
||
# For use in virtualbox. | ||
test: | ||
docker-compose run --rm cli bash -c "cd /data/SilMock/tests; ./phpunit" | ||
|
||
# For use in a Vagrant VM: | ||
vagrantTest: | ||
cd /var/lib/GA_mock/SilMock/tests; /var/lib/GA_mock/SilMock/tests/phpunit |
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
77 changes: 77 additions & 0 deletions
77
SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php
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,77 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\Assert; | ||
use SilMock\Google\Service\Gmail\Resource\UsersSettingsDelegates; | ||
use SilMock\Google\Service\GoogleFixtures; | ||
|
||
class UsersSettingsDelegatesTest extends PHPUnit\Framework\TestCase | ||
{ | ||
public $dataFile = DATAFILE4; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->emptyFixturesDataFile(); | ||
} | ||
|
||
private function emptyFixturesDataFile() | ||
{ | ||
$fixturesClass = new GoogleFixtures($this->dataFile); | ||
$fixturesClass->removeAllFixtures(); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->emptyFixturesDataFile(); | ||
} | ||
|
||
public function testListUsersSettingsDelegates() | ||
{ | ||
// Arrange: | ||
$accountEmail = '[email protected]'; | ||
$delegateEmail = '[email protected]'; | ||
|
||
// Act | ||
$before = $this->getDelegatesForAccount($accountEmail); | ||
$this->delegateAccessToAccountBy($accountEmail, $delegateEmail); | ||
$after = $this->getDelegatesForAccount($accountEmail); | ||
|
||
// Assert: | ||
$delegatesBefore = $before->getDelegates(); | ||
Assert::assertEmpty($delegatesBefore); | ||
|
||
$delegatesAfter = $after->getDelegates(); | ||
Assert::assertNotEmpty($delegatesAfter); | ||
|
||
$foundExpectedDelegate = false; | ||
foreach ($delegatesAfter as $delegate) { | ||
if ($delegate->delegateEmail === $delegateEmail) { | ||
$foundExpectedDelegate = true; | ||
break; | ||
} | ||
} | ||
Assert::assertTrue($foundExpectedDelegate, sprintf( | ||
'Did not find %s in %s', | ||
$delegateEmail, | ||
json_encode($delegatesAfter) | ||
)); | ||
} | ||
|
||
private function delegateAccessToAccountBy( | ||
string $accountEmail, | ||
string $delegateEmail | ||
) { | ||
$gmailDelegate = new Google_Service_Gmail_Delegate(); | ||
$gmailDelegate->setDelegateEmail($delegateEmail); | ||
$userSettingsDelegates = new UsersSettingsDelegates($this->dataFile); | ||
$userSettingsDelegates->create( | ||
$accountEmail, | ||
$gmailDelegate | ||
); | ||
} | ||
|
||
private function getDelegatesForAccount(string $emailAddress) | ||
{ | ||
$userSettingsDelegates = new UsersSettingsDelegates($this->dataFile); | ||
return $userSettingsDelegates->listUsersSettingsDelegates($emailAddress); | ||
} | ||
} |
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