summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/Validators/TitleValidator.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/Validators/TitleValidator.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/Validators/TitleValidator.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/Validators/TitleValidator.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/Validators/TitleValidator.php
new file mode 100644
index 00000000..16b70802
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/Validators/TitleValidator.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace SMW\Tests\Utils\Validators;
+
+use Title;
+
+/**
+ * @license GNU GPL v2+
+ * @since 2.1
+ *
+ * @author mwjames
+ */
+class TitleValidator extends \PHPUnit_Framework_Assert {
+
+ /**
+ * @since 2.1
+ */
+ public function assertThatTitleIsNotKnown( $titles ) {
+ $this->assertTitleExists( false, $titles );
+ }
+
+ /**
+ * @since 2.1
+ */
+ public function assertThatTitleIsKnown( $titles ) {
+ $this->assertTitleExists( true, $titles );
+ }
+
+ private function assertTitleExists( $isExpected, $titles ) {
+
+ if ( !is_array( $titles ) ) {
+ $titles = [ $titles ];
+ }
+
+ foreach ( $titles as $title ) {
+
+ if ( !$title instanceof Title && is_string( $title ) ) {
+ $title = Title::newFromText( $title );
+ }
+
+ $this->assertEquals( $isExpected, $title->exists(), $title->getPrefixedText() );
+ }
+ }
+
+}