PDF rausgenommen
This commit is contained in:
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license.
|
||||
*/
|
||||
|
||||
namespace ProxyManagerTest\Signature;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use ProxyManager\Signature\ClassSignatureGenerator;
|
||||
use Zend\Code\Generator\PropertyGenerator;
|
||||
|
||||
/**
|
||||
* Tests for {@see \ProxyManager\Signature\ClassSignatureGenerator}
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
* @license MIT
|
||||
*
|
||||
* @covers \ProxyManager\Signature\ClassSignatureGenerator
|
||||
* @group Coverage
|
||||
*/
|
||||
class ClassSignatureGeneratorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \ProxyManager\Signature\SignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $signatureGenerator;
|
||||
|
||||
/**
|
||||
* @var ClassSignatureGenerator
|
||||
*/
|
||||
private $classSignatureGenerator;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->signatureGenerator = $this->getMock('ProxyManager\\Signature\\SignatureGeneratorInterface');
|
||||
$this->classSignatureGenerator = new ClassSignatureGenerator($this->signatureGenerator);
|
||||
}
|
||||
|
||||
public function testAddSignature()
|
||||
{
|
||||
/* @var $classGenerator \PHPUnit_Framework_MockObject_MockObject|\Zend\Code\Generator\ClassGenerator */
|
||||
$classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator');
|
||||
|
||||
$classGenerator
|
||||
->expects($this->once())
|
||||
->method('addPropertyFromGenerator')
|
||||
->with($this->callback(function (PropertyGenerator $property) {
|
||||
return $property->getName() === 'signaturePropertyName'
|
||||
&& $property->isStatic()
|
||||
&& $property->getVisibility() === 'private'
|
||||
&& $property->getDefaultValue()->getValue() === 'valid-signature';
|
||||
}));
|
||||
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->any())
|
||||
->method('generateSignature')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('valid-signature'));
|
||||
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->any())
|
||||
->method('generateSignatureKey')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('PropertyName'));
|
||||
|
||||
|
||||
$this->classSignatureGenerator->addSignature($classGenerator, array('foo' => 'bar'));
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license.
|
||||
*/
|
||||
|
||||
namespace ProxyManagerTest\Signature\Exception;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use ProxyManager\Signature\Exception\InvalidSignatureException;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Tests for {@see \ProxyManager\Signature\Exception\InvalidSignatureException}
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
* @license MIT
|
||||
*
|
||||
* @covers \ProxyManager\Signature\Exception\InvalidSignatureException
|
||||
* @group Coverage
|
||||
*/
|
||||
class InvalidSignatureExceptionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFromInvalidSignature()
|
||||
{
|
||||
$exception = InvalidSignatureException::fromInvalidSignature(
|
||||
new ReflectionClass(__CLASS__),
|
||||
array('foo' => 'bar', 'baz' => 'tab'),
|
||||
'blah',
|
||||
'expected-signature'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
'ProxyManager\Signature\Exception\InvalidSignatureException',
|
||||
$exception
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'Found signature "blah" for class "'
|
||||
. __CLASS__
|
||||
. '" does not correspond to expected signature "expected-signature" for 2 parameters',
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license.
|
||||
*/
|
||||
|
||||
namespace ProxyManagerTest\Signature\Exception;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use ProxyManager\Signature\Exception\MissingSignatureException;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Tests for {@see \ProxyManager\Signature\Exception\MissingSignatureException}
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
* @license MIT
|
||||
*
|
||||
* @covers \ProxyManager\Signature\Exception\MissingSignatureException
|
||||
* @group Coverage
|
||||
*/
|
||||
class MissingSignatureExceptionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFromMissingSignature()
|
||||
{
|
||||
$exception = MissingSignatureException::fromMissingSignature(
|
||||
new ReflectionClass(__CLASS__),
|
||||
array('foo' => 'bar', 'baz' => 'tab'),
|
||||
'expected-signature'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
'ProxyManager\Signature\Exception\MissingSignatureException',
|
||||
$exception
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'No signature found for class "'
|
||||
. __CLASS__
|
||||
. '", expected signature "expected-signature" for 2 parameters',
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
117
msd2/phpBB3/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php
vendored
Normal file
117
msd2/phpBB3/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license.
|
||||
*/
|
||||
|
||||
namespace ProxyManagerTest\Signature;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use ProxyManager\Signature\SignatureChecker;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Tests for {@see \ProxyManager\Signature\SignatureChecker}
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
* @license MIT
|
||||
*
|
||||
* @covers \ProxyManager\Signature\SignatureChecker
|
||||
* @group Coverage
|
||||
*/
|
||||
class SignatureCheckerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signatureExample = 'valid-signature';
|
||||
|
||||
/**
|
||||
* @var SignatureChecker
|
||||
*/
|
||||
private $signatureChecker;
|
||||
|
||||
/**
|
||||
* @var \ProxyManager\Signature\SignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $signatureGenerator;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->signatureGenerator = $this->getMock('ProxyManager\Signature\SignatureGeneratorInterface');
|
||||
$this->signatureChecker = new SignatureChecker($this->signatureGenerator);
|
||||
}
|
||||
|
||||
public function testCheckSignatureWithValidKey()
|
||||
{
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->atLeastOnce())
|
||||
->method('generateSignatureKey')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('Example'));
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->atLeastOnce())
|
||||
->method('generateSignature')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('valid-signature'));
|
||||
|
||||
$this->signatureChecker->checkSignature(new ReflectionClass($this), array('foo' => 'bar'));
|
||||
}
|
||||
|
||||
public function testCheckSignatureWithInvalidKey()
|
||||
{
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->any())
|
||||
->method('generateSignatureKey')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('InvalidKey'));
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->any())
|
||||
->method('generateSignature')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('valid-signature'));
|
||||
|
||||
$this->setExpectedException('ProxyManager\Signature\Exception\MissingSignatureException');
|
||||
|
||||
$this->signatureChecker->checkSignature(new ReflectionClass($this), array('foo' => 'bar'));
|
||||
}
|
||||
|
||||
public function testCheckSignatureWithInvalidValue()
|
||||
{
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->any())
|
||||
->method('generateSignatureKey')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('Example'));
|
||||
$this
|
||||
->signatureGenerator
|
||||
->expects($this->any())
|
||||
->method('generateSignature')
|
||||
->with(array('foo' => 'bar'))
|
||||
->will($this->returnValue('invalid-signature'));
|
||||
|
||||
$this->setExpectedException('ProxyManager\Signature\Exception\InvalidSignatureException');
|
||||
|
||||
$this->signatureChecker->checkSignature(new ReflectionClass($this), array('foo' => 'bar'));
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license.
|
||||
*/
|
||||
|
||||
namespace ProxyManagerTest\Signature;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use ProxyManager\Signature\SignatureGenerator;
|
||||
|
||||
/**
|
||||
* Tests for {@see \ProxyManager\Signature\SignatureGenerator}
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
* @license MIT
|
||||
*
|
||||
* @covers \ProxyManager\Signature\SignatureGenerator
|
||||
* @group Coverage
|
||||
*/
|
||||
class SignatureGeneratorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var SignatureGenerator
|
||||
*/
|
||||
private $signatureGenerator;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->signatureGenerator = new SignatureGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* @param string $expected
|
||||
*
|
||||
* @dataProvider signatures
|
||||
*/
|
||||
public function testGenerateSignature(array $parameters, $expected)
|
||||
{
|
||||
$this->assertSame($expected, $this->signatureGenerator->generateSignature($parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* @param string $expected
|
||||
*
|
||||
* @dataProvider signatureKeys
|
||||
*/
|
||||
public function testGenerateSignatureKey(array $parameters, $expected)
|
||||
{
|
||||
$this->assertSame($expected, $this->signatureGenerator->generateSignatureKey($parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function signatures()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(),
|
||||
'YTowOnt9'
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar'),
|
||||
'YToxOntzOjM6ImZvbyI7czozOiJiYXIiO30='
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'baz' => 'tab'),
|
||||
'YToyOntzOjM6ImZvbyI7czozOiJiYXIiO3M6MzoiYmF6IjtzOjM6InRhYiI7fQ=='
|
||||
),
|
||||
array(
|
||||
array('bar'),
|
||||
'YToxOntpOjA7czozOiJiYXIiO30='
|
||||
),
|
||||
array(
|
||||
array('bar', 'baz'),
|
||||
'YToyOntpOjA7czozOiJiYXIiO2k6MTtzOjM6ImJheiI7fQ=='
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function signatureKeys()
|
||||
{
|
||||
return array(
|
||||
array(array(), '40cd750bba9870f18aada2478b24840a'),
|
||||
array(array('foo' => 'bar'), '49a3696adf0fbfacc12383a2d7400d51'),
|
||||
array(array('foo' => 'bar', 'baz' => 'tab'), '3f3cabbf33bae82b0711205c913a8fa0'),
|
||||
array(array('bar'), '6fc5f617053f53f56b4734453ec86daa'),
|
||||
array(array('bar', 'baz'), 'b9f31192ffbb4aa958cd1c5f88540c1e'),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user