点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 行业软件>> 在线考试系统>> 源文件浏览
[免费版 Free] WebForm,下载次数:408 次 | 关键字: 考试 办公 高校 竞赛 企事业单位

源码截图

源码目录树

;
当前路径:vendor/phar-io/version/tests/Integration/VersionConstraintParserTest.php
<?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\VersionConstraintParser
 */
class VersionConstraintParserTest extends TestCase {
    /**
     * @dataProvider versionStringProvider
     *
     * @param string $versionString
     * @param VersionConstraint $expectedConstraint
     */
    public function testReturnsExpectedConstraint($versionString, VersionConstraint $expectedConstraint) {
        $parser = new VersionConstraintParser;

        $this->assertEquals($expectedConstraint, $parser->parse($versionString));
    }

    /**
     * @dataProvider unsupportedVersionStringProvider
     *
     * @param string $versionString
     */
    public function testThrowsExceptionIfVersionStringIsNotSupported($versionString) {
        $parser = new VersionConstraintParser;

        $this->expectException(UnsupportedVersionConstraintException::class);

        $parser->parse($versionString);
    }

    /**
     * @return array
     */
    public function versionStringProvider() {
        return [
            ['1.0.2', new ExactVersionConstraint('1.0.2')],
            [
                '~4.6',
                new AndVersionConstraintGroup(
                    '~4.6',
                    [
                        new GreaterThanOrEqualToVersionConstraint('~4.6', new Version('4.6')),
                        new SpecificMajorVersionConstraint('~4.6', 4)
                    ]
                )
            ],
            [
                '~4.6.2',
                new AndVersionConstraintGroup(
                    '~4.6.2',
                    [
                        new GreaterThanOrEqualToVersionConstraint('~4.6.2', new Version('4.6.2')),
                        new SpecificMajorAndMinorVersionConstraint('~4.6.2', 4, 6)
                    ]
                )
            ],
            [
                '^2.6.1',
                new AndVersionConstraintGroup(
                    '^2.6.1',
                    [
                        new GreaterThanOrEqualToVersionConstraint('^2.6.1', new Version('2.6.1')),
                        new SpecificMajorVersionConstraint('^2.6.1', 2)
                    ]
                )
            ],
            ['5.1.*', new SpecificMajorAndMinorVersionConstraint('5.1.*', 5, 1)],
            ['5.*', new SpecificMajorVersionConstraint('5.*', 5)],
            ['*', new AnyVersionConstraint()],
            [
                '1.0.2 || 1.0.5',
                new OrVersionConstraintGroup(
                    '1.0.2 || 1.0.5',
                    [
                        new ExactVersionConstraint('1.0.2'),
                        new ExactVersionConstraint('1.0.5')
                    ]
                )
            ],
            [
                '^5.6 || ^7.0',
                new OrVersionConstraintGroup(
                    '^5.6 || ^7.0',
                    [
                        new AndVersionConstraintGroup(
                            '^5.6', [
                                new GreaterThanOrEqualToVersionConstraint('^5.6', new Version('5.6')),
                                new SpecificMajorVersionConstraint('^5.6', 5)
                            ]
                        ),
                        new AndVersionConstraintGroup(
                            '^7.0', [
                                new GreaterThanOrEqualToVersionConstraint('^7.0', new Version('7.0')),
                                new SpecificMajorVersionConstraint('^7.0', 7)
                            ]
                        )
                    ]
                )
            ],
            ['7.0.28-1', new ExactVersionConstraint('7.0.28-1')],
            [
                '^3.0.0-alpha1',
                new AndVersionConstraintGroup(
                    '^3.0.0-alpha1',
                    [
                        new GreaterThanOrEqualToVersionConstraint('^3.0.0-alpha1', new Version('3.0.0-alpha1')),
                        new SpecificMajorVersionConstraint('^3.0.0-alpha1', 3)
                    ]
                )
            ],
            [
                '^3.0.0-alpha.1',
                new AndVersionConstraintGroup(
                    '^3.0.0-alpha.1',
                    [
                        new GreaterThanOrEqualToVersionConstraint('^3.0.0-alpha.1', new Version('3.0.0-alpha.1')),
                        new SpecificMajorVersionConstraint('^3.0.0-alpha.1', 3)
                    ]
                )
            ]
        ];
    }

    public function unsupportedVersionStringProvider() {
        return [
            ['foo'],
            ['+1.0.2'],
            ['>=2.0'],
            ['^5.6 || >= 7.0'],
            ['2.0 || foo']
        ];
    }
}
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2022. 京ICP备09089570号 | 京公网安备11010702000869号