@@ 40-63 (lines=24) @@ | ||
37 | /** |
|
38 | * Take really last log. |
|
39 | */ |
|
40 | public function testLastLog() |
|
41 | { |
|
42 | /** @var LogService $service */ |
|
43 | $service = $this->container->get(LogService::class); |
|
44 | ||
45 | $this->assertEmpty($service->lastLog()); |
|
46 | ||
47 | $snapshot = $this->makeSnapshot('error', 123); |
|
48 | $snapshot->report(); |
|
49 | ||
50 | /** @var LogFile $last */ |
|
51 | $last = $service->lastLog(); |
|
52 | ||
53 | $this->assertNotEmpty($last); |
|
54 | $this->assertInstanceOf(LogFile::class, $last); |
|
55 | ||
56 | $this->get('/controller/action'); |
|
57 | ||
58 | /** @var LogFile $last */ |
|
59 | $last2 = $service->lastLog(); |
|
60 | $this->assertNotEmpty($last2); |
|
61 | ||
62 | $this->assertNotEquals($last->name(), $last2->name()); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * Get log by name is really what we want |
|
@@ 68-88 (lines=21) @@ | ||
65 | /** |
|
66 | * Get log by name is really what we want |
|
67 | */ |
|
68 | public function testGetLogByName() |
|
69 | { |
|
70 | /** @var LogService $service */ |
|
71 | $service = $this->container->get(LogService::class); |
|
72 | ||
73 | $snapshot = $this->makeSnapshot('error', 123); |
|
74 | $snapshot->report(); |
|
75 | ||
76 | $this->assertEmpty($service->getLogByName('some-name')); |
|
77 | ||
78 | /** @var LogFile $last */ |
|
79 | $last = $service->lastLog(); |
|
80 | $this->assertNotEmpty($last); |
|
81 | ||
82 | $log = $service->getLogByName($last->name()); |
|
83 | ||
84 | $this->assertNotEmpty($log); |
|
85 | $this->assertInstanceOf(LogFile::class, $log); |
|
86 | ||
87 | $this->assertEquals($last->name(), $log->name()); |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | * Remove all logs |
|
@@ 116-139 (lines=24) @@ | ||
113 | /** |
|
114 | * Remove |
|
115 | */ |
|
116 | public function testRemove() |
|
117 | { |
|
118 | /** @var LogService $service */ |
|
119 | $service = $this->container->get(LogService::class); |
|
120 | ||
121 | $this->assertEmpty($service->getLogs()); |
|
122 | ||
123 | $snapshot = $this->makeSnapshot('error', 123); |
|
124 | $snapshot->report(); |
|
125 | ||
126 | $this->assertCount(1, $service->getLogs()); |
|
127 | ||
128 | /** @var LogFile $last */ |
|
129 | $last = $service->lastLog(); |
|
130 | $this->assertNotEmpty($last); |
|
131 | ||
132 | $service->removeLog(new LogFile('some-name')); |
|
133 | ||
134 | $this->assertCount(1, $service->getLogs()); |
|
135 | ||
136 | $service->removeLog($last); |
|
137 | ||
138 | $this->assertEmpty($service->getLogs()); |
|
139 | } |
|
140 | } |