Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/Helper/ProfileValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testProfileValidatorWorksWithInvalidProfile($profile): void {
$this->assertFalse($validator->passes());
}

private function validProfileProvider() {
public static function validProfileProvider() {
return [
['boring profile with no other' => [
'purpose' => 'data_hub',
Expand All @@ -41,7 +41,7 @@ private function validProfileProvider() {
];
}

private function invalidProfileProvider() {
public static function invalidProfileProvider() {
return [
['missing other keys' => [
'purpose' => 'data_hub',
Expand Down
38 changes: 25 additions & 13 deletions tests/Jobs/CirrusSearch/ElasticSearchIndexInitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,30 @@ public function testJobTriggeredButNoSetting() {
*
* @expectedException RuntimeException
*/
public function testFailure($request, string $expectedFailure, $mockResponse) {
public function testFailure(string $expectedFailure, $mockResponse) {
$request = $this->createMock(HttpRequest::class);
$mockJob = $this->createMock(Job::class);
$mockJob->expects($this->once())
->method('fail');

$request->method('execute')->willReturn(json_encode($mockResponse));

$job = new ElasticSearchIndexInit($this->wiki->id);
$job->setJob($mockJob);
$job->handle($request);

$this->assertSame(
1,
WikiSetting::where(['wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, 'value' => true])->count()
);
}

public function testCurlFailure() {
$expectedFailure = 'wbstackElasticSearchInit curl error for <WIKI_ID>: Scary Error!';
$mockResponse = [];

$request = $this->createMock(HttpRequest::class);
$request->method('error')->willReturn('Scary Error!');
$mockJob = $this->createMock(Job::class);
$mockJob->expects($this->once())
->method('fail');
Expand All @@ -159,11 +182,10 @@ public function testFailure($request, string $expectedFailure, $mockResponse) {
);
}

public function failureProvider() {
public static function failureProvider() {

$mockResponse = [];
yield [
$this->createMock(HttpRequest::class),
'wbstackElasticSearchInit call for <WIKI_ID>. No wbstackElasticSearchInit key in response: []',
$mockResponse,
];
Expand All @@ -177,22 +199,12 @@ public function failureProvider() {
];

yield [
$this->createMock(HttpRequest::class),
'wbstackElasticSearchInit call for <WIKI_ID> was not successful:{"warnings":[],"wbstackElasticSearchInit":{"return":0,"output":[]}}',
$mockResponse,
];

$curlError = $this->createMock(HttpRequest::class);
$curlError->method('error')->willReturn('Scary Error!');
yield [
$curlError,
'wbstackElasticSearchInit curl error for <WIKI_ID>: Scary Error!',
$mockResponse,
];

$mockResponse['wbstackElasticSearchInit']['return'] = 1;
yield [
$this->createMock(HttpRequest::class),
'wbstackElasticSearchInit call for <WIKI_ID> was not successful:{"warnings":[],"wbstackElasticSearchInit":{"return":1,"output":[]}}',
$mockResponse,
];
Expand Down
Loading