Added Laravel project

This commit is contained in:
2017-09-17 00:35:10 +02:00
parent a3c19304d5
commit ecf605b8f5
6246 changed files with 682270 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\AbstractVersionConstraint
*/
class AbstractVersionConstraintTest extends TestCase {
public function testAsString() {
/** @var AbstractVersionConstraint|\PHPUnit_Framework_MockObject_MockObject $constraint */
$constraint = $this->getMockForAbstractClass(AbstractVersionConstraint::class, ['foo']);
$this->assertSame('foo', $constraint->asString());
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\AndVersionConstraintGroup
*/
class AndVersionConstraintGroupTest extends TestCase {
public function testReturnsFalseIfOneConstraintReturnsFalse() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$group = new AndVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertFalse($group->complies(new Version('1.0.0')));
}
public function testReturnsTrueIfAllConstraintsReturnsTrue() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$group = new AndVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertTrue($group->complies(new Version('1.0.0')));
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\AnyVersionConstraint
*/
class AnyVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
[new Version('1.0.2')],
[new Version('4.8')],
[new Version('0.1.1-dev')]
];
}
/**
* @dataProvider versionProvider
*
* @param Version $version
*/
public function testReturnsTrue(Version $version) {
$constraint = new AnyVersionConstraint;
$this->assertTrue($constraint->complies($version));
}
public function testAsString() {
$this->assertSame('*', (new AnyVersionConstraint())->asString());
}
}

View File

@@ -0,0 +1,58 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\ExactVersionConstraint
*/
class ExactVersionConstraintTest extends TestCase {
public function compliantVersionProvider() {
return [
['1.0.2', new Version('1.0.2')],
['4.8.9', new Version('4.8.9')],
['4.8', new Version('4.8')],
];
}
public function nonCompliantVersionProvider() {
return [
['1.0.2', new Version('1.0.3')],
['4.8.9', new Version('4.7.9')],
['4.8', new Version('4.8.5')],
];
}
/**
* @dataProvider compliantVersionProvider
*
* @param string $constraintValue
* @param Version $version
*/
public function testReturnsTrueForCompliantVersion($constraintValue, Version $version) {
$constraint = new ExactVersionConstraint($constraintValue);
$this->assertTrue($constraint->complies($version));
}
/**
* @dataProvider nonCompliantVersionProvider
*
* @param string $constraintValue
* @param Version $version
*/
public function testReturnsFalseForNonCompliantVersion($constraintValue, Version $version) {
$constraint = new ExactVersionConstraint($constraintValue);
$this->assertFalse($constraint->complies($version));
}
}

View File

@@ -0,0 +1,47 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\GreaterThanOrEqualToVersionConstraint
*/
class GreaterThanOrEqualToVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
// compliant versions
[new Version('1.0.2'), new Version('1.0.2'), true],
[new Version('1.0.2'), new Version('1.0.3'), true],
[new Version('1.0.2'), new Version('1.1.1'), true],
[new Version('1.0.2'), new Version('2.0.0'), true],
[new Version('1.0.2'), new Version('1.0.3'), true],
// non-compliant versions
[new Version('1.0.2'), new Version('1.0.1'), false],
[new Version('1.9.8'), new Version('0.9.9'), false],
[new Version('2.3.1'), new Version('2.2.3'), false],
[new Version('3.0.2'), new Version('2.9.9'), false],
];
}
/**
* @dataProvider versionProvider
*
* @param Version $constraintVersion
* @param Version $version
* @param bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions(Version $constraintVersion, Version $version, $expectedResult) {
$constraint = new GreaterThanOrEqualToVersionConstraint('foo', $constraintVersion);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\OrVersionConstraintGroup
*/
class OrVersionConstraintGroupTest extends TestCase {
public function testReturnsTrueIfOneConstraintReturnsFalse() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertTrue($group->complies(new Version('1.0.0')));
}
public function testReturnsTrueIfAllConstraintsReturnsTrue() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(true));
$group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertTrue($group->complies(new Version('1.0.0')));
}
public function testReturnsFalseIfAllConstraintsReturnsFalse() {
$firstConstraint = $this->createMock(VersionConstraint::class);
$secondConstraint = $this->createMock(VersionConstraint::class);
$firstConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$secondConstraint->expects($this->once())
->method('complies')
->will($this->returnValue(false));
$group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
$this->assertFalse($group->complies(new Version('1.0.0')));
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\SpecificMajorAndMinorVersionConstraint
*/
class SpecificMajorAndMinorVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
// compliant versions
[1, 0, new Version('1.0.2'), true],
[1, 0, new Version('1.0.3'), true],
[1, 1, new Version('1.1.1'), true],
// non-compliant versions
[2, 9, new Version('0.9.9'), false],
[3, 2, new Version('2.2.3'), false],
[2, 8, new Version('2.9.9'), false],
];
}
/**
* @dataProvider versionProvider
*
* @param int $major
* @param int $minor
* @param Version $version
* @param bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions($major, $minor, Version $version, $expectedResult) {
$constraint = new SpecificMajorAndMinorVersionConstraint('foo', $major, $minor);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers PharIo\Version\SpecificMajorVersionConstraint
*/
class SpecificMajorVersionConstraintTest extends TestCase {
public function versionProvider() {
return [
// compliant versions
[1, new Version('1.0.2'), true],
[1, new Version('1.0.3'), true],
[1, new Version('1.1.1'), true],
// non-compliant versions
[2, new Version('0.9.9'), false],
[3, new Version('2.2.3'), false],
[3, new Version('2.9.9'), false],
];
}
/**
* @dataProvider versionProvider
*
* @param int $major
* @param Version $version
* @param bool $expectedResult
*/
public function testReturnsTrueForCompliantVersions($major, Version $version, $expectedResult) {
$constraint = new SpecificMajorVersionConstraint('foo', $major);
$this->assertSame($expectedResult, $constraint->complies($version));
}
}

