-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBasicMessageTest.php
50 lines (41 loc) · 1.22 KB
/
BasicMessageTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Yoast\WHIP\Tests\Unit;
use Yoast\WHIPv2\Messages\BasicMessage;
/**
* Message Unit tests.
*/
final class BasicMessageTest extends TestCase {
/**
* Tests if BasicMessage correctly handles a string for its body argument.
*
* @covers \Yoast\WHIPv2\Messages\BasicMessage::body
*
* @return void
*/
public function testMessageHasBody() {
$message = new BasicMessage( 'This is a message' );
$this->assertNotEmpty( $message->body() );
}
/**
* Tests if an Exception is correctly thrown when an empty string is passed as argument.
*
* @covers \Yoast\WHIPv2\Messages\BasicMessage::validateParameters
*
* @return void
*/
public function testMessageCannotBeEmpty() {
$this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\EmptyProperty', 'Message body cannot be empty.' );
new BasicMessage( '' );
}
/**
* Tests if an Exception is correctly thrown when an invalid type is passed as argument.
*
* @covers \Yoast\WHIPv2\Messages\BasicMessage::validateParameters
*
* @return void
*/
public function testMessageMustBeString() {
$this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\InvalidType', 'Message body should be of type string. Found integer.' );
new BasicMessage( 123 );
}
}