function test_create_at_invalid() { $_SESSION['active_user'] = array('name' => 'fred', 'id' => 1); $_SESSION['direct_to'] = make_url('messages'); $_POST = array('message' => '@nobody fred sending a message to nobody'); $rmt_mck = new mck_mdl_remotes('sue', 'Big fat human'); $msg = new ctrl_messages(); try { $msg->create($rmt_mck); $this->fail(); } catch(exception $e) { $this->assertEquals(preg_match("/messages/", $e->getMessage()), 1); } // Check that warning message is displayed $msg->__construct(); $msg->index($rmt_mck); $result = $msg->display_outer(true); $this->assertEquals(preg_match('/<h4 id="errors_head">Errors/', $result), 1); $this->assertEquals(preg_match('/User.+not found/', $result), 1); $_SESSION = array(); }
function test_create_logged_in_invalid_url() { $_SESSION['active_user'] = array('name' => 'sue', 'id' => 2); $_POST = array( 'follow_user' => 'invalid_url', 'Submit' => 'Submit'); $rmt_mck = new mck_mdl_remotes('sue', 'Big fat human'); $rel = new ctrl_relations(); try { $rel->create($rmt_mck); $this->fail(); } catch(exception $e) { $this->assertEquals(preg_match("/messages/", $e->getMessage()), 1); } // After redirect, should display error $usr = new ctrl_messages(); $usr->index(); $result = $usr->display_outer(true); $this->assertEquals(preg_match("/url is invalid/", $result), 1); }