|
@@ -1,4 +1,6 @@
|
|
|
-<?php
|
|
|
+<?php declare(strict_types=1);
|
|
|
+
|
|
|
+use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
@@ -8,11 +10,44 @@
|
|
|
*/
|
|
|
define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
|
|
|
|
|
|
+require_once(BASE_ROOT_PATH . '/global.php');
|
|
|
+require_once(BASE_CORE_PATH . '/lrlz.php');
|
|
|
require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
-require_once(BASE_ROOT_PATH . '/helper/tools/image_scaler.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/tools/image_scaler.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/util_helper.php');
|
|
|
+
|
|
|
|
|
|
-class TestGD extends PHPUnit_Framework_TestCase
|
|
|
+class TestGD extends TestCase
|
|
|
{
|
|
|
+ public static function setUpBeforeClass() : void
|
|
|
+ {
|
|
|
+ Base::run_util();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testShare()
|
|
|
+ {
|
|
|
+ $this->create_shareimage(52620);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function create_shareimage($uid)
|
|
|
+ {
|
|
|
+ $back_img = BASE_RESOURCE_PATH . '/mobile/member/images/share.png';
|
|
|
+ $passwd = util::passwd;
|
|
|
+ $name = md5("{$uid}.{$passwd}") . ".png";
|
|
|
+ $mini_path = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
|
|
|
+
|
|
|
+ $name = "share-{$name}";
|
|
|
+ $dest_img = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
|
|
|
+
|
|
|
+ $back = $this->create_image($back_img);
|
|
|
+ $mini = $this->create_image($mini_path);
|
|
|
+
|
|
|
+ $dest = imagecreatetruecolor(imagesx($back), imagesy($back));
|
|
|
+ imagecopy($dest,$back, 0, 0, 0,0, imagesx($back), imagesy($back));
|
|
|
+ imagecopyresized($dest,$mini, 30, 648, 0,0, 168,168,imagesx($mini), imagesy($mini));
|
|
|
+ imagepng($dest, $dest_img);
|
|
|
+ }
|
|
|
+
|
|
|
public function testMerge()
|
|
|
{
|
|
|
$back_img = BASE_UPLOAD_PATH . '/tmp/back.jpg';
|
|
@@ -20,11 +55,13 @@ class TestGD extends PHPUnit_Framework_TestCase
|
|
|
$dest_img = BASE_UPLOAD_PATH . '/tmp/dest.jpg';
|
|
|
|
|
|
$back = imagecreatefromjpeg($back_img);
|
|
|
- $icon = imagecreatefrompng($icon_img);
|
|
|
- imageinterlace($back);
|
|
|
|
|
|
+ $icon = imagecreatefrompng($icon_img);
|
|
|
imagecopy($back, $icon, 60, 60, 0, 0, imagesx($icon), imagesy($icon));
|
|
|
imagejpeg($back, $dest_img,100);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function testMini()
|