From 6d66b079325d9e162973171f3fc123f2d14b1ac2 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Fri, 3 Feb 2023 10:09:25 +0800 Subject: [PATCH] + Add test case. --- test/model/admin/checkinternet.php | 19 +++++++++++++++++ test/model/admin/fetchapi.php | 26 ++++++++++++++++++++++++ test/model/admin/getextensionsbyapi.php | 19 +++++++++++++++++ test/model/admin/getpublicclassbyapi.php | 19 +++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 test/model/admin/checkinternet.php create mode 100644 test/model/admin/fetchapi.php create mode 100644 test/model/admin/getextensionsbyapi.php create mode 100644 test/model/admin/getpublicclassbyapi.php diff --git a/test/model/admin/checkinternet.php b/test/model/admin/checkinternet.php new file mode 100644 index 0000000000..e8f9ce2b60 --- /dev/null +++ b/test/model/admin/checkinternet.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +> 1 + +*/ + +global $tester; +$tester->loadModel('admin'); +$result = (int)$tester->admin->checkInternet(); + +r($result) && p() && e('1'); // 验证网络连接 diff --git a/test/model/admin/fetchapi.php b/test/model/admin/fetchapi.php new file mode 100644 index 0000000000..976778cc52 --- /dev/null +++ b/test/model/admin/fetchapi.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +> 1 +错误的API地址 >> 0 + +*/ + +global $tester; +$tester->loadModel('admin'); + +$realURL = 'https://www.zentao.net/publicclass.json'; +$invalidURL = 'https://test.zentao.net/publicclass.json'; + +$result1 = (int)!empty($tester->admin->fetchAPI($realURL)); +$result2 = (int)$tester->admin->fetchAPI($invalidURL); + +r($result1) && p() && e('1'); // 正确的API地址 +r($result2) && p() && e('0'); // 错误的API地址 diff --git a/test/model/admin/getextensionsbyapi.php b/test/model/admin/getextensionsbyapi.php new file mode 100644 index 0000000000..51ab19d423 --- /dev/null +++ b/test/model/admin/getextensionsbyapi.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +> 3 + +*/ + +global $tester; +$tester->loadModel('admin'); +$result = $tester->admin->getExtensionsByAPI('extension', 6, false); + +r(count($result)) && p() && e('3'); // 查询断网情况插件数量 diff --git a/test/model/admin/getpublicclassbyapi.php b/test/model/admin/getpublicclassbyapi.php new file mode 100644 index 0000000000..f90a8ab0bb --- /dev/null +++ b/test/model/admin/getpublicclassbyapi.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +> 2 + +*/ + +global $tester; +$tester->loadModel('admin'); +$result = $tester->admin->getPublicClassByAPI(); + +r(count($result)) && p() && e('2'); // 查询公开课程数量