PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / exec-with-fallback / tests / ArgumentsTest.php

ArgumentsTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/exec-with-fallback/tests/ArgumentsTest.php

156 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ExecWithFallback\Tests;
3
4 use PHPUnit\Framework\TestCase;
5
6 class ArgumentsTest extends TestCase
7 {
8
9 public function numArgs(&$arg = null)
10 {
11 //echo 'number of arguments:' . func_num_args();
12 return func_num_args();
13 }
14
15 public function getArg0Default8(&$arg = 8)
16 {
17 return func_get_arg(0);
18 }
19
20 public function getArg0DefaultNull(&$arg = null)
21 {
22 //return $arg;
23 return func_get_arg(0);
24 }
25
26 public function isArg0Set(&$arg0 = null, &$arg1 = null)
27 {
28 //return (func_num_args() > 0);
29 $a = func_get_args();
30 try {
31 $b = $a[0];
32 } catch (\Exception $e) {
33 return false;
34 } catch (\Throwable $e) {
35 return false;
36 }
37 if (count($a) == 2) {
38 return isset($a[0]);
39 }
40 //print_r($a);
41 //echo count($a);
42 return true;
43 //return !is_null($arg0);
44 //return isset($a[0]);
45 //return count($a) > 0;
46 //return isset($a[0])
47 //return isset($a[0]);
48 }
49
50 public function testFuncNumArgs()
51 {
52 $this->assertSame(0, $this->numArgs());
53 $this->assertSame(1, $this->numArgs($arg));
54 }
55
56 public function supplied($command, &$output = null, &$result_code = null)
57 {
58 //echo "\n" . $command . ':' . func_num_args() . "\n";
59
60 $outputSupplied = (func_num_args() >= 2);
61 $resultCodeSupplied = (func_num_args() >= 3);
62 /*
63 $a = func_get_args();
64 //return (func_num_args() > 0);
65 $outputSupplied = true;
66 try {
67 $o = $a[1];
68 } catch (\Exception $e) {
69 $outputSupplied = false;
70 } catch (\Throwable $e) {
71 $outputSupplied = false;
72 }
73 if (count($a) == 3) {
74 //$outputSupplied = isset($a[1]);
75 }
76
77 $resultCodeSupplied = true;
78 try {
79 $r = $a[2];
80 } catch (\Exception $e) {
81 $resultCodeSupplied = false;
82 } catch (\Throwable $e) {
83 $resultCodeSupplied = false;
84 }*/
85
86 //echo $command;
87 //print_r($a);
88
89 $result = 0;
90 if ($outputSupplied) $result += 1;
91 if ($resultCodeSupplied) $result += 2;
92 return $result;
93
94 //return !is_null($arg0);
95 //return isset($a[0]);
96 //return count($a) > 0;
97 //return isset($a[0])
98 //return isset($a[0]);*/
99 }
100
101 public function testFuncGetArg()
102 {
103 $seven = 7;
104 //$this->assertSame(7, $this->getArg0Default8($seven));
105
106 /*$a=[];
107 $this->assertFalse(isset($a[1]));
108 $a[0] = null;
109 $this->assertTrue(isset($a[1]));*/
110
111 $this->assertSame(0, $this->supplied('only-one'));
112 $this->assertSame(1, $this->supplied('two', $seven));
113 $this->assertSame(3, $this->supplied('three', $seven, $seven));
114 $this->assertSame(1, $this->supplied('', $yetUndefined));
115 $this->assertSame(3, $this->supplied('', $yetUndefined, $yetUndefined));
116
117 /*
118 TODO: enable in PHP 8.0
119 $this->assertSame(3, $this->supplied(
120 command:'hi',
121 output: $yetUndefined,
122 result_code: $yetUndefined
123 ));
124
125 // Sorry, the two below would be better if they return 2,
126 // but it seems impossible
127 // So, these are handled as if $output is supplied.
128 // - which means our selector will not choose system(), even though
129 // it could
130 $this->assertSame(3, $this->supplied(
131 command:'hi2',
132 result_code: $yetUndefined
133 ));
134 $this->assertSame(3, $this->supplied(
135 '',
136 result_code: $yetUndefined
137 ));
138 */
139
140
141 /*
142 $this->assertFalse($this->isArg0Set());
143 $this->assertTrue($this->isArg0Set($seven));
144 $this->assertTrue($this->isArg0Set($yetUndefined));
145
146 // PHP 8:
147 $this->assertTrue($this->isArg0Set(arg0: $seven));
148 $this->assertTrue($this->isArg0Set(arg0: $yetUndefined));
149 $this->assertFalse($this->isArg0Set(arg1: $seven));
150 */
151
152 //$this->assertSame(null, $this->getArg0Default8($yetUndefined));
153 //$this->assertSame(8,9);
154 }
155 }
156