1--TEST--
2Test Pdo\Sqlite::createAggregate() arguments error
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7
8declare(strict_types=1);
9
10$db = new Pdo\Sqlite('sqlite::memory:');
11
12class TrampolineTest {
13    public function __call(string $name, array $arguments) {
14        return '';
15    }
16}
17
18try {
19    $db->createAggregate(null, [new TrampolineTest(), 'step'], null, 1);
20} catch (Throwable $e) {
21    echo $e->getMessage() . "\n";
22}
23
24try {
25    $db->createAggregate(null, null, [new TrampolineTest(), 'step'], 1);
26} catch (Throwable $e) {
27    echo $e->getMessage() . "\n";
28}
29
30try {
31    $db->createAggregate(null, [new TrampolineTest(), 'step'], [new TrampolineTest(), 'step'], 1);
32} catch (Throwable $e) {
33    echo $e->getMessage() . "\n";
34}
35
36try {
37    $db->createAggregate('S', null, [new TrampolineTest(), 'finalize'], 1);
38} catch (Throwable $e) {
39    echo $e->getMessage() . "\n";
40}
41
42try {
43    $db->createAggregate('S', [new TrampolineTest(), 'step'], null, 1);
44} catch (Throwable $e) {
45    echo $e->getMessage() . "\n";
46}
47
48try {
49    $db->createAggregate('S', [new TrampolineTest(), 'step'], [new TrampolineTest(), 'finalize'], null);
50} catch (Throwable $e) {
51    echo $e->getMessage() . "\n";
52}
53
54echo 'done!';
55?>
56--EXPECT--
57Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
58Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
59Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
60Pdo\Sqlite::createAggregate(): Argument #2 ($step) must be a valid callback, no array or string given
61Pdo\Sqlite::createAggregate(): Argument #3 ($finalize) must be a valid callback, no array or string given
62Pdo\Sqlite::createAggregate(): Argument #4 ($numArgs) must be of type int, null given
63done!
64