-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathSourceCgitTest.php
74 lines (59 loc) · 1.55 KB
/
SourceCgitTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
# Copyright (c) 2011 asm89
# Licensed under the MIT license
/**
* This simple test fetches the specified url and outputs the parsed content.
* This output can be compared with the content of the webpage to verify that
* the cgit parser works.
*
* Usage: php SourceCgitTest.php
*/
// Url pointing to a commit on Cgit (default is a commit of the cgit project)
$url = 'http://hjemli.net/git/cgit/commit/?id=d885158f6ac29e04bd14dd132331c7e3a93e7490';
// Define testing mode
define('testing', true);
include 'SourceCgit.php';
// Get the testpage
$testpage = file_get_contents($url);
// Initialize the plugin
$plugin = new SourceCgitPlugin();
// Sanatize the input
$t_input = $plugin->clean_input( $testpage );
print_n( 'Revision:' );
print_c( $plugin->commit_revision( $t_input ) );
print_n();
print_n( 'Author/commiter info:' );
print_c( $plugin->commit_author( $t_input ) );
print_n();
print_n( 'Parent commits:' );
print_c( $plugin->commit_parents( $t_input ) );
print_n();
print_n( 'Commit message:' );
print_c( $plugin->commit_message( $t_input ) );
print_n();
print_n( 'Committed files:' );
print_c( $plugin->commit_files( $t_input ) );
/**
* Print the data and a newline.
*
* @param mixed $data
*/
function print_c($data) {
print_r($data);
echo "\n";
}
/**
* Print the text and a newline.
*
* @param string $text
*/
function print_n($text = '') {
echo $text . "\n";
}
/**
* MantisSourcePlugin stub
*
* This is commented out, as it causes PHPStorm to report multiple
* declarations of that class.
*/
//class MantisSourcePlugin {}