DifferenceEngineSlotDiffRendererTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @covers DifferenceEngineSlotDiffRenderer
  4. */
  5. class DifferenceEngineSlotDiffRendererTest extends \PHPUnit\Framework\TestCase {
  6. public function testGetDiff() {
  7. $differenceEngine = new CustomDifferenceEngine();
  8. $slotDiffRenderer = new DifferenceEngineSlotDiffRenderer( $differenceEngine );
  9. $oldContent = ContentHandler::makeContent( 'xxx', null, CONTENT_MODEL_TEXT );
  10. $newContent = ContentHandler::makeContent( 'yyy', null, CONTENT_MODEL_TEXT );
  11. $diff = $slotDiffRenderer->getDiff( $oldContent, $newContent );
  12. $this->assertEquals( 'xxx|yyy', $diff );
  13. $diff = $slotDiffRenderer->getDiff( null, $newContent );
  14. $this->assertEquals( '|yyy', $diff );
  15. $diff = $slotDiffRenderer->getDiff( $oldContent, null );
  16. $this->assertEquals( 'xxx|', $diff );
  17. }
  18. public function testAddModules() {
  19. $output = $this->getMockBuilder( OutputPage::class )
  20. ->disableOriginalConstructor()
  21. ->setMethods( [ 'addModules' ] )
  22. ->getMock();
  23. $output->expects( $this->once() )
  24. ->method( 'addModules' )
  25. ->with( 'foo' );
  26. $differenceEngine = new CustomDifferenceEngine();
  27. $slotDiffRenderer = new DifferenceEngineSlotDiffRenderer( $differenceEngine );
  28. $slotDiffRenderer->addModules( $output );
  29. }
  30. public function testGetExtraCacheKeys() {
  31. $differenceEngine = new CustomDifferenceEngine();
  32. $slotDiffRenderer = new DifferenceEngineSlotDiffRenderer( $differenceEngine );
  33. $extraCacheKeys = $slotDiffRenderer->getExtraCacheKeys();
  34. $this->assertSame( [ 'foo' ], $extraCacheKeys );
  35. }
  36. }