Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

CamelCase in unit testing #301

Closed
joelcox opened this Issue · 8 comments

6 participants

@joelcox

I've been going through the unit testing code and noticed the use of CamelCase throughout the code. Most notably in the CI_TestCase class name. I'm aware that PHPUnit is written in CamelCase, but I think we should try to adhere to the CodeIgniter style guide as much as possible.

Instead of writing a wrapper for every assertion/method, a the magic __call() method could be used to route underscore_case method names to the original PHPUnit method. This would break compatibility with the existing PHPUnit documentation though.

@kylefarris

I actually kinda agree.

@adamgriffiths

Very good point. I see a few comments on pull requests asking for the tiniest thing to be done to adhere to the CI standards (and rightly so) so it's only right that this be within the standards too.

@ktomk

This would break compatibility with the existing PHPUnit documentation though.

Not only that, it will prevent to actually go into PHPUnit source within the IDE because the magical __call() façade prevents IDEs to resolve the actual code statically.

Two questions:

  • Would you expect that CI coding-style applies to PHPUnit?
  • Is formality a higher good than usability?

Coding standards are reasonable to make the overall code readable, they help to write better code in a team. But if you start to apply them to third-party code then you might have not understood for what they are for.

My 2 cents.

@kenjis

I'm also afraid of incompatibility with 3rd party tools when CI makes its version (Non CamelCase or something) of PHPUnit.

@joelcox

@ktomk Thanks for your perspective on this. I don't use autocompletion myself so I overlooked that problem. Good point. To answer your questions:

  • I wouldn't expect that the CI style guidelines apply to PHPUnit. Personally I would prefer that the public methods match the CI style guide though.
  • Formality enforces usability. When I'm working with a framework that has a certain way of doing things, I expect it to adhere to those guidelines.

I understand the reasons for these guidelines. The tricky part is when you integrate third-party code in your code. Are you going to build a wrapper around this third-party code or stick with the original code? That's the only reason I opened this issue and stated my personal preference.

@joelcox

@kenjis I agree that the original methods should still be usable.

@ktomk

@joelcox: It's not only auto-completion (which wouldn't be affected by __call()), but navigating into a function definition (just as a side-note).

@philsturgeon

The test code sits outside of system and application, and is just a tool used by the team to make sure that CodeIgniter is built properly.

We wouldn't try to recode your favourite IDE to make sure it follows the CI style guide, and we wouldn't worry what the Python documentation generator tools uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.