Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294723

[Meta] Convert UnitTestBase to PHPUnit

$
0
0

Problem/Motivation

As #1567500: [meta] Replace the testing framework with PHPUnit and possibly rewrite Simpletest is underway we need to convert all Simpletest based unittest to PhpUnit tests.

Proposed resolution

Let's create patches for each directory from the list.

Make sure you use

git diff -M 8.x
to make the file move explicit which reduces the patch size and thus the reviewers tasks.

Remaining tasks

Documentation for PHPUnit's mocks and stubs: http://phpunit.de/manual/current/en/test-doubles.html

As an example for modules see breakpoint module core/modules/breakpoint/tests/Drupal/breakpoint/Tests/
For Core or Component we already have several tests core/tests/Drupal/Tests/Core|Component.

  • If a test is in the system module, and it tests a class not in system module, then it should be moved to core/tests/Drupal/Tests/ directory
  • If a class contains Unit in its name, remove it when converting to PHPUnit..there is no point keeping it.
  • If a class can be converted to use dataproviders it should

As mentioned in #1938068-11: [Meta] Convert UnitTestBase to PHPUnit

Open Issues

core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingDependentModuleUnitTest.php cannot be converted to phpunit since it actually tests Simpletest itself (which requires Drupal bootstrap, etc). Not sure if it deserves a separate issue, or if it should just be removed from this issue summary.

Fill in the documentation void of http://drupal.org/node/1814344 Agile Unit Testing section 'Unit Test Organization'

TODO

#1996868: Start converting image.inc to an Image component
#1938130: Convert User tests to PHPUnit
#2003800: Move drupal_check_memory_limit() and parse_size() functionality to components
#2008566: Convert PasswordHashingTest unit tests to phpunit
#2035133: Convert system module's Mail unit test to phpunit
#2042739: Convert system module's ControllerResolverTest to phpunit
#2051467: Expand and convert to phpunit tests for \Drupal\Component\Transliteration
#2130551: Convert system modules MimeTypeMatcherTest to phpunit
(And then 44 more tests from system module.)

In core / lib / Drupal / Component

Component might be a good place to aim for 100% coverage.
Really though we want to make issues to remove procedural code from classes,
and declare the dependencies (dependency injection), and then add phpunit tests in the issue to "Declare dependecies in *classWhatever*".
Fill in issue numbers if related to getting those tests in, or issue numbers for new issues created to convert tests or improve coverage. Let's try and do one issue per class.

In core / lib / Drupal / Core / Batch

Batch has 3 classes, but 2 are not in phpunit coverage output since code is not autoloaded as part of tests.

Done

#2003762: Convert system module's Uuid unit tests to phpunit
#1938184: Convert Drupal\Core\Utility\Color\ColorTest to PHPUnit
#1991078: Convert MachineNameControllerTest to PHPUnit
#1901670: Start using PHPUnit for unit tests
#1935970: Convert timer_* to a utility class and convert tests to phpunit
#1957302: Convert PathProcessorTest to PHPUnit
#2001218: Convert core/modules/views/lib/Drupal/views/Tests/PluginTypeListTest.php to phpunit
#2003342: Convert system module's database unit tests to phpunit
#2002190: Convert core/modules/search/lib/Drupal/search/Tests/SearchExpressionTest.php to phpunit
#2003568: Convert tags,attributes, diff and url validation unit tests to phpunit
#2006568: Convert filter_xss tests to unit tests
#2016299: Convert system module's JsonUnitTest to phpunit
#2042745: Convert system module's RouteTest to phpunit
#2002116: Convert core/modules/update/lib/Drupal/update/Tests/UpdateCoreUnitTest.php to phpunit
#2030173: Convert system module's ValidNumberStepUnitTest to phpunit

API changes

The UnitTest files are moved to ... tbd
====
See coder #1938066: Prepare for phpunit tests

Related issues


Viewing all articles
Browse latest Browse all 294723

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>