Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Analyzer / Tests.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
4
5 use Drupal\drupalmoduleupgrader\AnalyzerBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
7
8 /**
9  * @Analyzer(
10  *  id = "tests",
11  *  description = @Translation("Checks for test classes that need to be rejiggered for Drupal 8."),
12  *  documentation = {
13  *    {
14  *      "url" = "https://www.drupal.org/node/1543796",
15  *      "title" = @Translation("Namespacing of automated tests has changed")
16  *    },
17  *    {
18  *      "url" = "https://www.drupal.org/node/2301125",
19  *      "title" = @Translation("<code>getInfo()</code> in test classes replaced by doc comments")
20  *    },
21  *    {
22  *      "url" = "https://www.drupal.org/node/1710766",
23  *      "title" = @Translation("Test classes should define a <code>$modules</code> property declaring dependencies")
24  *    },
25  *    {
26  *      "url" = "https://www.drupal.org/node/1911318",
27  *      "title" = @Translation("SimpleTest tests now use empty &quot;testing&quot; profile by default")
28  *    },
29  *    {
30  *      "url" = "https://www.drupal.org/node/1829160",
31  *      "title" = @Translation("New <code>KernelTestBase</code> class for API-level integration tests")
32  *    },
33  *    {
34  *      "url" = "https://www.drupal.org/node/2012184",
35  *      "title" = @Translation("PHPUnit added to Drupal core")
36  *    }
37  *  },
38  *  tags = {
39  *    "category" = { "misc", "system" }
40  *  },
41  *  message = @Translation("Automated web tests must be in a PSR-4 namespace, and unit tests must be converted to PHPUnit.")
42  * )
43  */
44 class Tests extends AnalyzerBase {
45
46   /**
47    * {@inheritdoc}
48    */
49   public function analyze(TargetInterface $target) {
50     $issues = [];
51     $total = 0;
52     $total += $target->getIndexer('class')->getQuery()->condition('parent', 'DrupalWebTestCase')->countQuery()->execute();
53     $total += $target->getIndexer('class')->getQuery()->condition('parent', 'DrupalUnitTestCase')->countQuery()->execute();
54     $total += $target->getIndexer('class')->getQuery()->condition('parent', 'DrupalTestBase')->countQuery()->execute();
55
56     if ($total) {
57       $issues[] = $this->buildIssue($target);
58     }
59
60     return $issues;
61   }
62
63 }