コード例 #1
0
 /**
  * Auto version a single file
  *
  * @param $file
  * @param string $method
  * @return mixed
  */
 public static function file($file, $method = 'regexp')
 {
     $autoVersion = new AutoVersion(getenv('DOCUMENT_ROOT'));
     return $autoVersion->file($file, $method);
 }
コード例 #2
0
 /**
  * Test trying to auto version a file by regular expression option
  */
 public function testGetFileByQuery()
 {
     $folder = __DIR__;
     $auto = new AutoVersion($folder);
     foreach (['q', 'query'] as $option) {
         $fileName = md5(microtime(true)) . '-version-' . $option . '.json';
         file_put_contents(self::$tempFolder . '/' . $fileName, time());
         $fileMTime = filemtime(self::$tempFolder . '/' . $fileName);
         $versionedFile = $auto->file('/' . self::$tempFolderName . '/' . $fileName, $option);
         $this->assertNotEquals('/' . self::$tempFolderName . '/' . $fileName, $versionedFile);
         $this->assertContains((string) $fileMTime, (string) $versionedFile);
         $this->assertContains('?' . (string) $fileMTime, (string) $versionedFile);
     }
 }