Skip to content

Commit 3615e71

Browse files
GrahamCampbellspawniaStyleCIBot
authored
[11.8] Allow specifying params for Wiki::showAll() (GitLabPHP#691)
Co-authored-by: Benedikt Franke <[email protected]> Co-authored-by: spawnia <[email protected]> Co-authored-by: StyleCI Bot <[email protected]>
1 parent 4e91319 commit 3615e71

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/Api/Wiki.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
class Wiki extends AbstractApi
1818
{
1919
/**
20-
* @param int|string $project_id
21-
* @param array $params
20+
* @param int|string $project_id
21+
* @param array<string,mixed> $params
2222
*
2323
* @return mixed
2424
*/
@@ -39,19 +39,27 @@ public function show($project_id, string $wiki_slug)
3939
}
4040

4141
/**
42-
* @param int|string $project_id
42+
* @param int|string $project_id
43+
* @param array<string,mixed> $params {
44+
*
45+
* @var bool $with_content Include pages' content
46+
* }
4347
*
4448
* @return mixed
4549
*/
46-
public function showAll($project_id)
50+
public function showAll($project_id, array $params)
4751
{
48-
return $this->get($this->getProjectPath($project_id, 'wikis'));
52+
$resolver = $this->createOptionsResolver();
53+
$resolver->setDefined('with_content')
54+
->setAllowedTypes('with_content', 'bool');
55+
56+
return $this->get($this->getProjectPath($project_id, 'wikis'), $resolver->resolve($params));
4957
}
5058

5159
/**
52-
* @param int|string $project_id
53-
* @param string $wiki_slug
54-
* @param array $params
60+
* @param int|string $project_id
61+
* @param string $wiki_slug
62+
* @param array<string,mixed> $params
5563
*
5664
* @return mixed
5765
*/

tests/Api/WikiTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ public function shouldShowAllWiki(): void
8181
'format' => 'markdown',
8282
];
8383

84+
$params = ['with_content' => true];
85+
8486
$api = $this->getApiMock();
8587
$api->expects($this->once())
8688
->method('get')
87-
->with('projects/1/wikis')
89+
->with('projects/1/wikis', $params)
8890
->will($this->returnValue($expectedArray))
8991
;
9092

91-
$this->assertEquals($expectedArray, $api->showAll(1));
93+
$this->assertEquals($expectedArray, $api->showAll(1, $params));
9294
}
9395

9496
/**

0 commit comments

Comments
 (0)