提交 eb721058 编写于 作者: Y yuenblue

aaa

上级 f4b5413b
......@@ -9,6 +9,8 @@ composer create-project thinkcmf/thinkcmf=~6.0 demothinkcmf6
composer create-project thinkcmf/thinkcmf=~8.0 demothinkcmf8
ln -s /usr/local/etc/php/8.2/ php82
/usr/local/opt/mysql@5.7/bin/mysqld_safe --datadir\=/usr/local/var/mysql
./vendor/bin/phpunit -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_host=localhost -dxdebug.client_port=9003 tests/DemoTest.php
php -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_host=localhost -dxdebug.client_port=9003 index.php
php ../phpunit-10.5.13.phar tests/DemoTest.php
......
<?php
// class Outer {
// // 外部类的成员变量和方法
// class Inner {
// // 内部类的成员变量和方法
// }
// }
// class Outer{
// public $aa=null;
// function __construct()
// {
// $this->aa='aaaa';
// }
// function say(){
// print $this->aa;
// }
// class Inner{
// }
// }
// $outer = new Outer();
// $outer->say();
\ No newline at end of file
<?php
namespace app;
enum UserState:int{
case Aa=0;
case Bb=1;
case Cc=2;
public function label(): string{
return match ($this) {
static::Aa => "啊啊啊Aa",
static::Bb => "哦哦哦Bb",
static::Cc => "uuuCc",
};
}
}
class User{
function say() {
print "hello";
print UserState::Aa->label();
}
}
\ No newline at end of file
......@@ -2,11 +2,17 @@
use PHPUnit\Framework\TestCase;
use app\User;
use app\UserState;
use Monolog\Level;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use PgSql\Lob;
use function PHPUnit\Framework\assertTrue;
class DemoTest extends TestCase
{
function tearDown(): void
......@@ -16,12 +22,19 @@ class DemoTest extends TestCase
public function testAaa(){
$user=new User();
$user->say();
print UserState::Cc->name;
$aa =11;
}
function testInnerClass(){
}
function testLog() {
// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('php://stdout', Level::Warning));
$log->pushHandler(new StreamHandler('php://stdout'),Level::Warning);
// add records to the log
$log->warning('Foo');
......
<?php
namespace app\model;
use think\Model;
enum UserState:int{
case Inactive=0;
case Activated=1;
case Frozen=2;
public function label(): string{
return match ($this) {
static::Inactive => "未激活",
static::Activated => "已激活",
static::Frozen => "已冻结",
};
}
}
final class User extends Model
{
......
......@@ -2,6 +2,7 @@
namespace think;
use app\model\User;
use app\model\UserState;
use PHPUnit\Framework\TestCase;
use think\facade\Cache;
use think\facade\Config;
......@@ -38,11 +39,16 @@ class DemoTp6 extends TestCase{
$cc=env("database.HOSTPORT");
var_dump($bb,$cc);
}
function test_select_user() {
$user = User::find(3);
// print UserState::from($user->status)->label();
}
function test_createData() {
$user =new User();
$user->username='aaaa';
$user->password='bbbb';
$user->status=UserState::Activated->value;
$user->save();
}
function test_modal() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册