xref: /dokuwiki/_test/tests/Remote/OpenApiDoc/DocBlockMethodTest.php (revision 8ddd9b69189e5c591f86c9f4314a06ec13778622)
1*8ddd9b69SAndreas Gohr<?php
2*8ddd9b69SAndreas Gohr
3*8ddd9b69SAndreas Gohrnamespace dokuwiki\test\Remote\OpenApiDoc;
4*8ddd9b69SAndreas Gohr
5*8ddd9b69SAndreas Gohruse dokuwiki\Remote\OpenApiDoc\DocBlockMethod;
6*8ddd9b69SAndreas Gohr
7*8ddd9b69SAndreas Gohrclass DocBlockMethodTest extends \DokuWikiTest {
8*8ddd9b69SAndreas Gohr
9*8ddd9b69SAndreas Gohr
10*8ddd9b69SAndreas Gohr    /**
11*8ddd9b69SAndreas Gohr     * This is a test
12*8ddd9b69SAndreas Gohr     *
13*8ddd9b69SAndreas Gohr     * With more information
14*8ddd9b69SAndreas Gohr     * in several lines
15*8ddd9b69SAndreas Gohr     * @param string $foo First variable
16*8ddd9b69SAndreas Gohr     * @param int $bar
17*8ddd9b69SAndreas Gohr     * @param string[] $baz
18*8ddd9b69SAndreas Gohr     * @something else
19*8ddd9b69SAndreas Gohr     * @something other
20*8ddd9b69SAndreas Gohr     * @another tag
21*8ddd9b69SAndreas Gohr     * @return string  The return
22*8ddd9b69SAndreas Gohr     */
23*8ddd9b69SAndreas Gohr    public function dummyMethod1($foo, $bar, $baz=['a default'])
24*8ddd9b69SAndreas Gohr    {
25*8ddd9b69SAndreas Gohr        return 'dummy';
26*8ddd9b69SAndreas Gohr    }
27*8ddd9b69SAndreas Gohr
28*8ddd9b69SAndreas Gohr    public function testMethod()
29*8ddd9b69SAndreas Gohr    {
30*8ddd9b69SAndreas Gohr        $reflect = new \ReflectionMethod($this, 'dummyMethod1');
31*8ddd9b69SAndreas Gohr        $doc = new DocBlockMethod($reflect);
32*8ddd9b69SAndreas Gohr
33*8ddd9b69SAndreas Gohr        $this->assertEquals('This is a test', $doc->getSummary());
34*8ddd9b69SAndreas Gohr        $this->assertEquals("With more information\nin several lines", $doc->getDescription());
35*8ddd9b69SAndreas Gohr
36*8ddd9b69SAndreas Gohr        $this->assertEquals(
37*8ddd9b69SAndreas Gohr            [
38*8ddd9b69SAndreas Gohr                'foo' => [
39*8ddd9b69SAndreas Gohr                    'type' => 'string',
40*8ddd9b69SAndreas Gohr                    'description' => 'First variable',
41*8ddd9b69SAndreas Gohr                    'optional' => false,
42*8ddd9b69SAndreas Gohr                ],
43*8ddd9b69SAndreas Gohr                'bar' => [
44*8ddd9b69SAndreas Gohr                    'type' => 'int',
45*8ddd9b69SAndreas Gohr                    'description' => '',
46*8ddd9b69SAndreas Gohr                    'optional' => false,
47*8ddd9b69SAndreas Gohr                ],
48*8ddd9b69SAndreas Gohr                'baz' => [
49*8ddd9b69SAndreas Gohr                    'type' => 'string[]',
50*8ddd9b69SAndreas Gohr                    'description' => '',
51*8ddd9b69SAndreas Gohr                    'optional' => true,
52*8ddd9b69SAndreas Gohr                    'default' => ['a default'],
53*8ddd9b69SAndreas Gohr                ],
54*8ddd9b69SAndreas Gohr            ],
55*8ddd9b69SAndreas Gohr            $doc->getTag('param')
56*8ddd9b69SAndreas Gohr        );
57*8ddd9b69SAndreas Gohr
58*8ddd9b69SAndreas Gohr        $this->assertEquals(
59*8ddd9b69SAndreas Gohr            [
60*8ddd9b69SAndreas Gohr                'type' => 'string',
61*8ddd9b69SAndreas Gohr                'description' => 'The return'
62*8ddd9b69SAndreas Gohr            ],
63*8ddd9b69SAndreas Gohr            $doc->getTag('return')
64*8ddd9b69SAndreas Gohr        );
65*8ddd9b69SAndreas Gohr
66*8ddd9b69SAndreas Gohr        $this->assertEquals(
67*8ddd9b69SAndreas Gohr            [
68*8ddd9b69SAndreas Gohr                'else',
69*8ddd9b69SAndreas Gohr                'other',
70*8ddd9b69SAndreas Gohr            ],
71*8ddd9b69SAndreas Gohr            $doc->getTag('something')
72*8ddd9b69SAndreas Gohr        );
73*8ddd9b69SAndreas Gohr
74*8ddd9b69SAndreas Gohr        $this->assertEquals(
75*8ddd9b69SAndreas Gohr            [
76*8ddd9b69SAndreas Gohr                'tag',
77*8ddd9b69SAndreas Gohr            ],
78*8ddd9b69SAndreas Gohr            $doc->getTag('another')
79*8ddd9b69SAndreas Gohr        );
80*8ddd9b69SAndreas Gohr    }
81*8ddd9b69SAndreas Gohr}
82