from PHPUnitKit.tests import unittest

from PHPUnitKit.plugin import is_valid_php_version_file_version


class TestIsValidPhpVersionFileVersion(unittest.TestCase):

    def test_invalid_values(self):
        self.assertFalse(is_valid_php_version_file_version(''))
        self.assertFalse(is_valid_php_version_file_version(' '))
        self.assertFalse(is_valid_php_version_file_version('foobar'))
        self.assertFalse(is_valid_php_version_file_version('masterfoo'))
        self.assertFalse(is_valid_php_version_file_version('.'))
        self.assertFalse(is_valid_php_version_file_version('x'))
        self.assertFalse(is_valid_php_version_file_version('x.x'))
        self.assertFalse(is_valid_php_version_file_version('x.x.x'))
        self.assertFalse(is_valid_php_version_file_version('x'))
        self.assertFalse(is_valid_php_version_file_version('snapshot'))

    def test_master_branch_version(self):
        self.assertTrue(is_valid_php_version_file_version('master'))

    def test_specific_semver_versions(self):
        self.assertTrue(is_valid_php_version_file_version('5.0.0'))
        self.assertTrue(is_valid_php_version_file_version('5.0.1'))
        self.assertTrue(is_valid_php_version_file_version('5.0.7'))
        self.assertTrue(is_valid_php_version_file_version('5.0.30'))
        self.assertTrue(is_valid_php_version_file_version('5.0.32'))
        self.assertTrue(is_valid_php_version_file_version('5.1.0'))
        self.assertTrue(is_valid_php_version_file_version('5.1.1'))
        self.assertTrue(is_valid_php_version_file_version('5.1.3'))
        self.assertTrue(is_valid_php_version_file_version('5.1.27'))
        self.assertTrue(is_valid_php_version_file_version('7.0.0'))
        self.assertTrue(is_valid_php_version_file_version('7.1.19'))

    def test_minor_versions(self):
        self.assertTrue(is_valid_php_version_file_version('5.6'))
        self.assertTrue(is_valid_php_version_file_version('7.1'))
        self.assertTrue(is_valid_php_version_file_version('7.2'))

    def test_major_dot_x_versions(self):
        self.assertTrue(is_valid_php_version_file_version('5.x'))
        self.assertTrue(is_valid_php_version_file_version('6.x'))
        self.assertTrue(is_valid_php_version_file_version('7.x'))
        self.assertTrue(is_valid_php_version_file_version('8.x'))

    def test_major_dot_minor_dot_x_versions(self):
        self.assertTrue(is_valid_php_version_file_version('7.0.x'))
        self.assertTrue(is_valid_php_version_file_version('7.1.x'))
        self.assertTrue(is_valid_php_version_file_version('7.2.x'))

    def test_snapshot_versions(self):
        self.assertTrue(is_valid_php_version_file_version('5.4snapshot'))
        self.assertTrue(is_valid_php_version_file_version('5.5snapshot'))
        self.assertTrue(is_valid_php_version_file_version('5.6snapshot'))
        self.assertTrue(is_valid_php_version_file_version('7.0snapshot'))
        self.assertTrue(is_valid_php_version_file_version('7.1snapshot'))
        self.assertTrue(is_valid_php_version_file_version('7.0.0snapshot'))
        self.assertTrue(is_valid_php_version_file_version('7.1.0snapshot'))
        self.assertTrue(is_valid_php_version_file_version('7.1.1snapshot'))

[((225, 262), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['""""""'], {}), "('')\n", (258, 262), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((289, 327), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['""" """'], {}), "(' ')\n", (322, 327), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((354, 397), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""foobar"""'], {}), "('foobar')\n", (387, 397), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((424, 470), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""masterfoo"""'], {}), "('masterfoo')\n", (457, 470), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((497, 535), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""."""'], {}), "('.')\n", (530, 535), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((562, 600), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""x"""'], {}), "('x')\n", (595, 600), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((627, 667), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""x.x"""'], {}), "('x.x')\n", (660, 667), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((694, 736), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""x.x.x"""'], {}), "('x.x.x')\n", (727, 736), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((763, 801), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""x"""'], {}), "('x')\n", (796, 801), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((828, 873), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""snapshot"""'], {}), "('snapshot')\n", (861, 873), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((942, 985), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""master"""'], {}), "('master')\n", (975, 985), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1057, 1099), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.0.0"""'], {}), "('5.0.0')\n", (1090, 1099), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1125, 1167), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.0.1"""'], {}), "('5.0.1')\n", (1158, 1167), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1193, 1235), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.0.7"""'], {}), "('5.0.7')\n", (1226, 1235), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1261, 1304), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.0.30"""'], {}), "('5.0.30')\n", (1294, 1304), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1330, 1373), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.0.32"""'], {}), "('5.0.32')\n", (1363, 1373), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1399, 1441), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.1.0"""'], {}), "('5.1.0')\n", (1432, 1441), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1467, 1509), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.1.1"""'], {}), "('5.1.1')\n", (1500, 1509), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1535, 1577), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.1.3"""'], {}), "('5.1.3')\n", (1568, 1577), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1603, 1646), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.1.27"""'], {}), "('5.1.27')\n", (1636, 1646), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1672, 1714), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.0.0"""'], {}), "('7.0.0')\n", (1705, 1714), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1740, 1783), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.1.19"""'], {}), "('7.1.19')\n", (1773, 1783), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1845, 1885), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.6"""'], {}), "('5.6')\n", (1878, 1885), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1911, 1951), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.1"""'], {}), "('7.1')\n", (1944, 1951), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((1977, 2017), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.2"""'], {}), "('7.2')\n", (2010, 2017), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2085, 2125), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.x"""'], {}), "('5.x')\n", (2118, 2125), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2151, 2191), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""6.x"""'], {}), "('6.x')\n", (2184, 2191), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2217, 2257), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.x"""'], {}), "('7.x')\n", (2250, 2257), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2283, 2323), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""8.x"""'], {}), "('8.x')\n", (2316, 2323), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2401, 2443), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.0.x"""'], {}), "('7.0.x')\n", (2434, 2443), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2469, 2511), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.1.x"""'], {}), "('7.1.x')\n", (2502, 2511), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2537, 2579), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.2.x"""'], {}), "('7.2.x')\n", (2570, 2579), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2644, 2692), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.4snapshot"""'], {}), "('5.4snapshot')\n", (2677, 2692), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2718, 2766), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.5snapshot"""'], {}), "('5.5snapshot')\n", (2751, 2766), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2792, 2840), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""5.6snapshot"""'], {}), "('5.6snapshot')\n", (2825, 2840), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2866, 2914), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.0snapshot"""'], {}), "('7.0snapshot')\n", (2899, 2914), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((2940, 2988), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.1snapshot"""'], {}), "('7.1snapshot')\n", (2973, 2988), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((3014, 3064), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.0.0snapshot"""'], {}), "('7.0.0snapshot')\n", (3047, 3064), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((3090, 3140), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.1.0snapshot"""'], {}), "('7.1.0snapshot')\n", (3123, 3140), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), ((3166, 3216), 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', (['"""7.1.1snapshot"""'], {}), "('7.1.1snapshot')\n", (3199, 3216), False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n')]