Phpunit: Will PHPUnit 5 use namespace?

Created on 3 Oct 2015  Â·  16Comments  Â·  Source: sebastianbergmann/phpunit

So will I see PHPUnit/Framework/TestCase, or still the old PHPUnit_Framework_Testcase?

All 16 comments

No.

Thats disappointing.

@HallofFamer there are thousands of projects in this world using phpunit. The migration from the old-school underscore namespaces to native php5.3 namespaces would be such a pain.

class PHPUnit_Framework_TestCase {
  // (empty)
}
namespace PHPUnit\Framework;

class TestCase extends \PHPUnit_Framework_TestCase {
  // (everything here)
}
  1. would send the right signals.
  2. would grant everyone the time of an entire major release to _adapt_ (until PHPUnit 6).
  3. would surely be a very promising start.

:+1:

Thanks!
sun

@sun the other way around: PHPUnit_Framework_TestCase must contain all code while PHPUnit\Framework\TestCase only extends \PHPUnit_Framework_TestCase and is empty.

@klausi:
Its not that simple, PHPUnit_Framework_TestCase is just one of the many classes that uses the old fashioned underscore separator notation. If you look into the /src/framework directory, you see all the classes are named in this way. Its a pity really, I feel that a leading application like PHPUnit should send the right signals to developers, all projects from now on should use namespace.

@Ma27:
I understand the case for backward compatibility, but the older softwares are more likely hosted on servers with outdated PHP versions(aka 5.3 or even 5.2), so they aint likely to use the new version of PHPUnit anyway now that it requires PHP 5.6+. I really like @sun's proposal, it offers workaround for both developers who plan to move on with advanced PHP features, and those who stay back, at least for the lifetime of PHPUnit 5.

no, you did'nt understand me. Every project would have to update these namespaces. When using some phpunit tools such as selenium, it will be much more work.
And frameworks using this new phpunit version and providing testcase classes (e.g. the KernelTestCase of symfony2) would have to publish a new major version as switching the phpunit base class would be a big BC break.

Am 07.10.2015 um 13:39 schrieb HallofFamer [email protected]:

@klausi:

Its not that simple, PHPUnit_Framework_TestCase is just one of the many classes that uses the old fashioned underscore separator notation. If you look into the /src/framework directory, you see all the classes are named in this way. Its a pity really, I feel that a leading application like PHPUnit should send the right signals to developers, all projects from now on should use namespace.

@Ma27:
I understand the case for backward compatibility, but the older softwares are more likely hosted on servers with outdated PHP versions, so they aint likely to use the new version of PHPUnit anyway now that it requires PHP 5.6+.

—
Reply to this email directly or view it on GitHub.

FWIW, I would have given my :+1: for namespaces, but it's too late for PHPUnit 5 anyway.

I'd quite like to see namespaces in PHPUnit 6 tbh.

@Ma27
Nope, they dont have to, they can choose to use the older version. The same logic can be applied to anything else, you can remain on the old platform if you refuse to embrace new technology. I dont see how this is that difficult anyway, since modern IDEs allow you to change class name at one place and affect code in all files, its very convenient. Or PHPUnit can apply @sun 's idea, deprecate old naming convention first(PHPUnit 5) and remove later(PHPUnit 6), which will give developers sufficient time to make the shift.

Deprecations or not, it'll be a lot work. And staying on older versions is absolutly no solution. When releasing PHPUnit7 or 8 with a lot of new features then they'll drop phpunit 4 very soon as supporting such an old branch wouldn't make that much sense.
ANother problem would be merging between branches: Given PHPUnit6 has namespaces. When fixing bugs in that version, you'll run into thounsands of conflicts when trying to merge/rebase to the 4.x branch as much of the code is different there, so maintenance of multiple branches would be such a pain, too.

So you are saying that PHPUnit should just stay with the old and legacy PHP technology and standards forever, and never embrace things like namespace?

I think PHPUnit 6 is a perfect time to change to using namespace since it's dropping php 5, and the scalar typehint changes are already massively breaking anyway.

Would be great to have namespaces :)

we do now

Was this page helpful?
0 / 5 - 0 ratings