public function testSendTest() { $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest'); $entity->shouldReceive('send')->once(); $data = array('room_id' => 'hippy', 'from' => 'rcrowe', 'message' => 'hello world', 'message_format' => Message::FORMAT_TEXT, 'notify' => true, 'color' => Message::BACKGROUND_GREEN, 'format' => 'json'); $http = m::mock('Guzzle\\Http\\Client'); $http->shouldReceive('post')->with('rooms/message?format=json&auth_token=123', array('Content-type' => 'application/x-www-form-urlencoded'), http_build_query($data))->andReturn($entity)->once(); $transport = new Guzzle('123', 'hippy', 'rcrowe'); $transport->setHttp($http); $task = new PhingTask(); $project = m::mock('Project'); $project->shouldReceive('getProperty')->with('hipchat.notify')->andReturn(true)->once(); $project->shouldReceive('getProperty')->with('hipchat.background')->andReturn(Message::BACKGROUND_GREEN)->once(); $task->setProject($project); $task->setMsg($data['message']); $task->main($transport); }
public function testSetMsg() { $task = new PhingTask(); $task->setMsg('hello world'); $task->setMessage('test 2'); $task->setText('five spice'); $task->setHtml('<a href="#">egg and spoon race</a>'); $reflect = new ReflectionObject($task); $property = $reflect->getProperty('msgStore'); $property->setAccessible(true); $store = $property->getValue($task); $this->assertTrue(count($store) === 4); $this->assertEquals($store[0]['format'], Message::FORMAT_TEXT); $this->assertEquals($store[0]['msg'], 'hello world'); $this->assertEquals($store[1]['format'], Message::FORMAT_TEXT); $this->assertEquals($store[1]['msg'], 'test 2'); $this->assertEquals($store[2]['format'], Message::FORMAT_TEXT); $this->assertEquals($store[2]['msg'], 'five spice'); $this->assertEquals($store[3]['format'], Message::FORMAT_HTML); $this->assertEquals($store[3]['msg'], '<a href="#">egg and spoon race</a>'); }