[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> changelog_getrevisioninfo.test.php (source)

   1  <?php
   2  
   3  use dokuwiki\ChangeLog\PageChangeLog;
   4  
   5  /**
   6   * Tests for requesting revisioninfo of a revision of a page with getRevisionInfo()
   7   *
   8   * This class uses the files:
   9   * - data/pages/mailinglist.txt
  10   * - data/meta/mailinglist.changes
  11   */
  12  class changelog_getrevisionsinfo_test extends DokuWikiTest {
  13  
  14      private $logline = "1362525899    127.0.0.1    E    mailinglist    pubcie    [Data entry]     \n";
  15      private $firstlogline = "1374261194    127.0.0.1    E    mailinglist    pubcie        \n";
  16      private $pageid = 'mailinglist';
  17  
  18      function setup() {
  19          parent::setup();
  20          global $cache_revinfo;
  21          $cache =& $cache_revinfo;
  22          if(isset($cache['nonexist'])) {
  23              unset($cache['nonexist']);
  24          }
  25          if(isset($cache['mailinglist'])) {
  26              unset($cache['mailinglist']);
  27          }
  28      }
  29  
  30      /**
  31       * no nonexist.changes meta file available
  32       */
  33      function test_changemetadatanotexists() {
  34          $rev = 1362525899;
  35          $id = 'nonexist';
  36          $revsexpected = false;
  37  
  38          $pagelog = new PageChangeLog($id, $chunk_size = 8192);
  39          $revs = $pagelog->getRevisionInfo($rev);
  40          $this->assertEquals($revsexpected, $revs);
  41      }
  42  
  43      /**
  44       * request existing rev
  45       */
  46      function test_requestrev() {
  47          $rev = 1362525899;
  48          $infoexpected = parseChangelogLine($this->logline);
  49  
  50          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
  51          $info = $pagelog->getRevisionInfo($rev);
  52          $this->assertEquals($infoexpected, $info);
  53          //returns cached value
  54          $info = $pagelog->getRevisionInfo($rev);
  55          $this->assertEquals($infoexpected, $info);
  56      }
  57  
  58      /**
  59       * request existing rev with chucked reading
  60       */
  61      function test_requestrev_chuncked() {
  62          $rev = 1362525899;
  63          $infoexpected = parseChangelogLine($this->logline);
  64  
  65          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512);
  66          $info = $pagelog->getRevisionInfo($rev);
  67          $this->assertEquals($infoexpected, $info);
  68      }
  69  
  70      /**
  71       * request existing rev with chucked reading
  72       */
  73      function test_requestrev_chunckedsmallerthanlinelength() {
  74          $rev = 1362525899;
  75          $infoexpected = parseChangelogLine($this->logline);
  76  
  77          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20);
  78          $info = $pagelog->getRevisionInfo($rev);
  79          $this->assertEquals($infoexpected, $info);
  80      }
  81  
  82      /**
  83       * request current version
  84       */
  85      function test_requestrecentestlogline() {
  86          $rev = 1374261194;
  87          $infoexpected = parseChangelogLine($this->firstlogline);
  88  
  89          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
  90          $info = $pagelog->getRevisionInfo($rev);
  91          $this->assertEquals($infoexpected, $info);
  92          //returns cached value
  93          $info = $pagelog->getRevisionInfo($rev);
  94          $this->assertEquals($infoexpected, $info);
  95      }
  96  
  97      /**
  98       * request current version, with chuncked reading
  99       */
 100      function test_requestrecentestlogline_chuncked() {
 101          $rev = 1374261194;
 102          $infoexpected = parseChangelogLine($this->firstlogline);
 103  
 104          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512);
 105          $info = $pagelog->getRevisionInfo($rev);
 106          $this->assertEquals($infoexpected, $info);
 107      }
 108  
 109      /**
 110       * request negative revision
 111       */
 112      function test_negativerev() {
 113          $rev = -10;
 114  
 115          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
 116          $info = $pagelog->getRevisionInfo($rev);
 117          $this->assertEquals(false, $info);
 118      }
 119  
 120      /**
 121       * request non existing revision somewhere between existing revisions
 122       */
 123      function test_notexistingrev() {
 124          $rev = 1362525890;
 125  
 126          $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
 127          $info = $pagelog->getRevisionInfo($rev);
 128          $this->assertEquals(false, $info);
 129      }
 130  
 131      /**
 132       * sometimes chuncksize is set to true
 133       */
 134      function test_chuncksizetrue() {
 135          $rev = 1362525899;
 136          $infoexpected = parseChangelogLine($this->logline);
 137  
 138          $pagelog = new PageChangeLog($this->pageid, true);
 139          $info = $pagelog->getRevisionInfo($rev);
 140          $this->assertEquals($infoexpected, $info);
 141      }
 142  }