Skip to content

Commit

Permalink
Merge pull request #79 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 2.1.0 - Add `members->insert()` mock
  • Loading branch information
forevermatt authored Apr 11, 2024
2 parents 0b4c6e8 + 9a62002 commit b0b2ee1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions SilMock/Google/Service/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilMock\Google\Service;

use SilMock\Google\Service\Directory\Asps;
use SilMock\Google\Service\Directory\Members;
use SilMock\Google\Service\Directory\Tokens;
use SilMock\Google\Service\Directory\UsersResource;
use SilMock\Google\Service\Directory\UsersAliasesResource;
Expand All @@ -12,6 +13,7 @@
class Directory
{
public $asps;
public Members $members;
public $tokens;
public $users;
public $users_aliases;
Expand All @@ -28,6 +30,7 @@ class Directory
public function __construct($client, $dbFile = null)
{
$this->asps = new Asps($dbFile);
$this->members = new Members($dbFile);
$this->tokens = new Tokens($dbFile);
$this->users = new UsersResource($dbFile);
$this->users_aliases = new UsersAliasesResource($dbFile);
Expand Down
37 changes: 37 additions & 0 deletions SilMock/Google/Service/Directory/Members.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace SilMock\Google\Service\Directory;

use Exception;
use Google\Service\Directory\Member;
use SilMock\Google\Service\DbClass;

class Members extends DbClass
{
public function __construct($dbFile = null)
{
parent::__construct($dbFile, 'directory', 'members');
}

/**
* @throws Exception
*/
public function insert(string $groupKey, Member $postBody)
{
$dataAsJson = json_encode([
'groupKey' => $groupKey,
'member' => get_object_vars($postBody),
]);
$sqliteUtils = $this->getSqliteUtils();
$sqliteUtils->recordData(
$this->dataType,
$this->dataClass,
$dataAsJson
);

$newMember = new Member();
ObjectUtils::initialize($newMember, $postBody);

return $newMember;
}
}

0 comments on commit b0b2ee1

Please sign in to comment.