DiffMatchPatch\PatchTest::testAddContext PHP Method

testAddContext() public method

public testAddContext ( )
    public function testAddContext()
    {
        $this->p->setMargin(4);
        $patches = $this->p->fromText("@@ -21,4 +21,10 @@\n-jump\n+somersault\n");
        $this->p->addContext($patches[0], "The quick brown fox jumps over the lazy dog.");
        $this->assertEquals("@@ -17,12 +17,18 @@\n fox \n-jump\n+somersault\n s ov\n", (string) $patches[0]);
        // Same, but not enough trailing context.
        $patches = $this->p->fromText("@@ -21,4 +21,10 @@\n-jump\n+somersault\n");
        $this->p->addContext($patches[0], "The quick brown fox jumps.");
        $this->assertEquals("@@ -17,10 +17,16 @@\n fox \n-jump\n+somersault\n s.\n", (string) $patches[0]);
        // Same, but not enough leading context.
        $patches = $this->p->fromText("@@ -3 +3,2 @@\n-e\n+at\n");
        $this->p->addContext($patches[0], "The quick brown fox jumps.");
        $this->assertEquals("@@ -1,7 +1,8 @@\n Th\n-e\n+at\n  qui\n", (string) $patches[0]);
        // Same, but with ambiguity.
        $patches = $this->p->fromText("@@ -3 +3,2 @@\n-e\n+at\n");
        $this->p->addContext($patches[0], "The quick brown fox jumps.  The quick brown fox crashes.");
        $this->assertEquals("@@ -1,27 +1,28 @@\n Th\n-e\n+at\n  quick brown fox jumps. \n", (string) $patches[0]);
    }