public function testCanSaveFiles()
 {
     $am = AvatarFactory::createAvatarMaker('circle', 16);
     /** @todo This line shouldn't be needed */
     $am->setFontFile(__DIR__ . '/../demo/arial.ttf');
     $root = vfsStream::setup('exampleDir');
     $this->assertEquals(false, $root->hasChild('test.png'));
     $am->makeAvatar('Bob Smith')->save(vfsStream::url('exampleDir/test.png'));
     $this->assertEquals(true, $root->hasChild('test.png'));
     $res = imagecreatefrompng(vfsStream::url('exampleDir/test.png'));
     $this->assertEquals(16, imagesx($res));
     $this->assertEquals(16, imagesy($res));
 }
Beispiel #2
0
            padding: 0;
        }

        div {
            float: left;
            padding: 1%;
            margin: 1%;
            width: 25%;
            border: 1px solid #ddd;
        }

        img {
            float: right;
        }

    </style>
</head>
<body>
<?php 
foreach (['circle' => 'John Doe', 'diamond' => 'J. D.', 'random' => '*****@*****.**', 'rectangle' => '"Bob"', 'column' => 'John, Alice', 'rhomb' => \PHP_VERSION] as $shape => $name) {
    $avatar = \Shift\AvatarMaker\Factory\AvatarFactory::createAvatarMaker($shape, 64);
    $avatar->setBackgroundLuminosity('bright');
    $avatar->setHues(['red', 'orange']);
    $avatar->setFontFile('segoeui.ttf');
    $img = $avatar->makeAvatar($name)->toBase64();
    printf('<div><img alt="Avatar" src="%s"/><p>%s</p></div>', $img, $name);
}
?>
</body>
</html>
 /**
  * @expectedException InvalidArgumentException
  */
 public function testCannotInstantiateAvatarMakerWithInvalidShape()
 {
     AvatarFactory::createAvatarMaker('bogus');
 }