Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Dec 1, 2024
1 parent c6e1feb commit 6dd3850
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions app/Services/KeyGeneratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,17 @@ public function reservedKeyword()
}

/**
* Reserved keywords that are already in use as url shortened keywords.
* The keywords that are currently in use as active keywords, but also are
* reserved keywords.
*
* @return \Illuminate\Support\Collection
*/
public function reservedActiveKeyword()
{
$reservedKeyword = $this->reservedKeyword();
$usedKeyWord = Url::pluck('keyword')->toArray();
$activeKeyword = Url::pluck('keyword')->toArray();

return $reservedKeyword->intersect($usedKeyWord);
return $reservedKeyword->intersect($activeKeyword);
}

/*
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Services/KeyGeneratorServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ public function testReservedActiveKeyword()
);

// Test case 2: Some reserved keywords already in use
$usedKeyWord = 'zzz' . fake()->word();
Url::factory()->create(['keyword' => $usedKeyWord]);
$activeKeyword = 'zzz' . fake()->word();
Url::factory()->create(['keyword' => $activeKeyword]);

$fileSystem->makeDirectory(public_path($usedKeyWord));
$fileSystem->makeDirectory(public_path($activeKeyword));
$this->assertEquals(
$usedKeyWord,
$activeKeyword,
$this->keyGenerator->reservedActiveKeyword()->implode(''),
);
$fileSystem->deleteDirectory(public_path($usedKeyWord));
$fileSystem->deleteDirectory(public_path($activeKeyword));
}

/**
Expand Down

0 comments on commit 6dd3850

Please sign in to comment.