|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace BNETDocs\Tests\Libraries\EventLog; |
| 4 | + |
| 5 | +use \BNETDocs\Libraries\EventLog\EventType; |
| 6 | +use \BNETDocs\Libraries\EventLog\EventTypes; |
| 7 | +use \PHPUnit\Framework\TestCase; |
| 8 | +use \UnexpectedValueException; |
| 9 | + |
| 10 | +class EventTypeTest extends TestCase |
| 11 | +{ |
| 12 | + // color() — representative cases for each color bucket |
| 13 | + |
| 14 | + public function testColorBlueForBlizzardVisit(): void |
| 15 | + { |
| 16 | + $this->assertSame(0x5865F2, EventType::color(EventTypes::BLIZZARD_VISIT)); |
| 17 | + } |
| 18 | + |
| 19 | + public function testColorGrayForLogNote(): void |
| 20 | + { |
| 21 | + $this->assertSame(0x99AAB5, EventType::color(EventTypes::LOG_NOTE)); |
| 22 | + } |
| 23 | + |
| 24 | + public function testColorGrayForSlackUnfurl(): void |
| 25 | + { |
| 26 | + $this->assertSame(0x99AAB5, EventType::color(EventTypes::SLACK_UNFURL)); |
| 27 | + } |
| 28 | + |
| 29 | + public function testColorGreenForUserCreated(): void |
| 30 | + { |
| 31 | + $this->assertSame(0x57F287, EventType::color(EventTypes::USER_CREATED)); |
| 32 | + } |
| 33 | + |
| 34 | + public function testColorGreenForDocumentCreated(): void |
| 35 | + { |
| 36 | + $this->assertSame(0x57F287, EventType::color(EventTypes::DOCUMENT_CREATED)); |
| 37 | + } |
| 38 | + |
| 39 | + public function testColorGreenForServerCreated(): void |
| 40 | + { |
| 41 | + $this->assertSame(0x57F287, EventType::color(EventTypes::SERVER_CREATED)); |
| 42 | + } |
| 43 | + |
| 44 | + public function testColorRedForUserDeleted(): void |
| 45 | + { |
| 46 | + $this->assertSame(0xED4245, EventType::color(EventTypes::USER_DELETED)); |
| 47 | + } |
| 48 | + |
| 49 | + public function testColorRedForUserLogout(): void |
| 50 | + { |
| 51 | + $this->assertSame(0xED4245, EventType::color(EventTypes::USER_LOGOUT)); |
| 52 | + } |
| 53 | + |
| 54 | + public function testColorRedForPacketDeleted(): void |
| 55 | + { |
| 56 | + $this->assertSame(0xED4245, EventType::color(EventTypes::PACKET_DELETED)); |
| 57 | + } |
| 58 | + |
| 59 | + public function testColorYellowForUserEdited(): void |
| 60 | + { |
| 61 | + $this->assertSame(0xFEE75C, EventType::color(EventTypes::USER_EDITED)); |
| 62 | + } |
| 63 | + |
| 64 | + public function testColorYellowForDocumentEdited(): void |
| 65 | + { |
| 66 | + $this->assertSame(0xFEE75C, EventType::color(EventTypes::DOCUMENT_EDITED)); |
| 67 | + } |
| 68 | + |
| 69 | + public function testColorYellowForServerEdited(): void |
| 70 | + { |
| 71 | + $this->assertSame(0xFEE75C, EventType::color(EventTypes::SERVER_EDITED)); |
| 72 | + } |
| 73 | + |
| 74 | + public function testColorDefaultsToGrayForUnknownId(): void |
| 75 | + { |
| 76 | + $this->assertSame(0x99AAB5, EventType::color(99999)); |
| 77 | + } |
| 78 | + |
| 79 | + // __toString() — representative cases across all categories |
| 80 | + |
| 81 | + public function testToStringLogNote(): void |
| 82 | + { |
| 83 | + $e = new EventType(EventTypes::LOG_NOTE); |
| 84 | + $this->assertSame('Log Note', (string) $e); |
| 85 | + } |
| 86 | + |
| 87 | + public function testToStringSiteDeploy(): void |
| 88 | + { |
| 89 | + $e = new EventType(EventTypes::SITE_DEPLOY); |
| 90 | + $this->assertSame('Site Deploy', (string) $e); |
| 91 | + } |
| 92 | + |
| 93 | + public function testToStringUserCreated(): void |
| 94 | + { |
| 95 | + $e = new EventType(EventTypes::USER_CREATED); |
| 96 | + $this->assertSame('User Created', (string) $e); |
| 97 | + } |
| 98 | + |
| 99 | + public function testToStringUserLogin(): void |
| 100 | + { |
| 101 | + $e = new EventType(EventTypes::USER_LOGIN); |
| 102 | + $this->assertSame('User Login', (string) $e); |
| 103 | + } |
| 104 | + |
| 105 | + public function testToStringUserLogout(): void |
| 106 | + { |
| 107 | + $e = new EventType(EventTypes::USER_LOGOUT); |
| 108 | + $this->assertSame('User Logout', (string) $e); |
| 109 | + } |
| 110 | + |
| 111 | + public function testToStringNewsCreated(): void |
| 112 | + { |
| 113 | + $e = new EventType(EventTypes::NEWS_CREATED); |
| 114 | + $this->assertSame('News Post Created', (string) $e); |
| 115 | + } |
| 116 | + |
| 117 | + public function testToStringPacketEdited(): void |
| 118 | + { |
| 119 | + $e = new EventType(EventTypes::PACKET_EDITED); |
| 120 | + $this->assertSame('Packet Edited', (string) $e); |
| 121 | + } |
| 122 | + |
| 123 | + public function testToStringDocumentDeleted(): void |
| 124 | + { |
| 125 | + $e = new EventType(EventTypes::DOCUMENT_DELETED); |
| 126 | + $this->assertSame('Document Deleted', (string) $e); |
| 127 | + } |
| 128 | + |
| 129 | + public function testToStringCommentCreatedOnPacket(): void |
| 130 | + { |
| 131 | + $e = new EventType(EventTypes::COMMENT_CREATED_PACKET); |
| 132 | + $this->assertSame('Comment Created on Packet', (string) $e); |
| 133 | + } |
| 134 | + |
| 135 | + public function testToStringCommentEditedOnDocument(): void |
| 136 | + { |
| 137 | + $e = new EventType(EventTypes::COMMENT_EDITED_DOCUMENT); |
| 138 | + $this->assertSame('Comment Edited on Document', (string) $e); |
| 139 | + } |
| 140 | + |
| 141 | + public function testToStringCommentDeletedOnServer(): void |
| 142 | + { |
| 143 | + $e = new EventType(EventTypes::COMMENT_DELETED_SERVER); |
| 144 | + $this->assertSame('Comment Deleted on Server', (string) $e); |
| 145 | + } |
| 146 | + |
| 147 | + public function testToStringServerCreated(): void |
| 148 | + { |
| 149 | + $e = new EventType(EventTypes::SERVER_CREATED); |
| 150 | + $this->assertSame('Server Created', (string) $e); |
| 151 | + } |
| 152 | + |
| 153 | + public function testToStringSlackUnfurl(): void |
| 154 | + { |
| 155 | + $e = new EventType(EventTypes::SLACK_UNFURL); |
| 156 | + $this->assertSame('Slack Unfurl', (string) $e); |
| 157 | + } |
| 158 | + |
| 159 | + public function testToStringUnknownIdThrows(): void |
| 160 | + { |
| 161 | + $this->expectException(UnexpectedValueException::class); |
| 162 | + $e = new EventType(99999); |
| 163 | + (string) $e; |
| 164 | + } |
| 165 | +} |
0 commit comments