<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[1122] sites/trunk: Move Slack libraries into the proper place, also adding some new in the process.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/1122">1122</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/1122","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>nacin</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-01-11 11:21:12 +0000 (Sun, 11 Jan 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Move Slack libraries into the proper place, also adding some new in the process.</pre>
<h3>Added Paths</h3>
<ul>
<li>sites/trunk/api.wordpress.org/public_html/dotorg/</li>
<li>sites/trunk/api.wordpress.org/public_html/dotorg/slack/</li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgslackannouncephp">sites/trunk/api.wordpress.org/public_html/dotorg/slack/announce.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgslackcommittersphp">sites/trunk/api.wordpress.org/public_html/dotorg/slack/committers.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgslacknewticketphp">sites/trunk/api.wordpress.org/public_html/dotorg/slack/new-ticket.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmldotorgslacktracbotphp">sites/trunk/api.wordpress.org/public_html/dotorg/slack/trac-bot.php</a></li>
<li>sites/trunk/common/includes/slack/</li>
<li><a href="#sitestrunkcommonincludesslackautoloadphp">sites/trunk/common/includes/slack/autoload.php</a></li>
<li>sites/trunk/common/includes/tests/</li>
<li>sites/trunk/common/includes/tests/slack/</li>
<li>sites/trunk/common/includes/tests/slack/trac/</li>
<li><a href="#sitestrunkcommonincludestestsslacktracbotphp">sites/trunk/common/includes/tests/slack/trac/bot.php</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>sites/trunk/svn.wordpress.org/includes/slack-trac-hooks/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkapiwordpressorgpublic_htmldotorgslackannouncephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/api.wordpress.org/public_html/dotorg/slack/announce.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/slack/announce.php (rev 0)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/slack/announce.php 2015-01-11 11:21:12 UTC (rev 1122)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,36 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace {
+ require dirname( dirname( __DIR__ ) ) . '/includes/hyperdb/bb-10-hyper-db.php';
+ require dirname( __DIR__ ) . '/slack-config.php';
+}
+
+namespace Dotorg\Slack\Announce {
+
+require dirname( dirname( __DIR__ ) ) . '/includes/slack/announce/lib.php';
+require dirname( dirname( __DIR__ ) ) . '/includes/slack/announce/config.php';
+
+function get_avatar( $username, $slack_id, $team_id ) {
+ global $wpdb;
+
+ $wp_user_id = $wpdb->get_var( $wpdb->prepare(
+ "SELECT user_id FROM slack_invites WHERE slack_id = %s",
+ $slack_id
+ ) );
+
+ $email = $wpdb->get_var( $wpdb->prepare(
+ "SELECT user_email FROM $wpdb->users WHERE ID = %d",
+ $wp_user_id
+ ) );
+
+ $hash = md5( strtolower( trim( $email ) ) );
+ return sprintf( 'https://secure.gravatar.com/avatar/%s?s=96d=mm&r=G', $hash );
+}
+
+if ( $_POST['token'] !== WEBHOOK_TOKEN ) {
+ return;
+}
+
+run( $_POST );
+
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/api.wordpress.org/public_html/dotorg/slack/announce.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkapiwordpressorgpublic_htmldotorgslackcommittersphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/api.wordpress.org/public_html/dotorg/slack/committers.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/slack/committers.php (rev 0)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/slack/committers.php 2015-01-11 11:21:12 UTC (rev 1122)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,32 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+// Allow committers to publicly mention other committers via @committers.
+
+namespace Dotorg\Slack\Committers;
+
+require dirname( __DIR__ ) . '/slack-config.php';
+
+if ( $_POST['token'] !== WEBHOOK_TOKEN ) {
+ return;
+}
+
+// These should be Slack usernames.
+switch ( $_POST['channel_name'] ) {
+ case 'bbpress' :
+ case 'buddypress' :
+ case 'glotpress' :
+ return;
+ default:
+ $committers = array(
+ 'westi', 'azaozz', 'nb', 'josephscott', 'dd32', 'nacin', 'koop', 'duck_',
+ 'helen', 'sergeybiryukov', 'ocean90', 'wonderboymusic', 'drew', 'mark',
+ 'johnbillion', 'kovshenin', 'jorbin', 'boone', 'jeremyfelt', 'pento',
+ );
+ break;
+}
+
+if ( in_array( $_POST['user_name'], $committers, true ) ) {
+ $notify = array_diff( $committers, array( $_POST['user_name'] ) );
+ $notify = '(cc: @' . implode( ' @', $notify ) . ')';
+ echo json_encode( array( 'text' => $notify, 'username' => $_POST['user_name'], 'link_names' => 1 ) );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/api.wordpress.org/public_html/dotorg/slack/committers.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkapiwordpressorgpublic_htmldotorgslacknewticketphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/api.wordpress.org/public_html/dotorg/slack/new-ticket.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/slack/new-ticket.php (rev 0)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/slack/new-ticket.php 2015-01-11 11:21:12 UTC (rev 1122)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,37 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace Dotorg\Slack\Trac;
+use Dotorg\Slack\Send;
+
+require dirname( __DIR__ ) . '/slack-config.php';
+
+if ( 'cli' === PHP_SAPI ) {
+ if ( $argc !== 3 ) {
+ echo "Usage: <trac> <ticket>\n";
+ exit( 1 );
+ }
+
+ list( , $trac_slug, $ticket ) = $argv;
+} else {
+ if ( $_REQUEST['token'] !== URL_SECRET__NEW_TICKET ) {
+ return;
+ }
+ $trac_slug = preg_replace( '/[^a-z]/', '', $_POST['trac'] );
+ $ticket = (int) $_POST['ticket'];
+}
+
+$trac = Trac::get( $trac_slug );
+$new_ticket = new New_Ticket( $trac, $ticket );
+
+foreach ( $trac->get_ticket_channels( $new_ticket ) as $channel ) {
+ $send = new Send( \Dotorg\Slack\Send\WEBHOOK );
+ $send->set_user( $new_ticket );
+
+ if ( 'title' === $trac->get_ticket_format( $channel ) ) {
+ $send->set_text( $new_ticket->get_text() );
+ } else {
+ $send->add_attachment( $new_ticket->get_attachment() );
+ }
+
+ $send->send( $channel );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/api.wordpress.org/public_html/dotorg/slack/new-ticket.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkapiwordpressorgpublic_htmldotorgslacktracbotphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/api.wordpress.org/public_html/dotorg/slack/trac-bot.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/dotorg/slack/trac-bot.php (rev 0)
+++ sites/trunk/api.wordpress.org/public_html/dotorg/slack/trac-bot.php 2015-01-11 11:21:12 UTC (rev 1122)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,116 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace {
+ require dirname( dirname( __DIR__ ) ) . '/includes/hyperdb/bb-10-hyper-db.php';
+ require dirname( dirname( __DIR__ ) ) . '/includes/object-cache.php';
+
+ require dirname( __DIR__ ) . '/slack-config.php';
+
+ require WPORGPATH . 'bb-theme/themes/lib/class-IXR.php';
+ require WPORGPATH . 'bb-theme/themes/lib/class-trac.php';
+}
+
+namespace Dotorg\Slack\Trac {
+
+ // Verify it came from Slack.
+ if ( ! isset( $_GET['token'] ) || $_GET['token'] !== URL_SECRET__TRAC_BOT ) {
+ return;
+ }
+
+ // Prevent recursion.
+ if ( $_POST['user_name'] === 'slackbot' ) {
+ return;
+ }
+
+ $parser = new Bot( $_POST );
+ $parsed = $parser->parse();
+ $parser->avoid_redundancy();
+ # $parser->set_redundancy( 'slack', 'core', 'ticket', 12345 );
+
+ $comment_template = 'This ticket was mentioned in [https://make.wordpress.org/chat/ Slack] in #%1$s by %2$s. [https://wordpress.slack.com/archives/%1$s/p%3$s View the logs].';
+ $comment_template = "''$comment_template''"; // Italics.
+
+ $ticket_class = '\Dotorg\Slack\Trac\Ticket';
+ $commit_class = '\Dotorg\Slack\Trac\Commit';
+
+ // Loop through all results, grouped by Trac and then by type (commit versus ticket).
+ foreach ( $parsed as $trac => $results ) {
+ $trac_obj = Trac::get( $trac );
+ $slack = new \Dotorg\Slack\Send( \Dotorg\Slack\Send\WEBHOOK );
+ $slack->set_user( $trac_obj );
+
+ foreach ( $results as $type => $values ) {
+ // Loop through all tickets and commits for this Trac.
+ foreach ( $values as $value ) {
+ $id = is_array( $value ) ? $value['id'] : $value;
+
+ $class = 'commit' === $type ? $commit_class : $ticket_class;
+ // Get the Ticket or Commit object for this Trac + ID.
+ $obj = call_user_func( array( $class, 'get' ), $trac_obj, $id );
+
+ // Check if we should be posting this to Slack so quickly.
+ if ( $since = $parser->is_redundant( 'slack', $trac, $type, $id ) ) {
+ // If we should not be posting the whole thing, see if it's been long enough to post a link (only if we did not parse a link).
+ if ( ( ( $since + $parser::slack_repost_link ) < time() ) && empty( $value['url'] ) ) {
+ $slack->add_attachment( array(
+ 'text' => $obj->get_url(),
+ 'fallback' => $obj->get_url(),
+ ) );
+ // Reset redundancy time since we just posted a link.
+ $parser->set_redundancy( 'slack', $trac, $type, $id );
+ }
+ // We were redundant, skip the rest.
+ continue;
+ }
+
+ $attachment = $obj->get_attachment();
+
+ if ( $attachment ) {
+ $parser->set_redundancy( 'slack', $trac, $type, $id );
+ $slack->add_attachment( $attachment );
+ } else {
+ // We don't have an attachment when the Trac is private or if we experienced an error.
+ // Don't set redundancy times on errors.
+ if ( ! $this->trac->is_public() ) {
+ $parser->set_redundancy( 'slack', $trac, $type, $id );
+ }
+
+ // Provide a URL link only if we did not parse a link.
+ if ( empty( $value['url'] ) ) {
+ $slack->add_attachment( array(
+ 'text' => $obj->get_url(),
+ 'fallback' => $obj->get_url(),
+ ) );
+ }
+ }
+ }
+ }
+
+ // It's possible that all of our tickets/commits were redundant and thus skipped.
+ if ( ! $slack->get_attachments() ) {
+ continue;
+ }
+
+ $slack->send( $parser->get_channel() );
+
+ if ( $_POST['channel_name'] === 'test' ) {
+ // Don't post to Trac if we're coming from #test.
+ continue;
+ }
+
+ $trac_xmlrpc = new \Trac( 'slackbot', SLACKBOT_WPORG_PASSWORD, "$trac.trac.wordpress.org", '/login/xmlrpc', 443, true );
+ $comment = sprintf( $comment_template, $_POST['channel_name'], $_POST['user_name'], str_replace( '.', '', $_POST['timestamp'] ) );
+ foreach ( $results['ticket'] as $ticket ) {
+ if ( is_array( $ticket ) ) {
+ $ticket = $ticket['id'];
+ }
+
+ if ( $parser->is_redundant( 'trac', $trac, 'ticket', $ticket ) ) {
+ continue;
+ }
+ $parser->set_redundancy( 'trac', $trac, 'ticket', $ticket );
+
+ $trac_xmlrpc->ticket_update( $ticket, $comment );
+ }
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/api.wordpress.org/public_html/dotorg/slack/trac-bot.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkcommonincludesslackautoloadphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/common/includes/slack/autoload.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/common/includes/slack/autoload.php (rev 0)
+++ sites/trunk/common/includes/slack/autoload.php 2015-01-11 11:21:12 UTC (rev 1122)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,8 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+spl_autoload_register( function( $class ) {
+ if ( 0 === strpos( $class, 'Dotorg\\Slack\\' ) ) {
+ require __DIR__ . '/' . strtolower( strtr( $class, array( 'Dotorg\\Slack\\' => '', '_' => '-', '\\' => '/' ) ) ) . '.php';
+ }
+});
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/common/includes/slack/autoload.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkcommonincludestestsslacktracbotphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/common/includes/tests/slack/trac/bot.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/common/includes/tests/slack/trac/bot.php (rev 0)
+++ sites/trunk/common/includes/tests/slack/trac/bot.php 2015-01-11 11:21:12 UTC (rev 1122)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,80 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+require dirname( dirname( dirname( __DIR__ ) ) ) . '/slack/autoload.php';
+
+class Test_Slack_Trac_Bot extends PHPUnit_Framework_TestCase {
+ function test_commit_parse() {
+ $post_data = $this->mock_post_data( '[1234] r12345 r897-core https://core.trac.wordpress.org/changeset/11223' );
+ $receiving = new \Dotorg\Slack\Trac\Bot( $post_data );
+ $expected = array(
+ 'core' => array(
+ 'commit' => array(
+ array(
+ 'trac' => '',
+ 'id' => '1234',
+ ),
+ array(
+ // 'trac' => '',
+ 'id' => '12345',
+ ),
+ array(
+ 'id' => '897',
+ 'trac' => 'core',
+ ),
+ array(
+ 'trac' => 'core',
+ 'id' => '11223',
+ 'url' => true
+ )
+ )
+ )
+ );
+ $this->assertSame( $expected, $receiving->parse() );
+ }
+
+ function test_ticket_parse() {
+ $post_data = $this->mock_post_data( '#1234, #12345, https://core.trac.wordpress.org/ticket/11223' );
+ $receiving = new \Dotorg\Slack\Trac\Bot( $post_data );
+ $expected = array(
+ 'core' => array(
+ 'ticket' => array(
+ array( 'id' => '1234' ),
+ array( 'id' => '12345' ),
+ array( 'trac' => 'core', 'id' => '11223', 'url' => true ),
+ )
+ )
+ );
+ $this->assertSame( $expected, $receiving->parse() );
+ }
+
+ function mock_post_data( $text ) {
+ return array(
+ 'team_domain' => 'wordpress',
+ 'channel_name' => 'bots',
+ 'user_name' => 'nacin',
+ 'text' => $text,
+ );
+ }
+}
+
+/*
+$_POST['text'] = "
+ (#1234,
+ (#1235-core,
+ (#1236-bb,
+
+ (#glotpress12,
+ (#meta123,
+
+ (r1234,
+ (r1238-buddypress,
+ (r1200-bb,
+
+ ([1234],
+ ([core1234],
+ ([wp1234],
+
+ ([1234-core],
+ ([1234-wp],
+";*/
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/common/includes/tests/slack/trac/bot.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>
</body>
</html>