View File

@@ -0,0 +1,104 @@
<?php
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Version\Version
*/
class VersionTest extends TestCase {
/**
* @dataProvider versionProvider
*
* @param string $versionString
* @param string $expectedMajor
* @param string $expectedMinor
* @param string $expectedPatch
* @param string $expectedPreReleaseValue
* @param int $expectedReleaseCount
*/
public function testParsesVersionNumbers($versionString, $expectedMajor, $expectedMinor, $expectedPatch, $expectedPreReleaseValue = '', $expectedReleaseCount = 0) {
$version = new Version($versionString);
$this->assertSame($expectedMajor, $version->getMajor()->getValue());
$this->assertSame($expectedMinor, $version->getMinor()->getValue());
$this->assertSame($expectedPatch, $version->getPatch()->getValue());
if ($expectedPreReleaseValue !== '') {
$this->assertSame($expectedPreReleaseValue, $version->getPreReleaseSuffix()->getValue());
}
if ($expectedReleaseCount !== 0) {
$this->assertSame($expectedReleaseCount, $version->getPreReleaseSuffix()->getNumber());
}
$this->assertSame($versionString, $version->getVersionString());
}
public function versionProvider() {
return [
['0.0.1', '0', '0', '1'],
['0.1.2', '0', '1', '2'],
['1.0.0-alpha', '1', '0', '0', 'alpha'],
['3.4.12-dev3', '3', '4', '12', 'dev', 3],
];
}
/**
* @dataProvider versionGreaterThanProvider
*
* @param Version $versionA
* @param Version $versionB
* @param bool $expectedResult
*/
public function testIsGreaterThan(Version $versionA, Version $versionB, $expectedResult) {
$this->assertSame($expectedResult, $versionA->isGreaterThan($versionB));
}
/**
* @return array
*/
public function versionGreaterThanProvider() {
return [
[new Version('1.0.0'), new Version('1.0.1'), false],
[new Version('1.0.1'), new Version('1.0.0'), true],
[new Version('1.1.0'), new Version('1.0.1'), true],
[new Version('1.1.0'), new Version('2.0.1'), false],
[new Version('1.1.0'), new Version('1.1.0'), false],
[new Version('2.5.8'), new Version('1.6.8'), true],
[new Version('2.5.8'), new Version('2.6.8'), false],
[new Version('2.5.8'), new Version('3.1.2'), false],
];
}
/**
* @dataProvider invalidVersionStringProvider
*
* @param string $versionString
*/
public function testThrowsExceptionIfVersionStringDoesNotFollowSemVer($versionString)
{
$this->expectException(InvalidVersionException::class);
new Version($versionString);
}
/**
* @return array
*/
public function invalidVersionStringProvider()
{
return [
['foo'],
['0.0.1-dev+ABC', '0', '0', '1', 'dev', 'ABC'],
['1.0.0-x.7.z.92', '1', '0', '0', 'x.7.z.92']
];
}
}