From: Kunal Mehta Date: Sat, 10 Sep 2016 08:54:15 +0000 (-0700) Subject: Add structure test for ContentHandler::makeEmptyContent() X-Git-Tag: 1.31.0-rc.0~5640^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/supprimer.php?a=commitdiff_plain;h=f86d2a63e4ac89dfc3438b018da853247fdadaee;p=lhc%2Fweb%2Fwiklou.git Add structure test for ContentHandler::makeEmptyContent() This adds a structure test that verifies all registered ContentHandlers will return a valid content object (as determined by Content::isValid()), when makeEmptyContent() is called. Additionally, if the handler extends TextContentHandler, it will verify it is an instance of TextContentHandler::getContentClass(). This is a structure test so it is run for content handlers created by extensions as well. Change-Id: Idd67d824f2f7cc1819b1d8b186be058e63c4513d --- diff --git a/tests/phpunit/structure/ContentHandlerSanityTest.php b/tests/phpunit/structure/ContentHandlerSanityTest.php new file mode 100644 index 0000000000..98a0fbbfd5 --- /dev/null +++ b/tests/phpunit/structure/ContentHandlerSanityTest.php @@ -0,0 +1,53 @@ +makeEmptyContent(); + $this->assertInstanceOf( Content::class, $content ); + if ( $handler instanceof TextContentHandler ) { + // TextContentHandler::getContentClass() is protected, so bypass + // that restriction + $testingWrapper = TestingAccessWrapper::newFromObject( $handler ); + $this->assertInstanceOf( $testingWrapper->getContentClass(), $content ); + } + + $handlerClass = get_class( $handler ); + $contentClass = get_class( $content ); + + $this->assertTrue( + $content->isValid(), + "$handlerClass::makeEmptyContent() did not return a valid content ($contentClass::isValid())" + ); + } +}