The Google Summer of Code 2017 (GSoC’ 17) coding period kicked off from last week, May 30. Each selected student had an one-month long community bonding period with their respective organisations. I had written my community bonding experience with Drupal in my previous blog post.
Most of the easy parts of my project like configuration system, yml, plugin skeletons etc was already written before I start writing the proposal. I was really thrilled to get into the coding rounds of GSoc’ 17. Then it was the time to use the real magic of open source i.e DOCUMENTATION. I started reading it and wrote unit test for each part that is already coded. Students going to take part in GSoC'18 may take it as a feedback/ advice. If you are choosing an already ported module, then after getting selected first write all the required tests and try to cover at least 60-80% of module within one and half weeks.
I really had lost my confidence in the first week if I could write a single line of code, due to lack of time. But thanks to my mentor Nick_vh, I discussed with him about the problem. He was really helpful in guiding me in the proper way by reviewing the code, where to start and sharing his valuable feedback.
Long story in short. Given below some of the resources which I followed to learn PHPUnit test and what I accomplished last week,
PHPUNIT configuration for Drupal 8
- You can manually provide some test cases or use some PHPUnit built in methods like dataprovider()
- More: Click here
4- How to replace the dependencies / Objects of another class while Unit testing ?
6- Some more details for D8 testing.
- Disable Constructor
- Essential Annotations to know : Annotations allow us to tell PHPUnit how certain things are meant to be used. They can include:
- @covers: specifies that a given test “covers” a segment of code @depends: indicates that a given test is dependent on another test. More @dataProvider: indicates a data provider method @expectedException: tells PHPUnit that a known exception should pass the test
As I said above I need to write lot of tests, so I will be writing kernel tests for search_api_location_views filter plugin in the next week as well as learning how to write a views plugin. Stay tuned for next blog post. Thank you.