コード例 #1
0
ファイル: AvatarTest.php プロジェクト: explore-laravel/avatar
 /**
  * @test
  */
 public function it_can_override_attributes_after_set_name()
 {
     $cache = Mockery::mock('Illuminate\\Cache\\CacheManager');
     $generator = Mockery::mock('Laravolt\\Avatar\\InitialGenerator');
     $generator->shouldReceive('setName')->andReturnSelf();
     $generator->shouldReceive('setLength');
     $generator->shouldReceive('getInitial')->andReturn('A');
     $generator->shouldReceive('base_path');
     $config = ['backgrounds' => ['#000000', '#111111'], 'foregrounds' => ['#EEEEEE', '#FFFFFF']];
     $avatar = new \Laravolt\Avatar\Avatar($config, $cache, $generator);
     $avatar->setFontFolder(['fonts/']);
     $avatar->create('A');
     $this->assertAttributeEquals('#FFFFFF', 'foreground', $avatar);
 }
コード例 #2
0
ファイル: AvatarTest.php プロジェクト: yhbyun/avatar
 /**
  * @test
  */
 public function it_has_different_random_background()
 {
     $config = ['backgrounds' => ['#000000', '#111111']];
     $cache = Mockery::mock('Illuminate\\Cache\\CacheManager');
     $generator = Mockery::mock('Laravolt\\Avatar\\InitialGenerator');
     $generator->shouldReceive('setUppercase')->andReturnSelf();
     $name1 = 'AA';
     $name2 = 'AAA';
     $generator->shouldReceive('setLength')->andReturn(2);
     $generator->shouldReceive('setName')->andReturn($name1);
     $generator->shouldReceive('getInitial')->andReturn('AA');
     $avatar1 = new \Laravolt\Avatar\Avatar($config, $cache, $generator);
     $avatar1->setFontFolder(['fonts/']);
     $avatar1->create($name1);
     $generator->shouldReceive('setName')->andReturn($name2);
     $avatar2 = new \Laravolt\Avatar\Avatar($config, $cache, $generator);
     $avatar2->setFontFolder(['fonts/']);
     $avatar2->create($name2);
     $this->assertAttributeEquals('#000000', 'background', $avatar1);
     $this->assertAttributeEquals('#111111', 'background', $avatar2);
 }