The manual highlights some conventions:
MyClass go into a class MyClassTestMyClassTest live in file MyClassTest.phpMyClassTest inherits from PHPUnit_Framework_TestCasetest*This will result in something like this folder structure:
โโโ src/
โ โโโ classes/
โ โ โโโ MyClass.php # Different
โ โโโ ...
โโโ tests/
โ โโโ testcases/
โ โ โโโ MyClassTest.php # Different
โ โโโ bootstrap.php
โ โโโ ...
โโโ ...
... and this test case:
MyClassTest extends PHPUnit_Framework_TestCase {
testMyMethod() {
// Code here.
}
}
My question
I'm wondering why the naming used inside the test suite can't mirror the project's source code? For example, file names can match:
โโโ src/
โ โโโ classes/
โ โ โโโ MyClass.php # Same
โ โโโ ...
โโโ tests/
โ โโโ testcases/
โ โ โโโ MyClass.php # Same
โ โโโ bootstrap.php
โ โโโ ...
โโโ ...
And if using PHP > 5.3, namespaces can be used to allow class names to match:
namespace MyProject\MyTests;
MyClass extends PHPUnit_Framework_TestCase { # The class name MyClass matches the class name used in my project's source.
/**
* @test
*/
MyMethod() { The method name MyMethod matches the method name used in my project's source.
// Code here.
}
}
Note the @tests annotation is used so method names can match.
This is not a discussion / support forum, sorry.
:cry: