mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Merge run test scenarios in UnlockCommandTests
Expectations and setting properties should be in dataProvider
This commit is contained in:
		
							parent
							
								
									937355ce8b
								
							
						
					
					
						commit
						c6e0d6762c
					
				@ -27,6 +27,18 @@ class UnlockCommandTest extends BaseTest
 | 
			
		||||
    public static $fileExistsResult;
 | 
			
		||||
    public static $isFileExists;
 | 
			
		||||
 | 
			
		||||
    public function runProvider()
 | 
			
		||||
    {
 | 
			
		||||
        return array(
 | 
			
		||||
            'happy_path' => array(
 | 
			
		||||
                'file_exists' => true,
 | 
			
		||||
            ),
 | 
			
		||||
            'file_not_exists' => array(
 | 
			
		||||
                'file_exsits' => false
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @before
 | 
			
		||||
     */
 | 
			
		||||
@ -87,38 +99,20 @@ class UnlockCommandTest extends BaseTest
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @covers ::run
 | 
			
		||||
     * @dataProvider runProvider
 | 
			
		||||
     */
 | 
			
		||||
    public function testRun()
 | 
			
		||||
    public function testRun($fileExists)
 | 
			
		||||
    {
 | 
			
		||||
        $expectedOutput = "\tUnlocked deployment to production environment\n\n";
 | 
			
		||||
        $this->expectOutputString($expectedOutput);
 | 
			
		||||
        $expectedLockFilePath = '/.mage/production.lock';
 | 
			
		||||
 | 
			
		||||
        self::$isFileExists = true;
 | 
			
		||||
        self::$isFileExists = $fileExists;
 | 
			
		||||
 | 
			
		||||
        $actualExitCode = $this->unlockCommand->run();
 | 
			
		||||
        $expectedExitCode = 0;
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue(self::$isUnlinkCalled);
 | 
			
		||||
        $this->assertEquals($expectedExitCode, $actualExitCode);
 | 
			
		||||
        $this->assertEquals($expectedLockFilePath, self::$fileExistsResult);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @covers ::run
 | 
			
		||||
     */
 | 
			
		||||
    public function testRunIfFileNotExist()
 | 
			
		||||
    {
 | 
			
		||||
        $expectedOutput = "\tUnlocked deployment to production environment\n\n";
 | 
			
		||||
        $this->expectOutputString($expectedOutput);
 | 
			
		||||
        $expectedLockFilePath = '/.mage/production.lock';
 | 
			
		||||
 | 
			
		||||
        self::$isFileExists = false;
 | 
			
		||||
 | 
			
		||||
        $actualExitCode = $this->unlockCommand->run();
 | 
			
		||||
        $expectedExitCode = 0;
 | 
			
		||||
 | 
			
		||||
        $this->assertFalse(self::$isUnlinkCalled);
 | 
			
		||||
        $this->assertEquals(self::$isUnlinkCalled, $fileExists);
 | 
			
		||||
        $this->assertEquals($expectedExitCode, $actualExitCode);
 | 
			
		||||
        $this->assertEquals($expectedLockFilePath, self::$fileExistsResult);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user