UPDATE (2012-09-22): Sadly GitHub Pages don’t allow to use Jekyll Plugins. Since Gists are embedded via the HTML
That isn’t fully satisfying, but at least the user can now see that their exists more content that can’t be displayed in the client application.
Traits cannot be instantiated in PHP. Until this day, I always created a stub class to test a trait.
- The stub class that is instantiated in the PHPUnit test class.
- The PHPUnit test class that instantiates the stub class.
With the release of PHPUnit 3.7 yesterday, I also came across this blogpost from the author of PHPUnit, Sebastian Bergmann. That post describes how-to test traits properly with the method
. This doesn’t seem to be mentioned in the official PHPUnit manual, yet.
Following that instructions, the above code has been refactored to the following (proper) solution:
- Replaced the instantiation of the stub class
with the method
- Replaced the method annotation
with the new annotation
from PHP_CodeCoverage 1.2.0. The class annotation
is used to define the fully-qualified class name once.
- Created the Creation Method
, to encapsulate the creation of an object for a trait.
And to finish this post, some offtopic information: I’m using gist-it.appspot.com from now on, to embed code from GitHub repositories into my webpages. gist-it.appspot.com turns any file of a GitHub repository into a “pseudo-Gist”, and makes it look similar to Gist.