| 1 | <?php |
||
| 17 | * Class FileTest. |
||
| 18 | */ |
||
| 19 | class FileTest extends \PHPUnit_Framework_TestCase |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var File |
||
| 23 | */ |
||
| 24 | protected $watcher; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | protected static $tmpFile; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * {@inheritdoc} |
||
| 33 | */ |
||
| 34 | public static function setUpBeforeClass() |
||
| 35 | { |
||
| 36 | self::$tmpFile = sys_get_temp_dir() . '/maintenance'; |
||
| 37 | |||
| 38 | touch(self::$tmpFile); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritdoc} |
||
| 43 | */ |
||
| 44 | public static function tearDownAfterClass() |
||
| 45 | { |
||
| 46 | unlink(self::$tmpFile); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | public function setUp() |
||
| 53 | { |
||
| 54 | $this->watcher = new File(self::$tmpFile); |
||
| 55 | } |
||
| 56 | |||
| 57 | public function testIsActive() |
||
| 58 | { |
||
| 59 | self::assertTrue($this->watcher->isActive()); |
||
| 60 | } |
||
| 61 | |||
| 62 | public function testIsNotActive() |
||
| 63 | { |
||
| 64 | unlink(self::$tmpFile); |
||
| 65 | |||
| 66 | self::assertFalse($this->watcher->isActive()); |
||
| 67 | |||
| 68 | touch(self::$tmpFile); |
||
| 69 | } |
||
| 71 |