gggeek /
phpxmlrpc
| 1 | <?php |
||||
| 2 | |||||
| 3 | include_once __DIR__ . '/WebTestCase.php'; |
||||
| 4 | |||||
| 5 | use PhpXmlRpc\Request; |
||||
| 6 | use PhpXmlRpc\Value; |
||||
| 7 | |||||
| 8 | /** |
||||
| 9 | * Tests for php files in the 'demo' directory. |
||||
| 10 | * |
||||
| 11 | * @todo add execution of perl and python demos via usage of 'exec' |
||||
| 12 | */ |
||||
| 13 | class DemoFilesTest extends PhpXmlRpc_WebTestCase |
||||
| 14 | { |
||||
| 15 | public function testVardemo() |
||||
| 16 | { |
||||
| 17 | $page = $this->request('?demo=vardemo.php'); |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 18 | } |
||||
| 19 | |||||
| 20 | // *** client *** |
||||
| 21 | |||||
| 22 | public function testAgeSort() |
||||
| 23 | { |
||||
| 24 | $page = $this->request('?demo=client/agesort.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 25 | } |
||||
| 26 | |||||
| 27 | public function testCodegen() |
||||
| 28 | { |
||||
| 29 | $page = $this->request('?demo=client/codegen.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 30 | } |
||||
| 31 | |||||
| 32 | public function testGetStateName() |
||||
| 33 | { |
||||
| 34 | $page = $this->request('?demo=client/getstatename.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 35 | $page = $this->request('?demo=client/getstatename.php', 'POST', array('stateno' => '1')); |
||||
|
0 ignored issues
–
show
array('stateno' => '1') of type array<string,string> is incompatible with the type string expected by parameter $payload of PhpXmlRpc_WebTestCase::request().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 36 | } |
||||
| 37 | |||||
| 38 | public function testLoggerInjection() |
||||
| 39 | { |
||||
| 40 | $page = $this->request('?demo=client/loggerinjection.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 41 | } |
||||
| 42 | |||||
| 43 | public function testIntrospect() |
||||
| 44 | { |
||||
| 45 | $page = $this->request('?demo=client/introspect.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 46 | } |
||||
| 47 | |||||
| 48 | public function testParallel() |
||||
| 49 | { |
||||
| 50 | $page = $this->request('?demo=client/parallel.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 51 | } |
||||
| 52 | |||||
| 53 | public function testProxy() |
||||
| 54 | { |
||||
| 55 | $page = $this->request('?demo=client/proxy.php', 'GET', null, true); |
||||
|
0 ignored issues
–
show
|
|||||
| 56 | } |
||||
| 57 | |||||
| 58 | public function testWhich() |
||||
| 59 | { |
||||
| 60 | $page = $this->request('?demo=client/which.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 61 | } |
||||
| 62 | |||||
| 63 | public function testWindowsCharset() |
||||
| 64 | { |
||||
| 65 | $page = $this->request('?demo=client/windowscharset.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 66 | } |
||||
| 67 | |||||
| 68 | public function testWrap() |
||||
| 69 | { |
||||
| 70 | $page = $this->request('?demo=client/wrap.php'); |
||||
|
0 ignored issues
–
show
|
|||||
| 71 | } |
||||
| 72 | |||||
| 73 | // *** servers *** |
||||
| 74 | |||||
| 75 | public function testCodegenServer() |
||||
| 76 | { |
||||
| 77 | if (!extension_loaded('sqlite3')) { |
||||
| 78 | $this->markTestSkipped('PHP extension sqlite3 is required for this test'); |
||||
| 79 | } |
||||
| 80 | |||||
| 81 | $page = $this->request('?demo=server/codegen.php&generate=1'); |
||||
| 82 | $this->assertStringContainsString('Code generated', $page); |
||||
|
0 ignored issues
–
show
It seems like
$page can also be of type true; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 83 | |||||
| 84 | $c = $this->newClient('?demo=server/codegen.php'); |
||||
| 85 | $r = $c->send(new Request('CommentManager.getComments', array( |
||||
| 86 | new Value('aCommentId') |
||||
| 87 | ))); |
||||
| 88 | $this->assertEquals(0, $r->faultCode()); |
||||
| 89 | } |
||||
| 90 | |||||
| 91 | public function testDiscussServer() |
||||
| 92 | { |
||||
| 93 | if (!extension_loaded('sqlite3')) { |
||||
| 94 | $this->markTestSkipped('PHP extension sqlite3 is required for this test'); |
||||
| 95 | } |
||||
| 96 | |||||
| 97 | $page = $this->request('?demo=server/discuss.php'); |
||||
| 98 | $this->assertStringContainsString('<name>faultCode</name>', $page); |
||||
|
0 ignored issues
–
show
It seems like
$page can also be of type true; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 99 | $this->assertRegexp('#<int>10(5|3)</int>#', $page); |
||||
|
0 ignored issues
–
show
It seems like
$page can also be of type true; however, parameter $string of PHPUnit\Framework\Assert::assertRegExp() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 100 | |||||
| 101 | $c = $this->newClient('?demo=server/discuss.php'); |
||||
| 102 | |||||
| 103 | $r = $c->send(new Request('discuss.addComment', array( |
||||
| 104 | new Value('aCommentId'), |
||||
| 105 | new Value('aCommentUser'), |
||||
| 106 | new Value('a Comment') |
||||
| 107 | ))); |
||||
| 108 | $this->assertEquals(0, $r->faultCode()); |
||||
| 109 | $this->assertGreaterThanOrEqual(1, $r->value()->scalarval()); |
||||
| 110 | |||||
| 111 | $r = $c->send(new Request('discuss.getComments', array( |
||||
| 112 | new Value('aCommentId') |
||||
| 113 | ))); |
||||
| 114 | $this->assertEquals(0, $r->faultCode()); |
||||
| 115 | $this->assertEquals(0, $r->faultCode()); |
||||
| 116 | $this->assertGreaterThanOrEqual(1, count($r->value())); |
||||
|
0 ignored issues
–
show
It seems like
$r->value() can also be of type string; however, parameter $value of count() does only seem to accept Countable|array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 117 | } |
||||
| 118 | |||||
| 119 | public function testProxyServer() |
||||
| 120 | { |
||||
| 121 | /// @todo add a couple of proper xmlrpc calls, too |
||||
| 122 | $page = $this->request('?demo=server/proxy.php'); |
||||
| 123 | $this->assertStringContainsString('<name>faultCode</name>', $page); |
||||
|
0 ignored issues
–
show
It seems like
$page can also be of type true; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 124 | $this->assertRegexp('#<int>10(5|3)</int>#', $page); |
||||
|
0 ignored issues
–
show
It seems like
$page can also be of type true; however, parameter $string of PHPUnit\Framework\Assert::assertRegExp() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 125 | } |
||||
| 126 | } |
||||
| 127 |