Completed
Push — master ( 6867ea...535d08 )
by Jeroen De
62:35 queued 52:37
created

PageCreator::createPageWithContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Tests\Util;
6
7
use CommentStoreComment;
8
use Title;
9
use User;
10
11
/**
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class PageCreator {
16
17
	public function createPage( string $title, string $content = null ) {
18
		$titleObject = Title::newFromText( $title );
19
20
		$this->createPageWithContent(
21
			$title,
22
			\ContentHandler::makeContent( $content ?? 'Content of ' . $title, $titleObject )
23
		);
24
	}
25
26
	public function createPageWithContent( string $title, \Content $content ) {
27
		$titleObject = Title::newFromText( $title );
28
		$page = new \WikiPage( $titleObject );
29
30
		$updater = $page->newPageUpdater( User::newSystemUser( 'TestUser' ) );
31
		$updater->setContent( 'main', $content );
32
		$updater->saveRevision( CommentStoreComment::newUnsavedComment( __CLASS__ . ' creating page ' . $title ) );
33
	}
34
35
}
36