Skip to content

Commit

Permalink
Merge pull request #118 from johnzuk/fix/missing-set-session
Browse files Browse the repository at this point in the history
Add missing setSessionId for cache purpose #117
  • Loading branch information
johnzuk authored Jan 2, 2023
2 parents 2c1ba02 + a5304e4 commit 0f8fd91
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ jobs:
name: Composer validation
runs-on: ubuntu-20.04

strategy:
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.php }}

- name: Execute composer validate
run: composer validate --strict
Expand All @@ -25,14 +29,18 @@ jobs:
name: PHPCs
runs-on: ubuntu-20.04

strategy:
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.php }}

- name: Install Dependencies
uses: nick-invision/retry@v1
Expand All @@ -44,19 +52,22 @@ jobs:
- name: Execute PHPCs
run: vendor/bin/phpcs src tests


phpstan:
name: PHPStan
runs-on: ubuntu-20.04

strategy:
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.php }}

- name: Install Dependencies
uses: nick-invision/retry@v1
Expand Down
2 changes: 0 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ GusApi

* The `GusApi::setUserKey` has been removed.

* The `GusApi::setSessionId` has been removed.

* The `GusApi::getResultSearchMessage` has been removed.

ReportTypes
Expand Down
5 changes: 5 additions & 0 deletions src/GusApi/GusApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public function getSessionId(): string
return $this->sessionId;
}

public function setSessionId(string $sessionId): void
{
$this->sessionId = $sessionId;
}

/**
* @throws InvalidUserKeyException
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/GusApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public function testLoginWillSetSessionId(): void
self::assertSame('12sessionid21', $this->api->getSessionId());
}

public function testSetSessionIdWillSetSession(): void
{
$this->api->setSessionId("12sessionid21");
$this->mockApiClientGetValueCall('StatusSesji', '1');
self::assertTrue($this->api->isLogged());
}

public function testGetSessionIdFailsWhenNotLoggedIn(): void
{
$this->expectException(BadMethodCallException::class);
Expand Down Expand Up @@ -306,6 +313,11 @@ public function testGetSessionStatus(): void
private function expectGetValueCall(string $parameter, string $value): void
{
$this->loginApiWithSessionId('12sessionid21');
$this->mockApiClientGetValueCall($parameter, $value);
}

private function mockApiClientGetValueCall(string $parameter, string $value): void
{
$this->apiClient
->expects(self::once())
->method('getValue')
Expand Down

0 comments on commit 0f8fd91

Please sign in to comment.