getContentHandlerFactory(); $handlers = []; foreach ( $models as $model ) { $handlers[] = [ $contentHandlerFactory->getContentHandler( $model ) ]; } return $handlers; } /** * @dataProvider provideHandlers * @param ContentHandler $handler */ public function testMakeEmptyContent( ContentHandler $handler ) { $content = $handler->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 ); if ( $handler->supportsDirectEditing() ) { $this->assertTrue( $content->isValid(), "$handlerClass::makeEmptyContent() did not return a valid content ($contentClass::isValid())" ); } } }