You are here

public function vfsStreamWrapperFileTimesTestCase::readFileChangesAccessTime in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php \org\bovigo\vfs\vfsStreamWrapperFileTimesTestCase::readFileChangesAccessTime()

@test @group issue_7

File

vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php, line 132

Class

vfsStreamWrapperFileTimesTestCase
Test for org\bovigo\vfs\vfsStreamWrapper.

Namespace

org\bovigo\vfs

Code

public function readFileChangesAccessTime() {
  $file = vfsStream::newFile('foo.txt')
    ->withContent('test')
    ->at(vfsStreamWrapper::getRoot())
    ->lastModified(100)
    ->lastAccessed(100)
    ->lastAttributeModified(100);
  $fp = fopen($this->fooUrl, 'rb');
  $openTime = time();
  sleep(2);
  fread($fp, 1024);
  fclose($fp);
  $this
    ->assertLessThanOrEqual($openTime, filemtime($this->fooUrl));
  $this
    ->assertLessThanOrEqual($openTime + 3, fileatime($this->fooUrl));
  $this
    ->assertEquals(100, filectime($this->fooUrl));
  $this
    ->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
}