浏览代码

Added a new test for the proposed feature

Javier Eguiluz 8 年之前
父节点
当前提交
efde14c84e
共有 1 个文件被更改,包括 28 次插入0 次删除
  1. 28 0
      src/Packagist/WebBundle/Tests/Package/UpdaterTest.php

+ 28 - 0
src/Packagist/WebBundle/Tests/Package/UpdaterTest.php

@@ -104,6 +104,34 @@ EOR;
         self::assertSame($readmeHtml, $this->package->getReadme());
     }
 
+    /**
+     * When <h1> or <h2> titles are not the first element of the README contents,
+     * they should not be removed.
+     */
+    public function testNoUsefulTitlesAreRemovedForReadme()
+    {
+        $readme = <<<EOR
+Lorem ipsum dolor sit amet.
+
+# some title
+
+EOR;
+        $readmeHtml = <<<EOR
+<p>Lorem ipsum dolor sit amet.</p>
+<h1>some title</h1>
+EOR;
+
+        $this->driverMock->expects($this->any())->method('getRootIdentifier')->willReturn('master');
+        $this->driverMock->expects($this->any())->method('getComposerInformation')
+                         ->willReturn(['readme' => 'README.md']);
+        $this->driverMock->expects($this->once())->method('getFileContent')->with('README.md', 'master')
+                         ->willReturn($readme);
+
+        $this->updater->update($this->ioMock, $this->config, $this->package, $this->repositoryMock);
+
+        self::assertSame($readmeHtml, $this->package->getReadme());
+    }
+
     public function testSurrondsTextReadme()
     {
         $this->driverMock->expects($this->any())->method('getRootIdentifier')->willReturn('master');