Skip to content

Commit d022fd7

Browse files
Improve the tests and prepare release 4.1.0 (#106)
* 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
1 parent fd08eb7 commit d022fd7

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## Unreleased
44

5+
## 4.1.0 (2021-02-26)
6+
57
* **Specification override** Fix some `timestamp` from integer to mixed string and integer to support old messages
8+
* **Specification override** Change some `latest` / `oldest` / `ts_from` / `ts_to` query parameters from integer to string
9+
* Improve carbon footprint by removing unnecessary files from git export
610

711
## 4.0.0 (2020-12-28)
812

src/Checker/JsonSorter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function sort(string $content, bool $prettyPrint = true): string
2121
$content = $this->mergeNodes($content);
2222
$content = $this->recursiveAlphabeticalSort($content);
2323

24-
return json_encode($content, $prettyPrint ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : JSON_UNESCAPED_SLASHES);
24+
return json_encode($content, $prettyPrint ? \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES : \JSON_UNESCAPED_SLASHES);
2525
}
2626

2727
public function recursiveAlphabeticalSort($item)
@@ -44,7 +44,7 @@ public function recursiveAlphabeticalSort($item)
4444
}
4545

4646
$item = $asArray;
47-
ksort($item, SORT_STRING);
47+
ksort($item, \SORT_STRING);
4848

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

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

6464
return $item;

tests/ReadingTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525

2626
class ReadingTest extends TestCase
2727
{
28+
protected function setUp(): void
29+
{
30+
if (!\array_key_exists('SLACK_TOKEN', $_SERVER)) {
31+
$this->markTestSkipped('SLACK_TOKEN env var not present, skip the test.');
32+
}
33+
}
34+
2835
public function testItWorksOnTestSuccess()
2936
{
3037
$client = ClientFactory::create('');
@@ -74,15 +81,26 @@ public function testItCanReadAConversationHistory()
7481

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

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

89+
$hadAFileMessage = false;
8190
foreach ($results->getMessages() as $message) {
8291
if ($message->getFiles()) {
92+
$hadAFileMessage = true;
8393
self::assertInstanceOf(ObjsFile::class, $message->getFiles()[0]);
94+
95+
if (method_exists($this, 'assertIsString')) {
96+
self::assertIsString($message->getTs());
97+
} else {
98+
self::assertInternalType('string', $message->getTs());
99+
}
84100
}
85101
}
102+
103+
$this->assertTrue($hadAFileMessage, 'We expect a message in File in the history, cf \JoliCode\Slack\Tests\WritingTest::testItCanUploadFile');
86104
}
87105

88106
public function testItCanGetTheImList()

tests/UserInfoTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
class UserInfoTest extends TestCase
2121
{
22+
protected function setUp(): void
23+
{
24+
if (!\array_key_exists('SLACK_TOKEN', $_SERVER)) {
25+
$this->markTestSkipped('SLACK_TOKEN env var not present, skip the test.');
26+
}
27+
}
28+
2229
public function testItCanFetchUserInfo()
2330
{
2431
$client = ClientFactory::create($_SERVER['SLACK_TOKEN']);

tests/WritingTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121

2222
class WritingTest extends TestCase
2323
{
24+
protected function setUp(): void
25+
{
26+
if (!\array_key_exists('SLACK_TOKEN', $_SERVER)) {
27+
$this->markTestSkipped('SLACK_TOKEN env var not present, skip the test.');
28+
}
29+
}
30+
2431
public function testItCanPostAttachment()
2532
{
2633
$client = ClientFactory::create($_SERVER['SLACK_TOKEN']);

0 commit comments

Comments
 (0)