/var/www/html_us/wp-content/plugins/wp-smtp/tests/_support/Helper/MailDb.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
<?php

namespace Helper;

use 
Codeception\Exception\ModuleException;
use 
Codeception\Module;

class 
MailDb extends Module {

    public function 
haveSequentialLogsInDatabaseint $count ): void {
        global 
$wpdb;

        if ( ! 
$wpdb instanceof \wpdb ) {
            throw new 
ModuleException(
                
$this,
                
'WordPress database object is not available. WPLoader must be enabled first.'
            
);
        }

        for ( 
$i 1$i <= $count$i++ ) {
            
$wpdb->insert(
                
$wpdb->prefix 'wpsmtp_logs',
                [
                    
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
                    
'timestamp' => date'Y-m-d H:i:s'strtotime"2023-01-01 00:00:0{$i}) ),
                    
'to'        => "test{$i}@example.com",
                    
'subject'   => "Test Subject {$i}",
                    
'message'   => "Test Message {$i}",
                    
'headers'   => "Header {$i}",
                    
'error'     => "Error {$i}",
                ]
            );
        }
    }
}