-
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 branch 'develop' of github.com:silinternational/google-api-php-…
…client-mock into feature/api-client-restart-2023-07-12
- Loading branch information
Showing
5 changed files
with
121 additions
and
44 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
43 changes: 43 additions & 0 deletions
43
SilMock/Google/Service/Directory/Resource/TwoStepVerification.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,43 @@ | ||
<?php | ||
|
||
namespace SilMock\Google\Service\Directory\Resource; | ||
|
||
use SilMock\Google\Service\DbClass; | ||
|
||
class TwoStepVerification extends dbClass | ||
{ | ||
public function __construct(string $dbFile = '') | ||
{ | ||
parent::__construct($dbFile, 'directory', 'twoStepVerification'); | ||
} | ||
|
||
/** | ||
* Turn off 2SV for a given email account. | ||
* | ||
* NOTE: This doesn't need to work. It just needs to exist. | ||
* | ||
* @param $userKey | ||
* @param array $optParams | ||
* @return void | ||
*/ | ||
public function turnOff($userKey, $optParams = []) | ||
{ | ||
// Grab the corresponding twoStepVerification record. | ||
$sqliteUtils = $this->getSqliteUtils(); | ||
$twoStepVerificationRecord = $sqliteUtils->getAllRecordsByDataKey( | ||
$this->dataType, | ||
$this->dataClass, | ||
'twoStepVerification', | ||
$userKey | ||
); | ||
// Update it | ||
$twoStepVerificationRecord['onOrOff'] = 'off'; | ||
// Get the record id and update it, as needed. | ||
$recordId = $twoStepVerificationRecord['id'] ?? null; | ||
// If there was a recordId, then it probably would be functional | ||
// However, we just need this method to exist, not actually work | ||
if (! empty($recordId)) { | ||
$sqliteUtils->updateRecordById($recordId, json_encode($twoStepVerificationRecord)); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
SilMock/tests/Google/Service/Directory/Resource/TwoStepVerificationTest.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,30 @@ | ||
<?php | ||
|
||
namespace Service\Directory\Resource; | ||
|
||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
use SilMock\Google\Service\Directory\Resource\TwoStepVerification; | ||
|
||
class TwoStepVerificationTest extends TestCase | ||
{ | ||
public $dataFile = DATAFILE2; | ||
|
||
public function testTwoStepVerificationTurnOff() | ||
{ | ||
$twoStepVerfication = new TwoStepVerification($this->dataFile); | ||
$this->assertIsObject($twoStepVerfication, 'Unable to instantiate twoStepVerification Mock object'); | ||
|
||
try { | ||
$twoStepVerfication->turnOff('[email protected]'); | ||
} catch (Exception $exception) { | ||
$this->assertFalse( | ||
true, | ||
sprintf( | ||
'Was expecting the turnOff method to function, but got: %s', | ||
$exception->getMessage() | ||
) | ||
); | ||
} | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.