From e656a91dc5194041c4747d78cb3baf369aa8b019 Mon Sep 17 00:00:00 2001 From: Joshua Piper <32164094+JoshPiper@users.noreply.github.com> Date: Sat, 28 Nov 2020 14:08:20 +0000 Subject: [PATCH 1/2] Add ISteamRemoteStorage/Get{Collection,PublishedFile}Details classes. --- .../RemoteStorage/GetCollectionDetails.php | 54 +++++++++++++++++++ .../RemoteStorage/GetPublishedFileDetails.php | 54 +++++++++++++++++++ .../Command/RemoteStorage/RemoteStorage.php | 22 ++++++++ 3 files changed, 130 insertions(+) create mode 100644 src/Steam/Command/RemoteStorage/GetCollectionDetails.php create mode 100644 src/Steam/Command/RemoteStorage/GetPublishedFileDetails.php create mode 100644 src/Steam/Command/RemoteStorage/RemoteStorage.php diff --git a/src/Steam/Command/RemoteStorage/GetCollectionDetails.php b/src/Steam/Command/RemoteStorage/GetCollectionDetails.php new file mode 100644 index 0000000..2f4283f --- /dev/null +++ b/src/Steam/Command/RemoteStorage/GetCollectionDetails.php @@ -0,0 +1,54 @@ +collectionIds = $collectionIds; + } + } + + /** + * Add a new collection ID to the query list. + * @param integer $collectionId + */ + public function addCollectionID($collectionId){ + $this->collectionIds[] = $collectionId; + } + + /** + * @inheritDoc + */ + public function getMethod(){ + return 'GetCollectionDetails'; + } + + /** + * @inheritDoc + */ + public function getRequestMethod(){ + return 'POST'; + } + + /** + * @inheritDoc + */ + public function getParams(){ + $params = [ + 'collectioncount' => count($this->collectionIds), + ]; + foreach ($this->collectionIds as $idx => $collection_id){ + $params["publishedfileids[{$idx}]"] = $collection_id; + } + return $params; + } +} diff --git a/src/Steam/Command/RemoteStorage/GetPublishedFileDetails.php b/src/Steam/Command/RemoteStorage/GetPublishedFileDetails.php new file mode 100644 index 0000000..5cedd2b --- /dev/null +++ b/src/Steam/Command/RemoteStorage/GetPublishedFileDetails.php @@ -0,0 +1,54 @@ +fileIds = $fileIds; + } + } + + /** + * Add a new file ID to the query list. + * @param integer $fileId + */ + public function addFileID($fileId){ + $this->fileIds[] = $fileId; + } + + /** + * @inheritDoc + */ + public function getMethod(){ + return 'GetPublishedFileDetails'; + } + + /** + * @inheritDoc + */ + public function getRequestMethod(){ + return 'POST'; + } + + /** + * @inheritDoc + */ + public function getParams(){ + $params = [ + 'itemcount' => count($this->fileIds), + ]; + foreach ($this->fileIds as $idx => $file_id){ + $params["publishedfileids[{$idx}]"] = $file_id; + } + return $params; + } +} diff --git a/src/Steam/Command/RemoteStorage/RemoteStorage.php b/src/Steam/Command/RemoteStorage/RemoteStorage.php new file mode 100644 index 0000000..7e49d05 --- /dev/null +++ b/src/Steam/Command/RemoteStorage/RemoteStorage.php @@ -0,0 +1,22 @@ + Date: Sat, 28 Nov 2020 14:13:16 +0000 Subject: [PATCH 2/2] Add the tests. --- .../GetCollectionDetailsTest.php | 50 +++++++++++++++++++ .../GetPublishedFileDetailsTest.php | 50 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 tests/src/Steam/Command/RemoteStorage/GetCollectionDetailsTest.php create mode 100644 tests/src/Steam/Command/RemoteStorage/GetPublishedFileDetailsTest.php diff --git a/tests/src/Steam/Command/RemoteStorage/GetCollectionDetailsTest.php b/tests/src/Steam/Command/RemoteStorage/GetCollectionDetailsTest.php new file mode 100644 index 0000000..be0e9c5 --- /dev/null +++ b/tests/src/Steam/Command/RemoteStorage/GetCollectionDetailsTest.php @@ -0,0 +1,50 @@ +instance = new GetCollectionDetails(); + } + + public function testImplementsInterface() + { + $this->assertTrue($this->instance instanceof CommandInterface); + } + + public function testValues() + { + $this->assertEquals('ISteamRemoteStorage', $this->instance->getInterface()); + $this->assertEquals('GetCollectionDetails', $this->instance->getMethod()); + $this->assertEquals('v1', $this->instance->getVersion()); + $this->assertEquals('POST', $this->instance->getRequestMethod()); + $this->assertEquals([ + 'collectioncount' => 0 + ], $this->instance->getParams()); + } + + public function testAddingCollectionID() + { + $this->instance->addCollectionID(1234); + $this->assertParams([ + 'collectioncount' => 1, + 'publishedfileids[0]' => 1234 + ]); + } + + public function assertParams($params) + { + $this->assertEquals(array_merge([ + 'collectioncount' => 0 + ], $params), $this->instance->getParams()); + } +} diff --git a/tests/src/Steam/Command/RemoteStorage/GetPublishedFileDetailsTest.php b/tests/src/Steam/Command/RemoteStorage/GetPublishedFileDetailsTest.php new file mode 100644 index 0000000..812d9a1 --- /dev/null +++ b/tests/src/Steam/Command/RemoteStorage/GetPublishedFileDetailsTest.php @@ -0,0 +1,50 @@ +instance = new GetPublishedFileDetails(); + } + + public function testImplementsInterface() + { + $this->assertTrue($this->instance instanceof CommandInterface); + } + + public function testValues() + { + $this->assertEquals('ISteamRemoteStorage', $this->instance->getInterface()); + $this->assertEquals('GetPublishedFileDetails', $this->instance->getMethod()); + $this->assertEquals('v1', $this->instance->getVersion()); + $this->assertEquals('POST', $this->instance->getRequestMethod()); + $this->assertEquals([ + 'itemcount' => 0 + ], $this->instance->getParams()); + } + + public function testAddingFileID() + { + $this->instance->addFileID(1234); + $this->assertParams([ + 'itemcount' => 1, + 'publishedfileids[0]' => 1234 + ]); + } + + public function assertParams($params) + { + $this->assertEquals(array_merge([ + 'itemcount' => 0 + ], $params), $this->instance->getParams()); + } +}