Skip to content

Commit 4a341e1

Browse files
tests: Use assertObjectHasProperty() (#259)
Replaces deprecated PHPUnit method assertObjectHasAttribute() with assertObjectHasProperty() added in version 9.6.11.
1 parent 4de1442 commit 4a341e1

7 files changed

Lines changed: 52 additions & 52 deletions

File tree

tests/Endpoints/ApplicationMessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testGetAll(): void
4747
$messages = self::$applicationMessage->getAll(self::$appId);
4848

4949
$this->assertIsObject($messages);
50-
$this->assertObjectHasAttribute('messages', $messages);
50+
$this->assertObjectHasProperty('messages', $messages);
5151
}
5252

5353
/**

tests/Endpoints/ApplicationTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function testCreate(): void
3232
);
3333

3434
$this->assertIsObject($created);
35-
$this->assertObjectHasAttribute('id', $created);
36-
$this->assertObjectHasAttribute('name', $created);
37-
$this->assertObjectHasAttribute('description', $created);
35+
$this->assertObjectHasProperty('id', $created);
36+
$this->assertObjectHasProperty('name', $created);
37+
$this->assertObjectHasProperty('description', $created);
3838

3939
$this->assertEquals($name, $created->name);
4040
$this->assertEquals($description, $created->description);
@@ -52,17 +52,17 @@ public function testGetAll(): void
5252
$applications = self::$application->getAll();
5353

5454
$this->assertIsObject($applications);
55-
$this->assertObjectHasAttribute('apps', $applications);
55+
$this->assertObjectHasProperty('apps', $applications);
5656

5757
if (count($applications->apps) > 0) {
5858
$this->assertIsObject($applications->apps[0]);
5959

6060
$app = $applications->apps[0];
6161

62-
$this->assertObjectHasAttribute('id', $app);
63-
$this->assertObjectHasAttribute('name', $app);
64-
$this->assertObjectHasAttribute('description', $app);
65-
$this->assertObjectHasAttribute('token', $app);
62+
$this->assertObjectHasProperty('id', $app);
63+
$this->assertObjectHasProperty('name', $app);
64+
$this->assertObjectHasProperty('description', $app);
65+
$this->assertObjectHasProperty('token', $app);
6666
}
6767
}
6868

@@ -83,8 +83,8 @@ public function testUpdate(): void
8383
);
8484

8585
$this->assertIsObject($updated);
86-
$this->assertObjectHasAttribute('name', $updated);
87-
$this->assertObjectHasAttribute('description', $updated);
86+
$this->assertObjectHasProperty('name', $updated);
87+
$this->assertObjectHasProperty('description', $updated);
8888

8989
$this->assertEquals($name, $updated->name);
9090
$this->assertEquals($description, $updated->description);
@@ -101,7 +101,7 @@ public function testUploadImage(): void
101101
$uploaded = self::$application->uploadImage(self::$appId, $path);
102102

103103
$this->assertIsObject($uploaded);
104-
$this->assertObjectHasAttribute('image', $uploaded);
104+
$this->assertObjectHasProperty('image', $uploaded);
105105
}
106106

107107
/**

tests/Endpoints/ClientTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public function testCreate(): void
3030
);
3131

3232
$this->assertIsObject($client);
33-
$this->assertObjectHasAttribute('id', $client);
34-
$this->assertObjectHasAttribute('name', $client);
35-
$this->assertObjectHasAttribute('token', $client);
33+
$this->assertObjectHasProperty('id', $client);
34+
$this->assertObjectHasProperty('name', $client);
35+
$this->assertObjectHasProperty('token', $client);
3636

3737
$this->assertEquals($name, $client->name);
3838

@@ -49,16 +49,16 @@ public function testGetAll(): void
4949
$clients = self::$client->getAll();
5050

5151
$this->assertIsObject($clients);
52-
$this->assertObjectHasAttribute('clients', $clients);
52+
$this->assertObjectHasProperty('clients', $clients);
5353

5454
if (count($clients->clients) > 0) {
5555
$this->assertIsObject($clients->clients[0]);
5656

5757
$client = $clients->clients[0];
5858

59-
$this->assertObjectHasAttribute('id', $client);
60-
$this->assertObjectHasAttribute('name', $client);
61-
$this->assertObjectHasAttribute('token', $client);
59+
$this->assertObjectHasProperty('id', $client);
60+
$this->assertObjectHasProperty('name', $client);
61+
$this->assertObjectHasProperty('token', $client);
6262
}
6363
}
6464

@@ -77,7 +77,7 @@ public function testUpdate(): void
7777
);
7878

7979
$this->assertIsObject($updated);
80-
$this->assertObjectHasAttribute('name', $updated);
80+
$this->assertObjectHasProperty('name', $updated);
8181

8282
$this->assertEquals($name, $updated->name);
8383
}

tests/Endpoints/MessageTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public function testCreate(): void
6767
);
6868

6969
$this->assertIsObject($message);
70-
$this->assertObjectHasAttribute('id', $message);
71-
$this->assertObjectHasAttribute('title', $message);
72-
$this->assertObjectHasAttribute('message', $message);
73-
$this->assertObjectHasAttribute('priority', $message);
70+
$this->assertObjectHasProperty('id', $message);
71+
$this->assertObjectHasProperty('title', $message);
72+
$this->assertObjectHasProperty('message', $message);
73+
$this->assertObjectHasProperty('priority', $message);
7474

7575
$this->assertEquals(self::$testTitle, $message->title);
7676
$this->assertEquals(self::$testMessage, $message->message);
@@ -107,10 +107,10 @@ public function testCreateWithExtras(): void
107107
);
108108

109109
$this->assertIsObject($message);
110-
$this->assertObjectHasAttribute('extras', $message);
111-
$this->assertObjectHasAttribute('client::notification', $message->extras);
112-
$this->assertObjectHasAttribute('click', $message->extras->{'client::notification'});
113-
$this->assertObjectHasAttribute('url', $message->extras->{'client::notification'}->click);
110+
$this->assertObjectHasProperty('extras', $message);
111+
$this->assertObjectHasProperty('client::notification', $message->extras);
112+
$this->assertObjectHasProperty('click', $message->extras->{'client::notification'});
113+
$this->assertObjectHasProperty('url', $message->extras->{'client::notification'}->click);
114114

115115
$this->assertEquals(
116116
$extras['client::notification']['click']['url'],
@@ -126,7 +126,7 @@ public function testGetAll(): void
126126
$messages = self::$message->getAll();
127127

128128
$this->assertIsObject($messages);
129-
$this->assertObjectHasAttribute('messages', $messages);
129+
$this->assertObjectHasProperty('messages', $messages);
130130
}
131131

132132
/**

tests/Endpoints/PluginTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public function testGetAll(): void
2626
$plugins = self::$plugin->getAll();
2727

2828
$this->assertIsObject($plugins);
29-
$this->assertObjectHasAttribute('plugins', $plugins);
29+
$this->assertObjectHasProperty('plugins', $plugins);
3030

3131
if (count($plugins->plugins) > 0) {
3232
$this->assertIsObject($plugins->plugins[0]);
3333

3434
$plugin = $plugins->plugins[0];
3535

36-
$this->assertObjectHasAttribute('id', $plugin);
37-
$this->assertObjectHasAttribute('name', $plugin);
38-
$this->assertObjectHasAttribute('token', $plugin);
36+
$this->assertObjectHasProperty('id', $plugin);
37+
$this->assertObjectHasProperty('name', $plugin);
38+
$this->assertObjectHasProperty('token', $plugin);
3939
}
4040
}
4141

tests/Endpoints/UserTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function testGetCurrent(): void
3131

3232
$this->assertIsObject($current);
3333

34-
$this->assertObjectHasAttribute('id', $current);
35-
$this->assertObjectHasAttribute('name', $current);
36-
$this->assertObjectHasAttribute('admin', $current);
34+
$this->assertObjectHasProperty('id', $current);
35+
$this->assertObjectHasProperty('name', $current);
36+
$this->assertObjectHasProperty('admin', $current);
3737

3838
$this->assertEquals(self::$username, $current->name);
3939
}
@@ -56,7 +56,7 @@ public function testGetAll(): void
5656
$users = self::$user->getAll();
5757

5858
$this->assertIsObject($users);
59-
$this->assertObjectHasAttribute('users', $users);
59+
$this->assertObjectHasProperty('users', $users);
6060

6161
if (count($users->users) > 0) {
6262
$this->assertIsObject($users->users[0]);
@@ -113,8 +113,8 @@ public function testUpdate(): void
113113
);
114114

115115
$this->assertIsObject($updated);
116-
$this->assertObjectHasAttribute('name', $updated);
117-
$this->assertObjectHasAttribute('id', $updated);
116+
$this->assertObjectHasProperty('name', $updated);
117+
$this->assertObjectHasProperty('id', $updated);
118118

119119
$this->assertEquals(self::$userId, $updated->id);
120120
$this->assertEquals($newTestUsername, $updated->name);

tests/GuzzleTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function testGet(): void
2727
$body = (object) Json::decode($response->getBody());
2828

2929
$this->assertIsObject($body);
30-
$this->assertObjectHasAttribute('args', $body);
31-
$this->assertObjectHasAttribute('test', $body->args);
30+
$this->assertObjectHasProperty('args', $body);
31+
$this->assertObjectHasProperty('test', $body->args);
3232
$this->assertEquals('HelloWorld', $body->args->test[0]);
3333
}
3434

@@ -45,8 +45,8 @@ public function testPost(): void
4545
$body = (object) Json::decode($response->getBody());
4646

4747
$this->assertIsObject($body);
48-
$this->assertObjectHasAttribute('json', $body);
49-
$this->assertObjectHasAttribute('test', $body->json);
48+
$this->assertObjectHasProperty('json', $body);
49+
$this->assertObjectHasProperty('test', $body->json);
5050
$this->assertEquals('HelloWorld', $body->json->test);
5151
}
5252

@@ -61,7 +61,7 @@ public function testPostYaml(): void
6161
$body = (object) Json::decode($response->getBody());
6262

6363
$this->assertIsObject($body);
64-
$this->assertObjectHasAttribute('data', $body);
64+
$this->assertObjectHasProperty('data', $body);
6565
$this->assertEquals($this->getYamlBase64(), $body->data);
6666
}
6767

@@ -78,8 +78,8 @@ public function testPostFile(): void
7878
$body = (object) Json::decode($response->getBody());
7979

8080
$this->assertIsObject($body);
81-
$this->assertObjectHasAttribute('files', $body);
82-
$this->assertObjectHasAttribute('file', $body->files);
81+
$this->assertObjectHasProperty('files', $body);
82+
$this->assertObjectHasProperty('file', $body->files);
8383
$this->assertEquals(file_get_contents($this->getTextFilePath()), $body->files->file[0]);
8484
}
8585

@@ -96,8 +96,8 @@ public function testPut(): void
9696
$body = (object) Json::decode($response->getBody());
9797

9898
$this->assertIsObject($body);
99-
$this->assertObjectHasAttribute('json', $body);
100-
$this->assertObjectHasAttribute('test', $body->json);
99+
$this->assertObjectHasProperty('json', $body);
100+
$this->assertObjectHasProperty('test', $body->json);
101101
$this->assertEquals('HelloWorld', $body->json->test);
102102
}
103103

@@ -131,8 +131,8 @@ public function testBasicAuth(): void
131131
$body = (object) Json::decode($response->getBody());
132132

133133
$this->assertIsObject($body);
134-
$this->assertObjectHasAttribute('authorized', $body);
135-
$this->assertObjectHasAttribute('user', $body);
134+
$this->assertObjectHasProperty('authorized', $body);
135+
$this->assertObjectHasProperty('user', $body);
136136

137137
$this->assertEquals(true, $body->authorized);
138138
$this->assertEquals($username, $body->user);
@@ -153,8 +153,8 @@ public function testTokenAuth(): void
153153
$body = (object) Json::decode($response->getBody());
154154

155155
$this->assertIsObject($body);
156-
$this->assertObjectHasAttribute('headers', $body);
157-
$this->assertObjectHasAttribute('X-Gotify-Key', $body->headers);
156+
$this->assertObjectHasProperty('headers', $body);
157+
$this->assertObjectHasProperty('X-Gotify-Key', $body->headers);
158158

159159
$headers = get_object_vars($body->headers);
160160

0 commit comments

Comments
 (0)