-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Please add some unit tests.
For example, in https://github.com/vtmer/vtmer-wechat/blob/da696d2dbb8646aa2318e0e4a5a4dd4dc2a4e4aa/app/controllers/WeixinEventHandler.php#L11,L30 , you can add a simple layer for retrieving contact information:
<?php
$name = WeixinInput::get('content');
$contact = Contact::findByName($name);
$message = WeixinMessage:text(/* xxx */, View::render('contact_card', $contact));
return Response::xml($message);Then you can test Contact on method findByName:
<?php namespace Test\Contact;
use Contact;
class ContactTest extends \TestCase
{
public function testFindByName()
{
// You may mock your contact model first.
$contact = $this->mockContact();
$contact->shouldReceive('where')->andReturn($contact)->shouldReceive('first')->andReturn($contact);
$this->assertEquals($contact, Contact::findByName('test'));
}
}References:
Reactions are currently unavailable