diff --git a/Classes/Utility/Varnish/Command/VarnishAdministrationCommand.php b/Classes/Utility/Varnish/Command/VarnishAdministrationCommand.php deleted file mode 100644 index 6630f425..00000000 --- a/Classes/Utility/Varnish/Command/VarnishAdministrationCommand.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * This script is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use PunktDe\PtExtbase\Utility\GenericShellCommandWrapper\GenericShellCommand; - -/** - * Varnish Administration Command - * - * @package PunktDe\PtExtbase\Utility\Varnish\Command - */ -class VarnishAdministrationCommand extends GenericShellCommand -{ - /** - * @var array - */ - protected $argumentMap = [ - 'secretFile' => '-S %s', - 'address' => '%s', - 'port' => '%s' - ]; - - - /** - * @var array - */ - protected $arguments = [ - 'secretFile' => '', - 'address' => '', - 'port' => '' - ]; - - - - /** - * @param string $secretFile - * @return $this - */ - public function setSecretFile($secretFile) - { - $this->arguments['secretFile'] = $secretFile; - return $this; - } - - - - /** - * @param string $address - * @return $this - */ - public function setAddress($address) - { - $this->arguments['address'] = $address; - return $this; - } - - - - /** - * @param string $port - * @return $this - */ - public function setPort($port) - { - $this->arguments['portMode'] = $port; - return $this; - } - - - - /** - * @return BanUrlCommand - */ - public function add() - { - $command = $this->objectManager->get('PunktDe\PtExtbase\Utility\Varnish\Command\Remote\BanUrlCommand'); - $command->attachCommand($this); - return $command; - } - - - - /** - * @return string - */ - public function render() - { - return sprintf("%s", $this->buildCommand()); - } - - - - /** - * @return string - */ - public function getCommandName() - { - return 'varnishadm'; - } -} diff --git a/Classes/Utility/Varnish/VarnishAdministration.php b/Classes/Utility/Varnish/VarnishAdministration.php deleted file mode 100644 index 5eff5b02..00000000 --- a/Classes/Utility/Varnish/VarnishAdministration.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * This script is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use PunktDe\PtExtbase\Utility\GenericShellCommandWrapper\GenericShellCommand; -use PunktDe\PtExtbase\Utility\Varnish\Command; - -/** - * Varnish Administration - * - * @package PunktDe\PtExtbase\Utility\Varnish - */ -class VarnishAdministration extends GenericShellCommand -{ - /** - * @var string - */ - protected $commandPath = '/usr/bin/varnishadm'; - - - /** - * @var array - */ - protected $argumentMap = [ - 'secretFile' => '-S %s', - 'addressAndPort' => '-T %s' - ]; - - - /** - * @var array - */ - protected $arguments = [ - 'secretFile' => '', - 'addressAndPort' => '' - ]; - - - /** - * @param string $commandDirectory - */ - public function __construct($commandDirectory) - { - $this->commandPath = $commandDirectory; - } - - - /** - * @param string $secretFile - * @return $this - */ - public function setSecretFile($secretFile) - { - $this->arguments['secretFile'] = $secretFile; - return $this; - } - - - - /** - * @param string $addressAndPort - * @return $this - */ - public function setAddressAndPort($addressAndPort) - { - $this->arguments['addressAndPort'] = $addressAndPort; - return $this; - } - - - - /** - * @return \PunktDe\PtExtbase\Utility\Varnish\Command\BanUrlCommand - */ - public function banUrl() - { - $command = $this->objectManager->get('PunktDe\PtExtbase\Utility\Varnish\Command\BanUrlCommand'); - $command->attachCommand($this); - return $command; - } - - - - /** - * @return string - */ - public function render() - { - return sprintf("%s", $this->buildCommand()); - } - - - - /** - * @return string - */ - public function getCommandName() - { - return $this->commandPath; - } -} diff --git a/Classes/Utility/Varnish/VarnishAdministrationException.php b/Classes/Utility/Varnish/VarnishAdministrationException.php deleted file mode 100644 index 54da85c1..00000000 --- a/Classes/Utility/Varnish/VarnishAdministrationException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * This script is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -/** - * Varnish Administration Exception - * - * @package PunktDe\PtExtbase\Utility\Git - */ -class VarnishAdministrationException extends \Exception -{ -} diff --git a/Tests/Unit/Utility/Varnish/VarnishAdministrationTest.php b/Tests/Unit/Utility/Varnish/VarnishAdministrationTest.php deleted file mode 100755 index 0e953c1b..00000000 --- a/Tests/Unit/Utility/Varnish/VarnishAdministrationTest.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * This script is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use \TYPO3\TestingFramework\Core\Unit\UnitTestCase; - -/** - * Varnish Administration Test Case - * - * @package pt_extbase - * @subpackage PunktDe\PtExtbase\Tests\Unit\Utility\Git - */ -class VarnishAdministrationTest extends UnitTestCase -{ - /** - * @var \PunktDe\PtExtbase\Utility\Varnish\VarnishAdministration - */ - protected $proxy; - - - /** - * @var string - */ - protected $pathToGitCommand = ''; - - - /** - * @var \TYPO3\CMS\Extbase\Object\Container\Container - */ - protected $objectContainer; - - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $shellCommandServiceMock; - - - /** - * @return void - */ - public function setUp(): void - { - //$this->prepareProxy(); - } - - - - /** - * @return void - */ - protected function prepareProxy() - { - $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); - - $this->objectContainer = $objectManager->get('TYPO3\CMS\Extbase\Object\Container\Container'); /** @var \TYPO3\CMS\Extbase\Object\Container\Container $objectContainer */ - - $this->getMockBuilder(\PunktDe\PtExtbase\Logger\Logger::class) - ->setMockClassName('LoggerMock') - ->getMock(); - $objectManager->get('LoggerMock'); /** @var $loggerMock \PHPUnit_Framework_MockObject_MockObject */ - $this->objectContainer->registerImplementation(\PunktDe\PtExtbase\Logger\Logger::class, 'LoggerMock'); - - $this->getMockBuilder('PunktDe\PtExtbase\Utility\ShellCommandService') - ->setMethods(['execute']) - ->setMockClassName('ShellCommandServiceMock') - ->getMock(); - $this->shellCommandServiceMock = $objectManager->get('ShellCommandServiceMock'); /** @var $shellCommandServiceMock \PHPUnit_Framework_MockObject_MockObject */ - $this->objectContainer->registerImplementation('PunktDe\PtExtbase\Utility\ShellCommandService', 'ShellCommandServiceMock'); - - $proxyClass = $this->buildAccessibleProxy('PunktDe\PtExtbase\Utility\Varnish\VarnishAdministration'); - - $this->proxy = new $proxyClass('/usr/bin/varnishadm'); - } - - - - /** - * @test - */ - public function validCommandIsRendered() - { - $this->markTestSkipped('Functionaltest'); - $this->prepareShellCommandExpectations(); - - $this->proxy->setSecretFile('/home/spencer/varnish-secret') - ->setAddressAndPort('127.0.0.1:6082') - ->banUrl() - ->setUrl('spencer\.it/films.*') - ->execute(); - } - - - - /** - * @return void - */ - protected function prepareShellCommandExpectations() - { - $this->shellCommandServiceMock->expects($this->any()) - ->method('execute') - ->withConsecutive( - [$this->equalTo('/usr/bin/varnishadm -S /home/spencer/varnish-secret -T 127.0.0.1:6082 "ban.url spencer\.it/films.*"')] - ); - } -}