store = $this->getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->setMethods( [ 'getWikiPageSortKey' ] ) ->getMockForAbstractClass(); $this->collator = $this->getMockBuilder( '\SMW\MediaWiki\Collator' ) ->disableOriginalConstructor() ->getMock(); } public function testCanConstruct() { $this->assertInstanceOf( SortLetter::class, new SortLetter( $this->store, $this->collator ) ); } public function testFindFirstLetter() { $dataItem = $this->getMockBuilder( '\SMW\DIWikiPage' ) ->disableOriginalConstructor() ->getMock(); $dataItem->expects( $this->any() ) ->method( 'getDIType' ) ->willReturn( \SMWDataItem::TYPE_WIKIPAGE ); $this->store->expects( $this->once() ) ->method( 'getWikiPageSortKey' ) ->willReturn( 'Foo' ); $this->collator->expects( $this->once() ) ->method( 'getFirstLetter' ) ->willReturn( 'F' ); $instance = new SortLetter( $this->store, $this->collator ); $instance->getFirstLetter( $dataItem ); } }