public function testToJson()
 {
     $collection = new CiteCollection();
     for ($i = 1; $i < 4; $i++) {
         $cite = $this->getMock('Cite', array('toJson'));
         $cite->expects($this->once())->method('toJson')->will($this->returnValue('JSON' . $i));
         $collection->add($cite);
     }
     $this->assertEquals("[JSON1, JSON2, JSON3]", $collection->toJson());
 }
 protected function saveToCacheFile(CiteCollection $collection)
 {
     if (!file_put_contents($this->cacheFile, $collection->toJson())) {
         throw new RuntimeException("Can not write cache to file '{$this->cacheFile}'!");
     }
 }