Skip to content

Commit

Permalink
Add and clean up test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtompset committed Aug 16, 2023
1 parent e9becb1 commit c5c32e4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
14 changes: 10 additions & 4 deletions SilMock/Google/Service/Directory/Resource/TwoStepVerification.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ public function __construct(string $dbFile = '')
* NOTE: This doesn't need to work. It just needs to exist.
*
* @param $userKey
* @param $optParams
* @param array $optParams
* @return void
*/
public function turnOff($userKey, $optParams = [])
{
// Confirm verification codes exist.
// Grab the corresponding twoStepVerification record.
$sqliteUtils = $this->getSqliteUtils();
$twoStepVerificationRecord = $sqliteUtils->getAllRecordsByDataKey(
$this->dataType,
$this->dataClass,
'twoStepVerification',
$userKey
);
$recordId = $twoStepVerificationRecord['id'];
// Update it
$twoStepVerificationRecord['onOrOff'] = 'off';
$sqliteUtils->updateRecordById($recordId, json_encode($twoStepVerificationRecord));
// Get the record id and update it, as needed.
$recordId = $twoStepVerificationRecord['id'];
// 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));
}
}
}
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()
)
);
}
}
}

0 comments on commit c5c32e4

Please sign in to comment.