Difference between revisions of "Testing"

From Freephile Wiki
Jump to navigation Jump to search
Line 2: Line 2:
  
 
Software development is writing code. Testing makes sure the code actually works, so in a nutshell: '''Testing is software development''' :-)
 
Software development is writing code. Testing makes sure the code actually works, so in a nutshell: '''Testing is software development''' :-)
== Phan ==
+
==Phan==
 
see [[Phan]]
 
see [[Phan]]
  
Line 11: Line 11:
  
 
PHPStan seems more polished (perhaps because it's commercial and has a 'pro' version that adds a GUI) whereas phan is the original PHP static analysis tool Rasmus Ledorf uses.
 
PHPStan seems more polished (perhaps because it's commercial and has a 'pro' version that adds a GUI) whereas phan is the original PHP static analysis tool Rasmus Ledorf uses.
 +
 +
PHPStan has some very notable projects that integrate it: Symphony, Doctrine, Monolog, and many more. Once again, there are PHPStan integrations for Drupal and Wordpress, but not MediaWiki.
  
 
Adding a configuration file for your MediaWiki extension is straightforward and would look like this:<syntaxhighlight lang="yaml">
 
Adding a configuration file for your MediaWiki extension is straightforward and would look like this:<syntaxhighlight lang="yaml">
Line 25: Line 27:
  
  
The [https://phpstan.org/user-guide/rule-levels level can be 0 - 9]
+
The [https://phpstan.org/user-guide/rule-levels '''level''' can be 0 - 9] and are "intuitive" with zero being the lowest "lax" level, and 9 being the highest level of strictness. This is the opposite of Phan levels where zero is the highest level of strictness.
  
The paths are the directories of '''your code.'''
+
The '''paths''' are the directories of '''your code.'''
  
The scanDirectories are additional paths used to discover symbols, but not analyze for errors.
+
The '''scanDirectories''' are additional paths used to discover symbols, but not analyze for errors.
  
 
For more advanced usage, see [https://github.com/ProfessionalWiki/Maps/blob/ee88211fadb3573b646cce005383450e96c3054e/phpstan.neon the example of Professional Wiki's Maps extension] which illustrates configuration file includes of a 'baseline'; error message suppression; and directory exclusions of problem code.
 
For more advanced usage, see [https://github.com/ProfessionalWiki/Maps/blob/ee88211fadb3573b646cce005383450e96c3054e/phpstan.neon the example of Professional Wiki's Maps extension] which illustrates configuration file includes of a 'baseline'; error message suppression; and directory exclusions of problem code.

Revision as of 23:17, 18 February 2024

Testing is software development.

Software development is writing code. Testing makes sure the code actually works, so in a nutshell: Testing is software development :-)

Phan[edit | edit source]

see Phan

Other Static Analysis tools for PHP[edit | edit source]

PHPStan[edit | edit source]

https://phpstan.org/

PHPStan seems more polished (perhaps because it's commercial and has a 'pro' version that adds a GUI) whereas phan is the original PHP static analysis tool Rasmus Ledorf uses.

PHPStan has some very notable projects that integrate it: Symphony, Doctrine, Monolog, and many more. Once again, there are PHPStan integrations for Drupal and Wordpress, but not MediaWiki.

Adding a configuration file for your MediaWiki extension is straightforward and would look like this:

parameters:
	level: 1
	paths:
		- src
		- tests
	scanDirectories:
		- ../../includes
		- ../../tests/phpunit
		- ../../vendor


The level can be 0 - 9 and are "intuitive" with zero being the lowest "lax" level, and 9 being the highest level of strictness. This is the opposite of Phan levels where zero is the highest level of strictness.

The paths are the directories of your code.

The scanDirectories are additional paths used to discover symbols, but not analyze for errors.

For more advanced usage, see the example of Professional Wiki's Maps extension which illustrates configuration file includes of a 'baseline'; error message suppression; and directory exclusions of problem code.

Psalm[edit | edit source]

https://psalm.dev/