Beispiel #1
0
class PHPFormatCheckTest(CheckTestCase):
    check = PHPFormatCheck()

    def setUp(self):
        super(PHPFormatCheckTest, self).setUp()
        self.test_highlight = (
            'php-format',
            '%sstring%d',
            [(0, 2, u'%s'), (8, 10, u'%d')],
        )

    def test_no_format(self):
        self.assertFalse(self.check.check_format('strins', 'string', False))

    def test_format(self):
        self.assertFalse(
            self.check.check_format('%s string', '%s string', False))

    def test_named_format(self):
        self.assertFalse(
            self.check.check_format('%1$s string', '%1$s string', False))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format('%s string', 'string', False))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format('%1$s string', 'string',
                                                False))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format('%1$s string', 'string',
                                                 True))

    def test_wrong_format(self):
        self.assertTrue(
            self.check.check_format('%s string', '%c string', False))

    def test_double_format(self):
        self.assertTrue(
            self.check.check_format('%s string', '%s%s string', False))

    def test_reorder_format(self):
        self.assertFalse(
            self.check.check_format('%1$s %2$s string', '%2$s %1$s string',
                                    False))

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format('%1$s string', '%s string', False))

    def test_wrong_percent_format(self):
        self.assertTrue(
            self.check.check_format('%s%% (0.1%%)', '%s%% (0.1%)', False))

    def test_missing_percent_format(self):
        self.assertFalse(
            self.check.check_format('%s%% %%', '%s%% percent', False))
 def setUp(self):
     self.check = PHPFormatCheck()
class PHPFormatCheckTest(TestCase):
    def setUp(self):
        self.check = PHPFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            MockUnit('php_no_format'),
            0,
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            u'%s string',
            u'%s string',
            MockUnit('php_format'),
            0,
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%1$s string',
            u'%1$s string',
            MockUnit('php_named_format'),
            0,
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'string',
            MockUnit('php_missing_format'),
            0,
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%1$s string',
            u'string',
            MockUnit('php_missing_named_format'),
            0,
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            u'%1$s string',
            u'string',
            MockUnit('php_missing_named_format'),
            0,
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%c string',
            MockUnit('php_wrong_format'),
            0,
            False
        ))

    def test_double_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%s%s string',
            MockUnit('php_double_format'),
            0,
            False
        ))

    def test_reorder_format(self):
        self.assertFalse(self.check.check_format(
            u'%1$s %2$s string',
            u'%2$s %1$s string',
            MockUnit('php_reorder_format'),
            0,
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%1$s string',
            u'%s string',
            MockUnit('php_wrong_named_format'),
            0,
            False
        ))

    def test_wrong_percent_format(self):
        self.assertTrue(self.check.check_format(
            u'%s%% (0.1%%)',
            u'%s%% (0.1%)',
            MockUnit('php_wrong_percent_format'),
            0,
            False
        ))

    def test_missing_percent_format(self):
        self.assertFalse(self.check.check_format(
            u'%s%% %%',
            u'%s%% percent',
            MockUnit('php_missing_percent_format'),
            0,
            False
        ))
Beispiel #4
0
 def setUp(self):
     self.check = PHPFormatCheck()
Beispiel #5
0
class PHPFormatCheckTest(TestCase):
    def setUp(self):
        self.check = PHPFormatCheck()

    def test_no_format(self):
        self.assertFalse(
            self.check.check_format('strins', 'string',
                                    MockUnit('php_no_format'), 0, False))

    def test_format(self):
        self.assertFalse(
            self.check.check_format(u'%s string', u'%s string',
                                    MockUnit('php_format'), 0, False))

    def test_named_format(self):
        self.assertFalse(
            self.check.check_format(u'%1$s string', u'%1$s string',
                                    MockUnit('php_named_format'), 0, False))

    def test_missing_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'string',
                                    MockUnit('php_missing_format'), 0, False))

    def test_missing_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%1$s string', u'string',
                                    MockUnit('php_missing_named_format'), 0,
                                    False))

    def test_missing_named_format_ignore(self):
        self.assertFalse(
            self.check.check_format(u'%1$s string', u'string',
                                    MockUnit('php_missing_named_format'), 0,
                                    True))

    def test_wrong_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'%c string',
                                    MockUnit('php_wrong_format'), 0, False))

    def test_double_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'%s%s string',
                                    MockUnit('php_double_format'), 0, False))

    def test_reorder_format(self):
        self.assertFalse(
            self.check.check_format(u'%1$s %2$s string', u'%2$s %1$s string',
                                    MockUnit('php_reorder_format'), 0, False))

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%1$s string', u'%s string',
                                    MockUnit('php_wrong_named_format'), 0,
                                    False))

    def test_wrong_percent_format(self):
        self.assertTrue(
            self.check.check_format(u'%s%% (0.1%%)', u'%s%% (0.1%)',
                                    MockUnit('php_wrong_percent_format'), 0,
                                    False))

    def test_missing_percent_format(self):
        self.assertFalse(
            self.check.check_format(u'%s%% %%', u'%s%% percent',
                                    MockUnit('php_missing_percent_format'), 0,
                                    False))
Beispiel #6
0
class PHPFormatCheckTest(TestCase):
    def setUp(self):
        self.check = PHPFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            Unit('php_no_format'),
            0,
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            u'%s string',
            u'%s string',
            Unit('php_format'),
            0,
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%1$s string',
            u'%1$s string',
            Unit('php_named_format'),
            0,
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'string',
            Unit('php_missing_format'),
            0,
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%1$s string',
            u'string',
            Unit('php_missing_named_format'),
            0,
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            u'%1$s string',
            u'string',
            Unit('php_missing_named_format'),
            0,
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%c string',
            Unit('php_wrong_format'),
            0,
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%1$s string',
            u'%s string',
            Unit('php_wrong_named_format'),
            0,
            False
        ))