Skip to content

Commit

Permalink
Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Sep 6, 2024
1 parent 7491503 commit dc1ceae
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions tests/unit/helpers/ElementHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

namespace crafttests\unit\helpers;

use Codeception\Stub;
use Craft;
use craft\db\Command;
use craft\errors\OperationAbortedException;
use craft\helpers\ElementHelper;
use craft\test\mockclasses\elements\ExampleElement;
Expand Down Expand Up @@ -94,29 +92,10 @@ public function testDoesUriFormatHaveSlugTag(bool $expected, string $uriFormat):
* @dataProvider setUniqueUriDataProvider
* @param array $expected
* @param array $config
* @param int $duplicates
* @throws OperationAbortedException
*/
public function testSetUniqueUri(array $expected, array $config, int $duplicates = 0): void
public function testSetUniqueUri(array $expected, array $config): void
{
if ($duplicates) {
$db = Craft::$app->getDb();
$this->tester->mockDbMethods([
'createCommand' => function($sql, $params) use (&$duplicates, &$db) {
/* @var Command $command */
$command = Stub::construct(Command::class, [
['db' => $db, 'sql' => $sql],
], [
'queryScalar' => function() use (&$duplicates) {
return $duplicates-- ? 1 : 0;
},
]);
$command->bindValues($params);
return $command;
},
]);
}

$example = new ExampleElement($config);
ElementHelper::setUniqueUri($example);

Expand Down Expand Up @@ -258,8 +237,6 @@ public static function setUniqueUriDataProvider(): array
[['uri' => null], ['uriFormat' => null]],
[['uri' => null], ['uriFormat' => '']],
[['uri' => 'craft'], ['uriFormat' => '{slug}', 'slug' => 'craft']],
[['uri' => 'craft--3'], ['uriFormat' => '{slug}', 'slug' => 'craft'], 2],
[['uri' => 'testing-uri-longer-than-255-chars/arrêté-du-24-décembre-2020-portant-modification-de-larrêté-du-4-décembre-2020-fixant-la-liste-des-personnes-autorisées-à-exercer-en-france-la-profession-de-médecin-dans-la-spécialité-gériatrie-en-application-des-dispos--2'], ['uriFormat' => 'testing-uri-longer-than-255-chars/{slug}', 'slug' => 'arrêté-du-24-décembre-2020-portant-modification-de-larrêté-du-4-décembre-2020-fixant-la-liste-des-personnes-autorisées-à-exercer-en-france-la-profession-de-médecin-dans-la-spécialité-gériatrie-en-application-des-dispositions-de-larti'], 1],
[['uri' => 'test'], ['uriFormat' => 'test/{slug}']],
[['uri' => 'test/test'], ['uriFormat' => 'test/{slug}', 'slug' => 'test']],
[['uri' => 'test/tes.!@#$%^&*()_t'], ['uriFormat' => 'test/{slug}', 'slug' => 'tes.!@#$%^&*()_t']],
Expand Down

0 comments on commit dc1ceae

Please sign in to comment.