AppserverIo\Appserver\Core\Api\AppServiceTest::testCreateTmpFolders PHP Method

testCreateTmpFolders() public method

Tests if we can create the tmp directories a passed application needs
public testCreateTmpFolders ( ) : null
return null
    public function testCreateTmpFolders()
    {
        // temporarily switch off initUmask() and setUserRights() as they would make problems
        $service = $this->getMockBuilder('\\AppserverIo\\Appserver\\Core\\Api\\AppService')->setMethods(array_merge(array('findAll', 'load', 'initUmask', 'setUserRights')))->setConstructorArgs(array($this->getMockInitialContext()))->getMockForAbstractClass();
        $service->expects($this->any())->method('findAll')->will($this->returnValue(array()));
        $service->expects($this->any())->method('load')->will($this->returnValue(null));
        $service->expects($this->exactly(3))->method('initUmask');
        $service->expects($this->exactly(3))->method('setUserRights');
        $tmp = $this->getTmpDir() . DIRECTORY_SEPARATOR;
        $tmpDir = $tmp . 'tmp';
        $cacheDir = $tmp . 'cache';
        $sessionDir = $tmp . 'session';
        $mockApplication = $this->getMockBuilder('\\AppserverIo\\Psr\\Application\\ApplicationInterface')->setMethods(get_class_methods('\\AppserverIo\\Appserver\\Application\\Application'))->getMock();
        $mockApplication->expects($this->once())->method('getTmpDir')->will($this->returnValue($tmpDir));
        $mockApplication->expects($this->once())->method('getCacheDir')->will($this->returnValue($cacheDir));
        $mockApplication->expects($this->once())->method('getSessionDir')->will($this->returnValue($sessionDir));
        $service->createTmpFolders($mockApplication);
        $this->assertTrue(is_dir($tmpDir));
        $this->assertTrue(is_dir($cacheDir));
        $this->assertTrue(is_dir($sessionDir));
    }