Example #1
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))
Example #2
0
 def setUp(self):
     self.check = PHPFormatCheck()
Example #3
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
        ))
Example #4
0
 def setUp(self):
     self.check = PHPFormatCheck()
Example #5
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
        ))