Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Count modules unit tests #1303

Closed
wants to merge 6 commits into from

4 participants

@garyamort

Simple unit tests for CountModules added

@realityking
Collaborator

Great stuff!

A couple of things:
1. We don't accept failing tests. (I know we should but it's not possible in our current process)
2. Could you rebase to get rid of the merge conflicts?

Also your patch revealed one of the interesting things that happened with the legacy package. JDocumentHTML actually depends on JModuleHelper but the later is in legacy and thus not available in unit tests. I propose to move it back since it's really an integral part of the templating system we have. What do other think?

@garyamort

By failing tests do you mean the first 3?

@elinw

@realityking I agree about moving it back. I think in the end when JContent comes in we might want to change the name/rebrand/reconceptualize or something and maybe move it, but there has to be a way to place bits of content on pages and until there is something new for that, modules in positions is something we have. I just don't think it's a useful framework for building web applications unless you have some concept of a location of a page that you can assign stuff to display in. That doesn't mean developers are in any way limited to how the CMS conceives of them.

@garyamort

The JModuleHelper error is coming from something outside my patch? IE what do I need to do to get this patch to pass the checks?

@elinw

@garyamort
I think you need to make one big pull request with both the tests (passing) and the fix. Then when the pulltester runs it the tests will pass.

@realityking
Collaborator

I talked to Louis about this. Please add the test to the legacy test suite. That will work fine. You just have to move the file to a different folder for that.

@garyamort

Cool..thanks!

@realityking
Collaborator

Any news on this?

@realityking
Collaborator

@garyamort Could you fix this up as per my comment? Thanks.

@LouisLandry

I'm closing this in favor of #1307. Please add these tests into that pull request and we'll get them merged in all at once. Thanks a bunch for this!

@LouisLandry LouisLandry closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 151 additions and 2 deletions.
  1. +151 −2 tests/suites/unit/joomla/document/html/JDocumentHTMLTest.php
View
153 tests/suites/unit/joomla/document/html/JDocumentHTMLTest.php
@@ -135,16 +135,165 @@ public function testRender() {
);
}
+ /**
+ * These three tests cannot be enabled until the functionality has been added
+
+ public function testCountModulesNullString() {
+ // countModules parameter must be a string with an odd number of words
+ $this->assertThat(
+ $this->object->countModules(''),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules invalid number of parameters failed.'
+ );
+ }
+ public function testCountModulesNotTwo() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 or'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules invalid number of parameters failed.'
+ );
+ }
+ public function testCountModulesNotEven() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 or dummy2 or'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules invalid number of parameters failed.'
+ );
+ }
+ **/
+
+ public function testCountModulesOneParameter() {
+ //nonExistant conditions will be 0
+ $this->assertThat(
+ $this->object->countModules('dummy1'),
+ $this->equalTo(0),
+ 'JDocumentHTMLTest->countModules single empty position failed.'
+ );
+ }
+ public function testCountModulesAddition() {
+ // simple operator logic with 2 positions which are both nonexistant/0
+ $this->assertThat(
+ $this->object->countModules('dummy1 + dummy2'),
+ $this->equalTo(0),
+ 'JDocumentHTMLTest->countModules empty positions addition failed.'
+ );
+ }
+ public function testCountModulesSubtraction() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 - dummy2'),
+ $this->equalTo(0),
+ 'JDocumentHTMLTest->countModules empty positions subtraction failed.'
+ );
+ }
+ public function testCountModulesMultiplication() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 * dummy2'),
+ $this->equalTo(0),
+ 'JDocumentHTMLTest->countModules empty positions multiplication failed.'
+ );
+ }
+ public function testCountModulesEquals() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 == dummy2'),
+ $this->equalTo(true),
+ 'JDocumentHTMLTest->countModules empty positions equal comparison failed.'
+ );
+ }
+ public function testCountModulesNotEquals() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 != dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions not equal comparison failed.'
+ );
+ }
+ public function testCountModulesUnequal() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 <> dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions not equal comparison failed.'
+ );
+ }
+ public function testCountModulesLessThen() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 < dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions less then comparison failed.'
+ );
+ }
+ public function testCountModulesGreaterThen() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 > dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions greater then comparison failed.'
+ );
+
+ }
+ public function testCountModulesLessThenOrEqual() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 <= dummy2'),
+ $this->equalTo(true),
+ 'JDocumentHTMLTest->countModules empty positions less then or equal to comparison failed.'
+ );
+ }
+ public function testCountModulesGreaterThenOrEqual() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 >= dummy2'),
+ $this->equalTo(true),
+ 'JDocumentHTMLTest->countModules empty positions greater then or equal to comparison failed.'
+ );
+ }
+ public function testCountModulesLogicalAnd() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 and dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions and comparison failed.'
+ );
+ }
+ public function testCountModulesLogicalOr() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 or dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions or comparison failed.'
+ );
+ }
+ public function testCountModulesLogicalXor() {
+ $this->assertThat(
+ $this->object->countModules('dummy1 xor dummy2'),
+ $this->equalTo(false),
+ 'JDocumentHTMLTest->countModules empty positions xor comparison failed.'
+ );
+ }
+
+ /**
+ * countModules divide by zero special case test
+ */
+ public function testCountModulesDivideByZeroWarning()
+ {
+ try {
+ $this->object->countModules('dummy1 / dummy2');
+ }
+ catch (PHPUnit_Framework_Error_Warning $divideByZeroWarning) {
+ return;
+ }
+ $this->fail('An divide by zeror error was expected but has not been raised.');
+ }
+
/**
- * @todo Implement testCountModules().
+ * @todo finish implementing testCountModules().
*/
public function testCountModules() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'these tests have not been completed.'
);
}
+ //todo: create module positions in order to do simple tests with actual numbers
+
+ //todo: add complex condition tests
+
+ //todo: add invalid operator tests
+
/**
* @todo Implement testCountMenuChildren().
*/
Something went wrong with that request. Please try again.