Initial commit

This commit is contained in:
2018-04-02 08:07:38 +02:00
commit 7330c1ed3e
2054 changed files with 405203 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Once;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
/**
* @protection on
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class CookieViewHelperTest extends AbstractViewHelperTest {
/**
* @return void
*/
public function testAssertShouldSkip() {
$mock = $this->getMock($this->getViewHelperClassName(), array('getIdentifier'));
$mock->expects($this->exactly(2))->method('getIdentifier')->willReturn('test');
$this->assertFalse($this->callInaccessibleMethod($mock, 'assertShouldSkip'));
$_COOKIE['test'] = 'test';
$this->assertTrue($this->callInaccessibleMethod($mock, 'assertShouldSkip'));
unset($_COOKIE['test']);
}
/**
* @return void
*/
public function testRemoveIfExpired() {
$mock = $this->getMock($this->getViewHelperClassName(), array('getIdentifier', 'removeCookie'));
$mock->expects($this->exactly(2))->method('getIdentifier')->willReturn('test');
$mock->expects($this->once())->method('removeCookie');
$this->callInaccessibleMethod($mock, 'removeIfExpired');
$_COOKIE['test'] = 'test';
$this->callInaccessibleMethod($mock, 'removeIfExpired');
unset($_COOKIE['test']);
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Once;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Mvc\Web\Request;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
/**
* @protection on
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class InstanceViewHelperTest extends AbstractViewHelperTest {
/**
* @dataProvider getIdentifierTestValues
* @param string|NULL $identifierArgument
* @param string $expectedIdentifier
*/
public function testGetIdentifier($identifierArgument, $expectedIdentifier) {
$instance = $this->createInstance();
$instance->setArguments(array('identifier' => $identifierArgument));
$renderingContext = new RenderingContext();
$controllerContext = new ControllerContext();
$request = new Request();
$request->setControllerActionName('p1');
$request->setControllerName('p2');
$request->setPluginName('p3');
$request->setControllerExtensionName('p4');
$controllerContext->setRequest($request);
$renderingContext->setControllerContext($controllerContext);
$instance->setRenderingContext($renderingContext);
$result = $this->callInaccessibleMethod($instance, 'getIdentifier');
$this->assertEquals($expectedIdentifier, $result);
}
/**
* @return array
*/
public function getIdentifierTestValues() {
return array(
array(NULL, 'p1_p2_p3_p4'),
array('test', 'test'),
array('test2', 'test2'),
);
}
/**
* @return void
*/
public function testStoreIdentifier() {
$instance = $this->createInstance();
$instance->setArguments(array('identifier' => 'test'));
$this->callInaccessibleMethod($instance, 'storeIdentifier');
$this->assertTrue($GLOBALS[get_class($instance)]['test']);
unset($GLOBALS[get_class($instance)]['test']);
}
/**
* @return void
*/
public function testAssertShouldSkip() {
$instance = $this->createInstance();
$instance->setArguments(array('identifier' => 'test'));
$this->assertFalse($this->callInaccessibleMethod($instance, 'assertShouldSkip'));
$GLOBALS[get_class($instance)]['test'] = TRUE;
$this->assertTrue($this->callInaccessibleMethod($instance, 'assertShouldSkip'));
unset($GLOBALS[get_class($instance)]['test']);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Once;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
/**
* @protection on
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class SessionViewHelperTest extends AbstractViewHelperTest {
/**
* @return void
*/
public function testStoreIdentifier() {
$instance = $this->createInstance();
$instance->setArguments(array('identifier' => 'test'));
$this->callInaccessibleMethod($instance, 'storeIdentifier');
$this->assertEquals(time(), $_SESSION[get_class($instance)]['test']);
unset($_SESSION[get_class($instance)]['test']);
}
/**
* @return void
*/
public function testAssertShouldSkip() {
$instance = $this->createInstance();
$instance->setArguments(array('identifier' => 'test'));
$this->assertFalse($this->callInaccessibleMethod($instance, 'assertShouldSkip'));
$_SESSION[get_class($instance)]['test'] = time();
$this->assertTrue($this->callInaccessibleMethod($instance, 'assertShouldSkip'));
unset($_SESSION[get_class($instance)]['test']);
}
/**
* @return void
*/
public function testRemoveIfExpired() {
$instance = $this->createInstance();
$class = $this->getViewHelperClassName();
$time = time() - 10;
$_SESSION[$class]['test'] = $time;
$instance->setArguments(array('identifier' => 'test', 'ttl' => 15));
$this->callInaccessibleMethod($instance, 'removeIfExpired');
$this->assertArrayHasKey('test', $_SESSION[$class]);
$instance->setArguments(array('identifier' => 'test', 'ttl' => 5));
$this->callInaccessibleMethod($instance, 'removeIfExpired');
$this->assertArrayNotHasKey('test', $_SESSION[$class]);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Once;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
/**
* @protection on
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class StandardViewHelperTest extends AbstractViewHelperTest {
}