PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.12
Responsive Menu – Create Mobile-Friendly Menu v3.0.12
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / tests / app / Database / WpDatabaseTest.php

WpDatabaseTest.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.12, at tests/app/Database/WpDatabaseTest.php

62 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use PHPUnit\Framework\TestCase;
4 use ResponsiveMenu\Database\WpDatabase;
5
6 class WpDatabaseTest extends TestCase {
7
8 public function setUp() {
9 $this->wpdb = $this->getMockBuilder('wpdb')
10 ->setMethods(['update', 'delete', 'get_results', 'insert', 'select'])
11 ->getMock();
12 $this->wpdb->prefix = 'prefix';
13 $this->db = new WpDatabase($this->wpdb);
14
15 if(!function_exists('current_time')):
16 function current_time($type) {
17 return '0000';
18 }
19 endif;
20
21 if(!function_exists('update_option')):
22 function update_option($a, $b) {
23 return $a . ' ' . $b;
24 }
25 endif;
26 }
27
28 public function testUpdate() {
29 $this->wpdb->method('update')->will($this->returnArgument(0));
30 $this->assertEquals('prefixupdate_arg', $this->db->update('update_arg', [], []));
31 }
32
33 public function testDelete() {
34 $this->wpdb->method('delete')->will($this->returnArgument(0));
35 $this->assertEquals('prefixdelete_arg', $this->db->delete('delete_arg', 'b'));
36 }
37
38 public function testGetResults() {
39 $this->wpdb->method('get_results')->will($this->returnArgument(0));
40 $this->assertEquals('SELECT * FROM prefixget_results_arg', $this->db->all('get_results_arg'));
41 }
42
43 public function testInsertResults() {
44 $this->wpdb->method('insert')->will($this->returnArgument(0));
45 $this->assertEquals('prefixinsert_arg', $this->db->insert('insert_arg', []));
46 }
47
48 public function testSelectResults() {
49 $this->wpdb->method('get_results')->will($this->returnArgument(0));
50 $this->assertEquals('SELECT * FROM prefixselect_arg WHERE a = \'b\';', $this->db->select('select_arg', 'a', 'b'));
51 }
52
53 public function testMySqlTime() {
54 $this->assertEquals('0000', $this->db->mySqlTime());
55 }
56
57 public function testUpdateOption() {
58 $this->assertEquals('a b', $this->db->updateOption('a', 'b'));
59 }
60
61 }
62