File tree 2 files changed +48
-8
lines changed
2 files changed +48
-8
lines changed Original file line number Diff line number Diff line change 5
5
use DateTimeImmutable ;
6
6
use Doctrine \ORM \Mapping as ORM ;
7
7
use BugCatcher \Repository \RecordPingRepository ;
8
+ use LogicException ;
8
9
use Symfony \Component \HttpFoundation \Response ;
9
10
10
11
#[ORM \Entity(repositoryClass: RecordPingRepository::class)]
@@ -27,21 +28,16 @@ public function getStatusCode(): ?string {
27
28
return $ this ->statusCode ;
28
29
}
29
30
30
- public function setStatusCode (string $ statusCode ): static {
31
- $ this ->statusCode = $ statusCode ;
32
-
33
- return $ this ;
34
- }
35
31
36
32
function calculateHash (): ?string {
37
- return null ;
33
+ throw new LogicException ( " Ping record does not have hash " ) ;
38
34
}
39
35
40
36
function getComponentName (): string {
41
- return " RecordLog " ;
37
+ throw new LogicException ( " Ping record does not have component name " ) ;
42
38
}
43
39
44
40
function isError (): bool {
45
- return $ this ->getStatus () != Response::HTTP_OK ;
41
+ return $ this ->statusCode != Response::HTTP_OK ;
46
42
}
47
43
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: Jozef Môstka
5
+ * Date: 8. 10. 2024
6
+ * Time: 21:37
7
+ */
8
+
9
+ namespace BugCatcher \Tests \Unit \Entity ;
10
+
11
+ use BugCatcher \Entity \Project ;
12
+ use BugCatcher \Entity \RecordPing ;
13
+ use LogicException ;
14
+ use PHPUnit \Framework \TestCase ;
15
+
16
+ class RecordPingTest extends TestCase
17
+ {
18
+ public function testCalculateHash (): void
19
+ {
20
+ $ record = new RecordPing (new Project (), "200 " );
21
+ $ this ->expectException (LogicException::class);
22
+ $ record ->calculateHash ();
23
+ }
24
+
25
+ public function testComponentName (): void
26
+ {
27
+ $ record = new RecordPing (new Project (), "200 " );
28
+ $ this ->expectException (LogicException::class);
29
+ $ record ->getComponentName ();
30
+ }
31
+
32
+ public function testIsNotError (): void
33
+ {
34
+ $ record = new RecordPing (new Project (), "200 " );
35
+ $ this ->assertFalse ($ record ->isError ());
36
+ }
37
+
38
+ public function testIsError (): void
39
+ {
40
+ $ record = new RecordPing (new Project (), "500 " );
41
+ $ this ->assertTrue ($ record ->isError ());
42
+ }
43
+
44
+ }
You can’t perform that action at this time.
0 commit comments