mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			990 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			990 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * @link http://www.yiiframework.com/
 | 
						|
 * @copyright Copyright (c) 2008 Yii Software LLC
 | 
						|
 * @license http://www.yiiframework.com/license/
 | 
						|
 */
 | 
						|
 | 
						|
namespace yiiunit\framework\mutex;
 | 
						|
 | 
						|
use yii\mutex\FileMutex;
 | 
						|
use yiiunit\TestCase;
 | 
						|
 | 
						|
/**
 | 
						|
 * Class FileMutexTest.
 | 
						|
 *
 | 
						|
 * @group mutex
 | 
						|
 */
 | 
						|
class FileMutexTest extends TestCase
 | 
						|
{
 | 
						|
    use MutexTestTrait;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return FileMutex
 | 
						|
     * @throws \yii\base\InvalidConfigException
 | 
						|
     */
 | 
						|
    protected function createMutex()
 | 
						|
    {
 | 
						|
        return \Yii::createObject([
 | 
						|
            'class' => FileMutex::className(),
 | 
						|
            'mutexPath' => '@yiiunit/runtime/mutex',
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function testDeleteLockFile()
 | 
						|
    {
 | 
						|
        $mutex = $this->createMutex();
 | 
						|
        $fileName = $mutex->mutexPath . '/' . md5(self::$mutexName) . '.lock';
 | 
						|
 | 
						|
        $mutex->acquire(self::$mutexName);
 | 
						|
        $this->assertFileExists($fileName);
 | 
						|
 | 
						|
        $mutex->release(self::$mutexName);
 | 
						|
        $this->assertFileNotExists($fileName);
 | 
						|
    }
 | 
						|
}
 |