2FAuth/tests/Classes/LocalFileFactory.php

52 lines
13 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Classes;
use Illuminate\Http\Testing\File;
class LocalFileFactory {
/**
* Create a new local valid qrcode image.
*
* @return \Illuminate\Http\Testing\File
*/
public function validQrcode()
{
return new File('validQrcode.png', tap(tmpfile(), function ($temp) {
ob_start();
$data = 'iVBORw0KGgoAAAANSUhEUgAAAMYAAADFCAYAAAAPD43zAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAABNjSURBVHhe7ZNBjiW5ksT6/pf+A66H5g0TPJ6iuoIAd5RJkYn3z/8+Pj7+H98P4+ND+H4YHx/C98P4+BC+H8bHh/D9MD4+hO+H8fEhfD+Mjw/h+2F8fAjfD+PjQ/h+GB8fwvfD+PgQ6h/GP//880fYYhuTW9g2Po3diS228UZb6hN26RttsY3JLWwbn8buxBbbeKMt9Qm79I222MbkFraNT2N3YottvNGW+oRd+kZbbGNyC9vGp7E7scU23mhLfcIufaMttjG5hW3j09id2GIbb7SlPmGXvtEW25jcwrbxaexObLGNN9pSn7BL8Rb2FkxY+wtbbAOfxu7EhLV4C3sLttQn7FK8hb0FE9b+whbbwKexOzFhLd7C3oIt9Qm7FG9hb8GEtb+wxTbwaexOTFiLt7C3YEt9wi7FW9hbMGHtL2yxDXwauxMT1uIt7C3YUp+wS/EW9hZMWPsLW2wDn8buxIS1eAt7C7bUJ+xSvIW9BRPW/sIW28CnsTsxYS3ewt6CLfUJuxQT1p6YsBYT1mKLbWCLbWCLbWCLbWDCWkxYe2LCWmypT9ilmLD2xIS1mLAWW2wDW2wDW2wDW2wDE9ZiwtoTE9ZiS33CLsWEtScmrMWEtdhiG9hiG9hiG9hiG5iwFhPWnpiwFlvqE3YpJqw9MWEtJqzFFtvAFtvAFtvAFtvAhLWYsPbEhLXYUp+wSzFh7YkJazFhLbbYBrbYBrbYBrbYBiasxYS1JyasxZb6hF2KCWtPTFiLCWux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052WIbJ7bYBrbYBrY8/p+0R2KLbWzaYhv4NHbnZIttnNhiG9hiG9jy+H/SHokttrFpi23g09idky22cWKLbWCLbWDL4/9JeyS22MamLbaBT2N3TrbYxokttoEttoEtj/8n7ZHYYhubttgGPo3dOdliGye22Aa22Aa21CfsUnwauxMT1mKLbZyYsBZbbANbbAOfxu7EW9Q32+PxaexOTFiLLbZxYsJabLENbLENfBq7E29R32yPx6exOzFhLbbYxokJa7HFNrDFNvBp7E68RX2zPR6fxu7EhLXYYhsnJqzFFtvAFtvAp7E78Rb1zfZ4fBq7ExPWYottnJiwFltsA1tsA5/G7sRb1Dfb4/Fp7E5MWIsttnFiwlpssQ1ssQ18GrsTb7F2s33UiS22gS22cWLCWmyxDUxYi1vY9qYJaydb1v5C9pgTW2wDW2zjxIS12GIbmLAWt7DtTRPWTras/YXsMSe22Aa22MaJCWuxxTYwYS1uYdubJqydbFn7C9ljTmyxDWyxjRMT1mKLbWDCWtzCtjdNWDvZsvYXssec2GIb2GIbJyasxRbbwIS1uIVtb5qwdrJl7S9kjzmxxTawxTZOTFiLLbaBCWtxC9veNGHtZMveX2gJ+6jJhLWTCWsxYe3kFrb9C29hb8Et7n1ZwD52MmHtZMJaTFg7uYVt/8Jb2Ftwi3tfFrCPnUxYO5mwFhPWTm5h27/wFvYW3OLelwXsYycT1k4mrMWEtZNb2PYvvIW9Bbe492UB+9jJhLWTCWsxYe3kFrb9C29hb8Et7n1ZwD52MmHtZMJaTFg7uYVt/8Jb2Ftwi2tfZh+FLbaxaYttTLbYxmTCWtzCtnEL28Yt9pZK7KOwxTY2bbGNyRbbmExYi1vYNm5h27jF3lKJfRS22MamLbYx2WIbkwlrcQvbxi1sG7fYWyqxj8IW29i0xTYmW2xjMmEtbmHbuIVt4xZ7SyX2UdhiG5u22MZki21MJqzFLWwbt7Bt3GJvqcQ+CltsY9MW25hssY3JhLW4hW3jFraNW6wt2SMxYe2JCW
$data = base64_decode($data);
$image = imagecreatefromstring($data);
imagepng($image);
fwrite($temp, ob_get_clean());
}));
}
/**
* Create a new local invalid qrcode image.
*
* @return \Illuminate\Http\Testing\File
*/
public function invalidQrcode()
{
return new File('invalidQrcode.png', tap(tmpfile(), function ($temp) {
ob_start();
$data = 'iVBORw0KGgoAAAANSUhEUgAAALcAAAC5CAYAAABqZK7vAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAA7nSURBVHhe7Z07r+RIFcf7vmaB0TyEBAlkRLCEsLyCmS8AGRFfDwiACD7BBCvQgsgWQhIQ0kIwO1e7aGfuA//dPn2rq0+5TrnKr/L/J/na3a53/X18qsrte3bfsCOkQs67PSHVQXGTaqG4SbVQ3KRaKG5SLRQ3qRaKm1QLxU2qheIm1WJeoTw7O+uO5se6qKqVOWdB1toGOeXT0NLLqVvpuHMRKzMtN6kWiptUC8VNqoXiJtWSNaC0DkJysOZrHegsKa5GTjuXLotGTvlyGJIvLTepFoqbVAvFTaqF4ibVUnxAaR3UaFjTMxa5eFk0cspnJaceVkrXt3TbD2lnWm5SLRQ3qRaKm1QLxU2qpZoBpTXfKfKwouVhxVpmjaW3VU6+LhR3gxv391/7Rrt/8eJFuwdPf/urdp9TNw1j06tY20WjVFsJOf2hkZOvC8XdgLgiasEVt/Dq1avuaLf72X/+1R0Nx9j0KtZ20chtK5+c/tDIyddl0z73m5//ot18YVtAHNnIMtmkuEXUfaRYHop8mVS9QukiYnZdC0FcEOQlaWvhXr58eZK3Fu6nn/yzO3qgVD2E0v1hLUvpfDWs6cXKvAnLHbPSQqyxrAKw3BnI+FQv7jlFRoHPS9XiXoK4KPD52PRsSS5Wv5ICn4fiA8rSDB3AYPYiNlctaOGQXl/95LyWXh9D5sdz2rl0v5VOz8qQfKu03CWm5WINN7RDOWU4HdWJew3iQRkp8vGhz02qpSpxr80a0oKPS9aAci60Iv/h69/sjh7IGVDmhpMBpxBLr+/JQ62+Swo3F1r5XOiWjESs4X0wXcgpw7JUIe4+UVgs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HaC14YxEPizx9HdKcO5zt6xCck3Tc40TQ6eriU4PMZ8eEvSVWJ+4p5mpFKCEhuSAEpAqrpIYWMWeIGqAsd4HoFLbOai137BZnvQUCPyymCE+e/YY4A+BM+Gw+/kXmPjsCYaO88vwIhf3AKsUN6x3zy1L8Ni0srCBWMd/c3bXiuh1idH1r7X+24M2G4KLDVB/cp3b77nf2Jxoo7GOyBpRWrEJLyWPo+zesK5kyGJXXIbi/nrf+uhyhpOYSw22J3vo6ovafD4GV9gfLELbWzloeOf0xRdxSrNYtmQL3PR+wmOKqWHxxdK0fyty1jbAhaNkEcT9c4UDUtNg6qxX3FB0qAzQXEXnrqhjl6towUwzvTbSuT+1CUfezass9Z+eKyMUnF3DrFavtCvlw3Jw/XBj4NRDcD8+vFkKifvKbX1LYBlYtbrCEThaRY3On63AoH0XQR9N57nEn8rMnT9pNAwPprT22msOiBpQ5oHyWQaYMKBHeUq7Yq3/x9lSXZ401vvrRD9rjmz991JjZJ7v7N292nzbCt+C/SOerf/trd3SMtT+0OmpxreE0SvdvqXxXb7ldUqy4pUOsjQzfXLaTONfXrdjdMH2buCIhl4TYqUrcoKSbEroAXPFBkMJP3vvy7sMv/tcew2pfJjxKG2Jr/8emJNWJG0DgspUCiyWp1nSowK13DNJPleJ2cYWOLWVAhrAi6pgb41rtXEr7sFul+IDS2jE51knLQ0vPGk7AgNS39u4gVVvdlJVCV9xyHBN8X3ouCOdflNb6TkFOWaw6GFK36i13Cr6wgfYdWQcU90C2+r8d1wTFbSBkvSFw///MWF2SVDhrkg7FPQDfav/40Zd2r29vN/cPlZbOJL+htDJk0CCULp8WV6ynL26sQJ49fdru3dXJEvPcQAaZS/X/p+i3IdByJ4COCPra19cnHdX3WetUgO9D50gaFHcCeB
$data = base64_decode($data);
$image = imagecreatefromstring($data);
imagepng($image);
fwrite($temp, ob_get_clean());
}));
}
}