summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ant.test/pom.xml
Commit message (Expand)AuthorAgeFilesLines
* Prepare 5.4.0-SNAPSHOT buildsMatthias Sohn2019-03-071-1/+1
* Capture test coverage and add an aggregate test coverage reportMatthias Sohn2018-12-211-1/+1
* Prepare 5.3.0-SNAPSHOT buildsMatthias Sohn2018-12-031-1/+1
* Prepare 5.2.0-SNAPSHOT buildsMatthias Sohn2018-09-061-1/+1
* Prepare 5.1.0-SNAPSHOT buildsMatthias Sohn2018-05-231-1/+1
* Prepare 5.0.0-SNAPSHOT buildsMatthias Sohn2018-03-081-1/+1
* Prepare 4.11.1-SNAPSHOT buildsMatthias Sohn2018-03-081-1/+1
* JGit v4.11.0.201803080745-rv4.11.0.201803080745-rMatthias Sohn2018-03-081-1/+1
* Prepare 4.11.0-SNAPSHOT buildsMatthias Sohn2017-12-311-1/+1
* Prepare 4.10.0-SNAPSHOT buildsMatthias Sohn2017-10-081-1/+1
* Prepare 4.9.0-SNAPSHOT buildsMatthias Sohn2017-05-301-1/+1
* Prepare 4.8.0-SNAPSHOT buildsMatthias Sohn2017-04-051-1/+1
* Prepare 4.7.0-SNAPSHOT buildsMatthias Sohn2016-12-271-1/+1
* Prepare 4.6.1-SNAPSHOT buildsMatthias Sohn2016-12-241-1/+1
* JGit v4.6.0.201612231935-rv4.6.0.201612231935-rMatthias Sohn2016-12-241-1/+1
* Prepare 4.6.0-SNAPSHOT buildsMatthias Sohn2016-09-191-1/+1
* Prepare 4.5.0-SNAPSHOT buildsMatthias Sohn2016-06-011-1/+1
* Prepare 4.4.0-SNAPSHOT buildsMatthias Sohn2016-04-081-1/+1
* Prepare 4.3.1-SNAPSHOT versionsMatthias Sohn2016-04-081-1/+1
* JGit v4.3.0.201604071810-rv4.3.0.201604071810-rMatthias Sohn2016-04-081-1/+1
* JGit v4.3.0.201604071045-rMatthias Sohn2016-04-071-1/+1
* Prepare 4.3-SNAPSHOT buildsMatthias Sohn2016-04-051-1/+1
* JGit v4.3.0.201603230630-rc1v4.3.0.201603230630-rc1Matthias Sohn2016-03-231-1/+1
* Prepare 4.3.0-SNAPSHOT buildsMatthias Sohn2016-01-211-1/+1
* Prepare 4.2.0-SNAPSHOT buildsMatthias Sohn2015-09-281-1/+1
* Prepare 4.1.1-SNAPSHOT buildsMatthias Sohn2015-09-281-1/+1
* JGit v4.1.0.201509280440-rv4.1.0.201509280440-rMatthias Sohn2015-09-281-1/+1
* Prepare 4.1.0-SNAPSHOT buildsMatthias Sohn2015-06-031-1/+1
* Prepare 4.0.0-SNAPSHOT buildsMatthias Sohn2015-01-271-1/+1
* Prepare 3.7.0-SNAPSHOT buildsMatthias Sohn2014-12-241-1/+1
* Prepare 3.6.1-SNAPSHOT buildsMatthias Sohn2014-12-231-1/+1
* JGit v3.6.0.201412230720-rv3.6.0.201412230720-rMatthias Sohn2014-12-231-1/+1
* Prepare post 3.6.0-m1 buildsMatthias Sohn2014-11-121-1/+1
* JGit v3.6.0.201411121045-m1v3.6.0.201411121045-m1Matthias Sohn2014-11-121-1/+1
* Prepare 3.6.0-SNAPSHOT buildsMatthias Sohn2014-09-051-1/+1
* Prepare 3.5.0-SNAPSHOT buildsRobin Rosenberg2014-06-041-1/+1
* Prepare post 3.4.0 RC1 buildsMatthias Sohn2014-05-211-1/+1
* JGit v3.4.0.201405211411-rc1v3.4.0.201405211411-rc1Matthias Sohn2014-05-211-1/+1
* Prepare 3.4.0-SNAPSHOT buildsMatthias Sohn2014-05-061-1/+1
* JGit v3.4.0.201405051725-m7v3.4.0.201405051725-m7Matthias Sohn2014-05-051-1/+1
* Prepare 3.4.0-SNAPSHOT buildsMatthias Sohn2014-03-051-1/+1
* Prepare 3.3.1-SNAPSHOT buildsMatthias Sohn2014-03-051-1/+1
* JGit v3.3.0.201403021825-rv3.3.0.201403021825-rMatthias Sohn2014-03-031-1/+1
* Prepare post 3.3.0RC1 buildsMatthias Sohn2014-02-201-1/+1
* JGit v3.3.0.201402191814-rc1v3.3.0.201402191814-rc1Matthias Sohn2014-02-201-1/+1
* Prepare 3.3.0-SNAPSHOT buildsMatthias Sohn2013-12-051-1/+1
* Prepare 3.2.0-SNAPSHOT buildsMatthias Sohn2013-10-031-1/+1
* Prepare post 3.1.0 buildsstable-3.1Matthias Sohn2013-10-031-1/+1
* JGit v3.1.0.201310021548-rv3.1.0.201310021548-rMatthias Sohn2013-10-021-1/+1
* Prepare post 3.1.0 RC1 buildsMatthias Sohn2013-09-271-1/+1
>backport/48366/stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/simpletest/test/page_test.php
blob: fdc15c5d008b8ddfafa939e2c28b1dd278783f7f (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
// $Id: page_test.php 1913 2009-07-29 16:50:56Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../expectation.php');
require_once(dirname(__FILE__) . '/../http.php');
require_once(dirname(__FILE__) . '/../page.php');
Mock::generate('SimpleHttpHeaders');
Mock::generate('SimpleHttpResponse');

class TestOfPageInterface extends UnitTestCase {
    function testInterfaceOnEmptyPage() {
        $page = new SimplePage();
        $this->assertEqual($page->getTransportError(), 'No page fetched yet');
        $this->assertIdentical($page->getRaw(), false);
        $this->assertIdentical($page->getHeaders(), false);
        $this->assertIdentical($page->getMimeType(), false);
        $this->assertIdentical($page->getResponseCode(), false);
        $this->assertIdentical($page->getAuthentication(), false);
        $this->assertIdentical($page->getRealm(), false);
        $this->assertFalse($page->hasFrames());
        $this->assertIdentical($page->getUrls(), array());
        $this->assertIdentical($page->getTitle(), false);
    }
}

class TestOfPageHeaders extends UnitTestCase {

    function testUrlAccessor() {
        $headers = new MockSimpleHttpHeaders();

        $response = new MockSimpleHttpResponse();
        $response->setReturnValue('getHeaders', $headers);
        $response->setReturnValue('getMethod', 'POST');
        $response->setReturnValue('getUrl', new SimpleUrl('here'));
        $response->setReturnValue('getRequestData', array('a' => 'A'));

        $page = new SimplePage($response);
        $this->assertEqual($page->getMethod(), 'POST');
        $this->assertEqual($page->getUrl(), new SimpleUrl('here'));
        $this->assertEqual($page->getRequestData(), array('a' => 'A'));
    }

    function testTransportError() {
        $response = new MockSimpleHttpResponse();
        $response->setReturnValue('getError', 'Ouch');

        $page = new SimplePage($response);
        $this->assertEqual($page->getTransportError(), 'Ouch');
    }

    function testHeadersAccessor() {
        $headers = new MockSimpleHttpHeaders();
        $headers->setReturnValue('getRaw', 'My: Headers');

        $response = new MockSimpleHttpResponse();
        $response->setReturnValue('getHeaders', $headers);

        $page = new SimplePage($response);
        $this->assertEqual($page->getHeaders(), 'My: Headers');
    }

    function testMimeAccessor() {
        $headers = new MockSimpleHttpHeaders();
        $headers->setReturnValue('getMimeType', 'text/html');

        $response = new MockSimpleHttpResponse();
        $response->setReturnValue('getHeaders', $headers);

        $page = new SimplePage($response);
        $this->assertEqual($page->getMimeType(), 'text/html');
    }

    function testResponseAccessor() {
        $headers = new MockSimpleHttpHeaders();
        $headers->setReturnValue('getResponseCode', 301);

        $response = new MockSimpleHttpResponse();
        $response->setReturnValue('getHeaders', $headers);

        $page = new SimplePage($response);
        $this->assertIdentical($page->getResponseCode(), 301);
    }

    function testAuthenticationAccessors() {
        $headers = new MockSimpleHttpHeaders();
        $headers->setReturnValue('getAuthentication', 'Basic');
        $headers->setReturnValue('getRealm', 'Secret stuff');

        $response = new MockSimpleHttpResponse();
        $response->setReturnValue('getHeaders', $headers);

        $page = new SimplePage($response);
        $this->assertEqual($page->getAuthentication(), 'Basic');
        $this->assertEqual($page->getRealm(), 'Secret stuff');
    }
}

class TestOfHtmlStrippingAndNormalisation extends UnitTestCase {

	function testImageSuppressionWhileKeepingParagraphsAndAltText() {
        $this->assertEqual(
                SimplePage::normalise('<img src="foo.png" /><p>some text</p><img src="bar.png" alt="bar" />'),
                'some text bar');
	}

    function testSpaceNormalisation() {
        $this->assertEqual(
                SimplePage::normalise("\nOne\tTwo   \nThree\t"),
                'One Two Three');
    }

    function testMultilinesCommentSuppression() {
        $this->assertEqual(
                SimplePage::normalise('<!--\n Hello \n-->'),
                '');
    }

    function testCommentSuppression() {
        $this->assertEqual(
                SimplePage::normalise('<!--Hello-->'),
                '');
    }

    function testJavascriptSuppression() {
        $this->assertEqual(
                SimplePage::normalise('<script attribute="test">\nHello\n</script>'),
                '');
        $this->assertEqual(
                SimplePage::normalise('<script attribute="test">Hello</script>'),
                '');
        $this->assertEqual(
                SimplePage::normalise('<script>Hello</script>'),
                '');
    }

    function testTagSuppression() {
        $this->assertEqual(
                SimplePage::normalise('<b>Hello</b>'),
                'Hello');
    }

    function testAdjoiningTagSuppression() {
        $this->assertEqual(
                SimplePage::normalise('<b>Hello</b><em>Goodbye</em>'),
                'HelloGoodbye');
    }

    function testExtractImageAltTextWithDifferentQuotes() {
        $this->assertEqual(
                SimplePage::normalise('<img alt="One"><img alt=\'Two\'><img alt=Three>'),
                'One Two Three');
    }

    function testExtractImageAltTextMultipleTimes() {
        $this->assertEqual(
                SimplePage::normalise('<img alt="One"><img alt="Two"><img alt="Three">'),
                'One Two Three');
    }

    function testHtmlEntityTranslation() {
        $this->assertEqual(
                SimplePage::normalise('&lt;&gt;&quot;&amp;&#039;'),
                '<>"&\'');
    }
}
?>