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'))

[(9, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (10, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (11, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (12, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (13, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (14, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (15, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (16, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (17, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (18, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (21, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (24, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (25, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (26, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (27, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (28, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (29, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (30, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (31, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (32, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (33, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (34, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (37, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (38, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (39, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (42, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (43, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (44, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (45, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (48, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (49, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (50, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (53, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (54, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (55, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (56, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (57, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (58, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (59, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n'), (60, 'PHPUnitKit.plugin.is_valid_php_version_file_version', 'is_valid_php_version_file_version', False, 'from PHPUnitKit.plugin import is_valid_php_version_file_version\n')]