初始版本
This commit is contained in:
62
tests/Feature/ActionTest.php
Normal file
62
tests/Feature/ActionTest.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace DingNotice\Tests\Feature;
|
||||
|
||||
use DingNotice\Tests\TestCase;
|
||||
|
||||
|
||||
class ActionTest extends TestCase
|
||||
{
|
||||
protected $title = "乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身";
|
||||
protected $text = " \n".
|
||||
" #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n".
|
||||
" Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划";
|
||||
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$this->setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* available content to set
|
||||
* @param $content
|
||||
* @return bool
|
||||
* @author wangju 2019-05-17 21:50
|
||||
*/
|
||||
protected function matchContent($content)
|
||||
{
|
||||
return $content['title'] && $content['text'];
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPushActionSingleMessage()
|
||||
{
|
||||
|
||||
$result = $this->ding
|
||||
->actionCard($this->title,$this->text,1)
|
||||
->single("阅读全文","https://www.dingtalk.com/")
|
||||
->send();
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
|
||||
public function testPushActionBtnsMessageAtAllUser(){
|
||||
$result = $result = $this->ding
|
||||
->actionCard($this->title,$this->text,1)
|
||||
->addButtons("内容不错","https://www.dingtalk.com/")
|
||||
->addButtons("不感兴趣","https://www.dingtalk.com/")
|
||||
->send();
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
}
|
62
tests/Feature/FeedTest.php
Normal file
62
tests/Feature/FeedTest.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace DingNotice\Tests\Feature;
|
||||
|
||||
use DingNotice\Tests\TestCase;
|
||||
|
||||
|
||||
class FeedTest extends TestCase
|
||||
{
|
||||
protected $messageUrl = "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI";
|
||||
protected $picUrl = "https://www.dingtalk.com";
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$this->setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* available content to set
|
||||
* @param $content
|
||||
* @return bool
|
||||
* @author wangju 2019-05-17 21:50
|
||||
*/
|
||||
protected function matchContent($content)
|
||||
{
|
||||
if (empty($content)){
|
||||
return false;
|
||||
}
|
||||
return array_reduce($content,function ($carry,$item){
|
||||
if ($carry === null) return true;
|
||||
return $carry && $item['title'] && $item['messageURL'] && $item['picURL'];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPushTextMessage()
|
||||
{
|
||||
$result =$this->ding->text("我就是我,@{$this->testUser} 是不一样的烟火");
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
|
||||
public function testPushTextMessageAtAllUser(){
|
||||
$result =$this->ding
|
||||
->feed()
|
||||
->addLinks('时代的火车向前开',$this->messageUrl,$this->picUrl)
|
||||
->addLinks('时代的火车向前开2',$this->messageUrl,$this->picUrl)
|
||||
->send();
|
||||
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
}
|
48
tests/Feature/LinkTest.php
Normal file
48
tests/Feature/LinkTest.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace DingNotice\Tests\Feature;
|
||||
|
||||
use DingNotice\Tests\TestCase;
|
||||
|
||||
|
||||
class LinkTest extends TestCase
|
||||
{
|
||||
|
||||
protected $title = "自定义机器人协议";
|
||||
protected $text = "群机器人是钉钉群的高级扩展功能。群机器人可以将第三方服务的信息聚合到群聊中,实现自动化的信息同步。例如:通过聚合GitHub,GitLab等源码管理服务,实现源码更新同步;通过聚合Trello,JIRA等项目协调服务,实现项目信息同步。不仅如此,群机器人支持Webhook协议的自定义接入,支持更多可能性,例如:你可将运维报警提醒通过自定义机器人聚合到钉钉群。";
|
||||
protected $picUrl = "";
|
||||
protected $messageUrl = "https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.Rqyvqo&treeId=257&articleId=105735&docType=1";
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$this->setUp();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* available content to set
|
||||
* @param $content
|
||||
* @return bool
|
||||
* @author wangju 2019-05-17 21:50
|
||||
*/
|
||||
protected function matchContent($content)
|
||||
{
|
||||
return $content['text'] && $content['title'] && $content['messageUrl'];
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPushLinkMessage()
|
||||
{
|
||||
$result = $this->ding->link($this->title,$this->text,$this->messageUrl,$this->picUrl);
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
|
||||
}
|
56
tests/Feature/MarkdownTest.php
Normal file
56
tests/Feature/MarkdownTest.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace DingNotice\Tests\Feature;
|
||||
|
||||
use DingNotice\Tests\TestCase;
|
||||
|
||||
|
||||
class MarkDownTest extends TestCase
|
||||
{
|
||||
protected $title = "杭州天气";
|
||||
protected $markdown = "#### 杭州天气 \n ".
|
||||
"> 9度,@1825718XXXX 西北风1级,空气良89,相对温度73%\n\n ".
|
||||
"> \n".
|
||||
"> ###### 10点20分发布 [天气](http://www.thinkpage.cn/) ";
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$this->setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* available content to set
|
||||
* @param $content
|
||||
* @return bool
|
||||
* @author wangju 2019-05-17 21:50
|
||||
*/
|
||||
protected function matchContent($content)
|
||||
{
|
||||
return $content['title'] && $content['text'];
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPushMarkdownMessage()
|
||||
{
|
||||
$result =$this->ding->markdown($this->title,$this->markdown);
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
|
||||
public function testPushMarkdownMessageAtAllUser(){
|
||||
$result =$this->ding
|
||||
->at([],true)
|
||||
->markdown($this->title,$this->markdown);
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
}
|
52
tests/Feature/TextTest.php
Normal file
52
tests/Feature/TextTest.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace DingNotice\Tests\Feature;
|
||||
|
||||
use DingNotice\SendClient;
|
||||
use DingNotice\Tests\TestCase;
|
||||
|
||||
|
||||
class TextTest extends TestCase
|
||||
{
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$this->setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* available content to set
|
||||
* @param $content
|
||||
* @return bool
|
||||
* @author wangju 2019-05-17 21:50
|
||||
*/
|
||||
protected function matchContent($content)
|
||||
{
|
||||
$text = $content['content'];
|
||||
return !empty($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPushTextMessage()
|
||||
{
|
||||
$result =$this->ding->text("我就是我,@{$this->testUser} 是不一样的烟火");
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
|
||||
public function testPushTextMessageAtAllUser(){
|
||||
$result =$this->ding
|
||||
->at([],true)
|
||||
->text("我就是我,@{$this->testUser} 是不一样的烟火");
|
||||
$this->assertSame([
|
||||
'errmsg' => 'ok',
|
||||
'errcode' => 0
|
||||
],$result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user