~ubuntu-branches/ubuntu/trusty/mediawiki/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/phpunit/includes/ArticleTest.php

  • Committer: Package Import Robot
  • Author(s): Thorsten Glaser
  • Date: 2014-03-28 09:56:29 UTC
  • mfrom: (1.3.14)
  • Revision ID: package-import@ubuntu.com-20140328095629-1526y9tchdd507id
Tags: 1:1.19.14+dfsg-1
* New upstream security fix release (Closes: #742857):
  - (bug 62497) SECURITY: Add CSRF token on Special:ChangePassword
  - (bug 62467) Set a title for the context during import on the cli
* Use upstream-provided signing key bundle

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class ArticleTest extends MediaWikiTestCase {
 
4
 
 
5
        private $title; // holds a Title object
 
6
        private $article; // holds an article
 
7
 
 
8
        /** creates a title object and its article object */
 
9
        function setUp() {
 
10
                $this->title   = Title::makeTitle( NS_MAIN, 'SomePage' );
 
11
                $this->article = new Article( $this->title );
 
12
 
 
13
        }
 
14
 
 
15
        /** cleanup title object and its article object */
 
16
        function tearDown() {
 
17
                $this->title   = null;
 
18
                $this->article = null;
 
19
 
 
20
        }
 
21
 
 
22
        function testImplementsGetMagic() {
 
23
                $this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
 
24
        }
 
25
 
 
26
        /**
 
27
         * @depends testImplementsGetMagic
 
28
         */
 
29
        function testImplementsSetMagic() {
 
30
                $this->article->mLatest = 2;
 
31
                $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
 
32
        }
 
33
 
 
34
        /**
 
35
         * @depends testImplementsSetMagic
 
36
         */
 
37
        function testImplementsCallMagic() {
 
38
                $this->article->mLatest = 33;
 
39
                $this->article->mDataLoaded = true;
 
40
                $this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
 
41
        }
 
42
 
 
43
        function testGetOrSetOnNewProperty() {
 
44
                $this->article->ext_someNewProperty = 12;
 
45
                $this->assertEquals( 12, $this->article->ext_someNewProperty,
 
46
                        "Article get/set magic on new field" );
 
47
                
 
48
                $this->article->ext_someNewProperty = -8;
 
49
                $this->assertEquals( -8, $this->article->ext_someNewProperty,
 
50
                        "Article get/set magic on update to new field" );
 
51
        }
 
52
 
 
53
        /**
 
54
         * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
 
55
         */
 
56
        function testStaticFunctions() {
 
57
                $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
 
58
                        "Article static functions" );
 
59
                $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
 
60
                        "Article static functions" );
 
61
                $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
 
62
                        "Article static functions" );
 
63
                $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
 
64
                        "Article static functions" );
 
65
                $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
 
66
                        "Article static functions" );
 
67
        }
 
68
 
 
69
        function testWikiPageFactory() {
 
70
                $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
 
71
                $page = WikiPage::factory( $title );
 
72
                $this->assertEquals( 'WikiFilePage', get_class( $page ) );
 
73
                
 
74
                $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
 
75
                $page = WikiPage::factory( $title );
 
76
                $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
 
77
                
 
78
                $title = Title::makeTitle( NS_MAIN, 'SomePage' );
 
79
                $page = WikiPage::factory( $title );
 
80
                $this->assertEquals( 'WikiPage', get_class( $page ) );
 
81
        }
 
82
}