|
2 | 2 |
|
3 | 3 | namespace Tests;
|
4 | 4 |
|
5 |
| -use Dompdf\Dompdf; |
| 5 | +use Carbon\Carbon; |
6 | 6 | use Illuminate\Support\Facades\DB;
|
| 7 | +use TCPDF; |
7 | 8 |
|
8 | 9 | class DatabaseInteractionTest extends TestCase
|
9 | 10 | {
|
@@ -85,9 +86,10 @@ public function scheduled_date_should_be_saved_correctly()
|
85 | 86 | $this->assertNull(DB::table('emails')->find(1)->scheduled_at);
|
86 | 87 | $this->assertNull($email->getScheduledDate());
|
87 | 88 |
|
| 89 | + Carbon::setTestNow(Carbon::create(2019, 1, 1, 1, 2, 3)); |
88 | 90 | $email = $this->scheduleEmail('+2 weeks');
|
89 | 91 | $this->assertNotNull(DB::table('emails')->find(2)->scheduled_at);
|
90 |
| - $this->assertEquals(date('Y-m-d H:i:s', strtotime('+2 weeks')), $email->getScheduledDate()); |
| 92 | + $this->assertEquals('2019-01-15 01:02:03', $email->getScheduledDate()); |
91 | 93 | }
|
92 | 94 |
|
93 | 95 | /** @test */
|
@@ -156,7 +158,9 @@ public function attempts_should_be_zero()
|
156 | 158 | /** @test */
|
157 | 159 | public function the_scheduled_date_should_be_saved_correctly()
|
158 | 160 | {
|
159 |
| - $scheduledFor = date('Y-m-d H:i:s', strtotime('+2 weeks')); |
| 161 | + Carbon::setTestNow(Carbon::now()); |
| 162 | + |
| 163 | + $scheduledFor = date('Y-m-d H:i:s', Carbon::now()->addWeek(2)->timestamp); |
160 | 164 |
|
161 | 165 | $email = $this->scheduleEmail('+2 weeks');
|
162 | 166 |
|
@@ -205,19 +209,20 @@ public function attachments_should_be_saved_correctly()
|
205 | 209 | /** @test */
|
206 | 210 | public function in_memory_attachments_should_be_saved_correctly()
|
207 | 211 | {
|
208 |
| - $pdf = new Dompdf; |
209 |
| - $pdf->loadHtml('Hello CI!'); |
210 |
| - $pdf->setPaper('A4', 'landscape'); |
| 212 | + $pdf = new TCPDF; |
| 213 | + $pdf->Write(0, 'Hello CI!'); |
| 214 | + |
| 215 | + $rawData = $pdf->Output('generated.pdf', 'S'); |
211 | 216 |
|
212 | 217 | $email = $this->composeEmail()
|
213 |
| - ->attachData($pdf->outputHtml(), 'generated.pdf', [ |
| 218 | + ->attachData($rawData, 'generated.pdf', [ |
214 | 219 | 'mime' => 'application/pdf',
|
215 | 220 | ])
|
216 | 221 | ->send();
|
217 | 222 |
|
218 | 223 | $this->assertCount(1, $email->getAttachments());
|
219 | 224 |
|
220 | 225 | $this->assertEquals('rawAttachment', $email->getAttachments()[0]['type']);
|
221 |
| - $this->assertEquals($pdf->outputHtml(), $email->getAttachments()[0]['attachment']['data']); |
| 226 | + $this->assertEquals(md5($rawData), md5($email->getAttachments()[0]['attachment']['data'])); |
222 | 227 | }
|
223 | 228 | }
|
0 commit comments