Skip to content

Commit

Permalink
fix #126
Browse files Browse the repository at this point in the history
  • Loading branch information
uyab committed Mar 25, 2021
1 parent 90b1434 commit 66d0330
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public function create($name)
{
$this->name = $name;

$this->initTheme();
$this->setForeground($this->getRandomForeground());
$this->setBackground($this->getRandomBackground());
$this->setFont($this->getRandomFont());

return $this;
}
Expand Down Expand Up @@ -418,7 +420,7 @@ protected function getRandomElement($array, $default)

$name = $this->name;
if (strlen($name) === 0) {
$name = chr(rand(65, 90));
$name = 'laravolt';
}

if (count($array) == 0) {
Expand Down
12 changes: 6 additions & 6 deletions tests/AvatarPhpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ public function it_can_resolve_random_themes_and_then_overrides()
'theme' => '*',
'themes' => [
'dark' => [
'backgrounds' => ['#000000', '#111111'],
'foregrounds' => ['#EEEEEE', '#FFFFFF'],
'backgrounds' => ['#000000'],
'foregrounds' => ['#EEEEEE'],
],
'light' => [
'backgrounds' => ['#FFFFFF', '#EEEEEE'],
'foregrounds' => ['#000000', '#111111'],
'backgrounds' => ['#FFFFFF'],
'foregrounds' => ['#000000'],
],
]
];
Expand All @@ -113,8 +113,8 @@ public function it_can_resolve_random_themes_and_then_overrides()
$avatar1 = new \Laravolt\Avatar\Avatar($config);
$avatar1->create($name1)->buildAvatar();

$this->assertEquals('#000000', $avatar1->getAttribute('background'));
$this->assertEquals('#EEEEEE', $avatar1->getAttribute('foreground'));
$this->assertEquals('#FFFFFF', $avatar1->getAttribute('background'));
$this->assertEquals('#000000', $avatar1->getAttribute('foreground'));

$avatar1->setTheme('light')->buildAvatar();
$this->assertEquals('#FFFFFF', $avatar1->getAttribute('background'));
Expand Down

0 comments on commit 66d0330

Please sign in to comment.