Skip to content

Commit

Permalink
Improve the tests and prepare release 4.1.0 (#106)
Browse files Browse the repository at this point in the history
* Add a test for #105, fix CS, and skip Slack tests when misconfigured

* Prepare release 4.1.0

* Fix tests for PHP 7.2 and lowest deps compatibility
  • Loading branch information
damienalexandre authored Feb 26, 2021
1 parent fd08eb7 commit d022fd7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Unreleased

## 4.1.0 (2021-02-26)

* **Specification override** Fix some `timestamp` from integer to mixed string and integer to support old messages
* **Specification override** Change some `latest` / `oldest` / `ts_from` / `ts_to` query parameters from integer to string
* Improve carbon footprint by removing unnecessary files from git export

## 4.0.0 (2020-12-28)

Expand Down
6 changes: 3 additions & 3 deletions src/Checker/JsonSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function sort(string $content, bool $prettyPrint = true): string
$content = $this->mergeNodes($content);
$content = $this->recursiveAlphabeticalSort($content);

return json_encode($content, $prettyPrint ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : JSON_UNESCAPED_SLASHES);
return json_encode($content, $prettyPrint ? \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES : \JSON_UNESCAPED_SLASHES);
}

public function recursiveAlphabeticalSort($item)
Expand All @@ -44,7 +44,7 @@ public function recursiveAlphabeticalSort($item)
}

$item = $asArray;
ksort($item, SORT_STRING);
ksort($item, \SORT_STRING);

return $item;
} elseif (!\is_array($item)) {
Expand All @@ -58,7 +58,7 @@ public function recursiveAlphabeticalSort($item)
$types = array_unique(array_map('getType', $item));

if (1 === \count($types) && \in_array($types[0], ['string', 'int'], true)) {
sort($item, SORT_STRING);
sort($item, \SORT_STRING);
}

return $item;
Expand Down
18 changes: 18 additions & 0 deletions tests/ReadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@

class ReadingTest extends TestCase
{
protected function setUp(): void
{
if (!\array_key_exists('SLACK_TOKEN', $_SERVER)) {
$this->markTestSkipped('SLACK_TOKEN env var not present, skip the test.');
}
}

public function testItWorksOnTestSuccess()
{
$client = ClientFactory::create('');
Expand Down Expand Up @@ -74,15 +81,26 @@ public function testItCanReadAConversationHistory()

$results = $client->conversationsHistory([
'channel' => $_SERVER['SLACK_TEST_CHANNEL'],
'oldest' => (string) strtotime('10 September 2000'), // test #105
]);

self::assertInstanceOf(ConversationsHistoryGetResponse200::class, $results);

$hadAFileMessage = false;
foreach ($results->getMessages() as $message) {
if ($message->getFiles()) {
$hadAFileMessage = true;
self::assertInstanceOf(ObjsFile::class, $message->getFiles()[0]);

if (method_exists($this, 'assertIsString')) {
self::assertIsString($message->getTs());
} else {
self::assertInternalType('string', $message->getTs());
}
}
}

$this->assertTrue($hadAFileMessage, 'We expect a message in File in the history, cf \JoliCode\Slack\Tests\WritingTest::testItCanUploadFile');
}

public function testItCanGetTheImList()
Expand Down
7 changes: 7 additions & 0 deletions tests/UserInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

class UserInfoTest extends TestCase
{
protected function setUp(): void
{
if (!\array_key_exists('SLACK_TOKEN', $_SERVER)) {
$this->markTestSkipped('SLACK_TOKEN env var not present, skip the test.');
}
}

public function testItCanFetchUserInfo()
{
$client = ClientFactory::create($_SERVER['SLACK_TOKEN']);
Expand Down
7 changes: 7 additions & 0 deletions tests/WritingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@

class WritingTest extends TestCase
{
protected function setUp(): void
{
if (!\array_key_exists('SLACK_TOKEN', $_SERVER)) {
$this->markTestSkipped('SLACK_TOKEN env var not present, skip the test.');
}
}

public function testItCanPostAttachment()
{
$client = ClientFactory::create($_SERVER['SLACK_TOKEN']);
Expand Down

0 comments on commit d022fd7

Please sign in to comment.