public function testPurgePage() { $api = $this->getMockApi(); $api->expects($this->once())->method('postRequest')->with($this->isInstanceOf('\\Mediawiki\\Api\\SimpleRequest'))->will($this->returnValue('SOME no error RESULT')); $service = new PagePurger($api); $page = new Page(new PageIdentifier(new Title('Foo', 0), 123), new Revisions(array())); $this->assertTrue($service->purge($page)); }
function testIncorrectPurgePages() { $api = $this->getMockApi(); $api->expects($this->once())->method('postRequest')->with($this->isInstanceOf('\\Mediawiki\\Api\\SimpleRequest'))->will($this->returnValue(["batchcomplete" => "", "purge" => [["ns" => 0, "title" => "Foo", "purged" => ""], ["ns" => 0, "title" => "Bar", "purged" => ""], ["ns" => 0, "title" => "This page really does not exist", "missing" => ""]]])); $service = new PagePurger($api); $pages = new Pages([new Page(new PageIdentifier(new Title('Foo', 0), 100)), new Page(new PageIdentifier(new Title('Bar', 1), 101)), new Page(new PageIdentifier(new Title('MissingPage', 1), 103))]); // MissingPage is not in the pages that are returned by purgePages $pagesArray = $pages->toArray(); array_pop($pagesArray); $result = new Pages($pagesArray); $this->assertEquals($service->purgePages($pages), $result); }