Example #1
0
    def test_summary_with_absolute_path(self):
        # One posix + one windows path to normalize
        self.summary.write("""
FILE: %s/module/file1.php
-------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
-------------------------------------------------------------------------------
 1 | ERROR | You must use "/**" style comments for a file comment
-------------------------------------------------------------------------------

FILE: %s\\module\\file2.php
-------------------------------------------------------------------------------
FOUND 1 WARNING(S) AFFECTING 1 LINE(S)
-------------------------------------------------------------------------------
 15 | WARNING | Line exceeds 85 characters; contains 118 characters
-------------------------------------------------------------------------------

""" % (self.ctxt.basedir, self.ctxt.basedir))
        self.summary.close()
        phptools.phpcs(self.ctxt, file_=self.summary.name)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('lint', category)
        self.assertEqual(2, len(xml.children))
        child = xml.children[0]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file1.php', child.attr['file'])
        child = xml.children[1]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file2.php', child.attr['file'])
Example #2
0
 def test_empty_summary(self):
     self.summary.close()
     phptools.phpcs(self.ctxt, file_=self.summary.name)
     type, category, generator, xml = self.ctxt.output.pop()
     self.assertEqual(Recipe.REPORT, type)
     self.assertEqual('lint', category)
     self.assertEqual(0, len(xml.children))
Example #3
0
    def test_summary_with_absolute_path(self):
        # One posix + one windows path to normalize
        self.summary.write("""
FILE: %s/module/file1.php
-------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
-------------------------------------------------------------------------------
 1 | ERROR | You must use "/**" style comments for a file comment
-------------------------------------------------------------------------------

FILE: %s\\module\\file2.php
-------------------------------------------------------------------------------
FOUND 1 WARNING(S) AFFECTING 1 LINE(S)
-------------------------------------------------------------------------------
 15 | WARNING | Line exceeds 85 characters; contains 118 characters
-------------------------------------------------------------------------------

""" % (self.ctxt.basedir, self.ctxt.basedir))
        self.summary.close()
        phptools.phpcs(self.ctxt, file_=self.summary.name)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('lint', category)
        self.assertEqual(2, len(xml.children))
        child = xml.children[0]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file1.php', child.attr['file'])
        child = xml.children[1]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file2.php', child.attr['file'])
Example #4
0
 def test_empty_summary(self):
     self.summary.close()
     phptools.phpcs(self.ctxt, file_=self.summary.name)
     type, category, generator, xml = self.ctxt.output.pop()
     self.assertEqual(Recipe.REPORT, type)
     self.assertEqual('lint', category)
     self.assertEqual(0, len(xml.children))
Example #5
0
    def test_summary_format(self):
        # thoroughly check on report line
        self.summary.write("""
FILE: %s/module/file1.php
-------------------------------------------------------------------------------
FOUND 1 ERROR(S) AND 1 WARNING(S) AFFECTING 2 LINE(S)
-------------------------------------------------------------------------------
  1 | ERROR   | You must use "/**" style comments for a file comment
 15 | WARNING | Line exceeds 85 characters; contains 118 characters
-------------------------------------------------------------------------------

""" % (self.ctxt.basedir, ))
        self.summary.close()
        phptools.phpcs(self.ctxt, file_=self.summary.name)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('lint', category)
        self.assertEqual(2, len(xml.children))

        child = xml.children[0]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file1.php', child.attr['file'])
        self.assertEqual('error', child.attr['category'])
        self.assertEqual(1, child.attr['line'])
        self.assertEqual(1, len(child.children))
        msg = child.children[0]
        self.assertEqual('msg', msg.name)
        self.assertEqual(1, len(msg.children))
        self.assertEqual(
            'You must use "/**" style comments for a '
            'file comment', msg.children[0])

        child = xml.children[1]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file1.php', child.attr['file'])
        self.assertEqual('warning', child.attr['category'])
        self.assertEqual(15, child.attr["line"])
        self.assertEqual(1, len(child.children))
        msg = child.children[0]
        self.assertEqual('msg', msg.name)
        self.assertEqual(1, len(msg.children))
        self.assertEqual('Line exceeds 85 characters; contains 118 characters',
                         msg.children[0])
Example #6
0
    def test_summary_format(self):
        # thoroughly check on report line
        self.summary.write("""
FILE: %s/module/file1.php
-------------------------------------------------------------------------------
FOUND 1 ERROR(S) AND 1 WARNING(S) AFFECTING 2 LINE(S)
-------------------------------------------------------------------------------
  1 | ERROR   | You must use "/**" style comments for a file comment
 15 | WARNING | Line exceeds 85 characters; contains 118 characters
-------------------------------------------------------------------------------

""" % (self.ctxt.basedir,))
        self.summary.close()
        phptools.phpcs(self.ctxt, file_=self.summary.name)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('lint', category)
        self.assertEqual(2, len(xml.children))
        
        child = xml.children[0]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file1.php', child.attr['file'])
        self.assertEqual('error', child.attr['category'])
        self.assertEqual(1, child.attr['line'])
        self.assertEqual(1, len(child.children))
        msg = child.children[0]
        self.assertEqual('msg', msg.name)
        self.assertEqual(1, len(msg.children))
        self.assertEqual('You must use "/**" style comments for a '
                         'file comment', msg.children[0])
        
        child = xml.children[1]
        self.assertEqual('problem', child.name)
        self.assertEqual('module/file1.php', child.attr['file'])
        self.assertEqual('warning', child.attr['category'])
        self.assertEqual(15, child.attr["line"])
        self.assertEqual(1, len(child.children))
        msg = child.children[0]
        self.assertEqual('msg', msg.name)
        self.assertEqual(1, len(msg.children))
        self.assertEqual('Line exceeds 85 characters; contains 118 characters'
                         , msg.children[0])