Skip to content

Commit

Permalink
Change visibility generateId() method. (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 12, 2024
1 parent a194ad9 commit 059d87c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 deletions.
2 changes: 1 addition & 1 deletion src/Attribute/HasId.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function id(string|null $value): static
*
* @return string|null A unique ID for the widget.
*/
public function generateId(string $value = 'id_'): string|null
protected function generateId(string $value = 'id_'): string|null
{
return $this->id === '' ? uniqid($value) : $this->id;
}
Expand Down
29 changes: 0 additions & 29 deletions tests/Attribute/HasIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,4 @@ public function testImmutability(): void

$this->assertNotSame($instance, $instance->id(''));
}

public function testGenerateId(): void
{
$instance = new class () {
use HasId;

protected array $attributes = [];
};

$instance = $instance->id('');

$this->assertNotEmpty($instance->generateId());
$this->assertMatchesRegularExpression('/^id_[a-z0-9]{13}$/', $instance->generateId());
$this->assertMatchesRegularExpression('/^alert_[a-z0-9]{13}$/', $instance->id('')->generateId('alert_'));
}

public function testGenerateIdWithId(): void
{
$instance = new class () {
use HasId;

protected array $attributes = [];
};


$instance = $instance->id('foo');

$this->assertSame('foo', $instance->generateId());
}
}

0 comments on commit 059d87c

Please sign in to comment.