diff --git a/.gitignore b/.gitignore index c2f4ab1..046d499 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ composer.lock .idea/ vendor/ -tests/ +tests/prikey.pem diff --git a/composer.json b/composer.json index 63dfe79..03a2e47 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "maiyoule/mqttclient_author", "type": "library", "description": "MQTT管理模块操作库", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "authors": [ { diff --git a/tests/AppManagerTest.php b/tests/AppManagerTest.php new file mode 100644 index 0000000..d5867c1 --- /dev/null +++ b/tests/AppManagerTest.php @@ -0,0 +1,74 @@ +manager = new MQTTManager(); + $this->manager->setAppId('6MMVTLW66D'); + $this->manager->setPrivateKey(file_get_contents(__DIR__ . '/prikey.pem')); + $this->manager->setApi('http://localhost:8000/api/'); + $this->manager->setDebug(true); + } + + + public function testRunUser() + { + + + try { + $request = new AppUserCreateRequest(); + $request->setPassword('111'); + $request->setFettle(''); + $request->setRole('admin'); + $request->setBiz(['ch','ws']); + + $biz = $this->manager->exec($request); + if (!$biz->isSuccess()) { + $this->fail($biz->getMessage()); + } + $data = $biz->getData(); + + //更改 + $username = $data['username']; + + $request = new AppUserUpdateRequest(); + $request->setUsername($username); + $request->setPassword('123'); + $request->setState(false); + $request->setRole('user'); + $request->setBiz(['ch']); + + $biz = $this->manager->exec($request); + if (!$biz->isSuccess()) { + $this->fail($biz->getMessage()); + } + $data = $biz->getData(); + + //print_r($data); + //删除 + $request = new AppUserDeleteRequest(); + $request->setUsername($username); + + $biz = $this->manager->exec($request); + + $this->assertTrue($biz->isSuccess(), $biz->getMessage()); + + } catch (ApiException $e) { + $this->fail($e->getMessage()); + } + } + +}