Moved over from #1224838-14: Fix the inconsistency between filenames as array keys and array values.
We can do better than what we currently have.

Files: 
CommentFileSizeAuthor
#14 1299076-14-libraries-better-tests.patch3 KBtstoeckler
PASSED: [[SimpleTest]]: [MySQL] 128 pass(es).
[ View ]
#11 1299076-11-libraries-better-tests.patch3 KBtstoeckler
PASSED: [[SimpleTest]]: [MySQL] 128 pass(es).
[ View ]
#9 1299076-9-libraries-better-tests.patch2.99 KBtstoeckler
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/libraries/tests/libraries.test.
[ View ]
#7 1299076-7-libraries-better-tests.patch2.93 KBtstoeckler
PASSED: [[SimpleTest]]: [MySQL] 128 pass(es).
[ View ]
#5 1224838-libraries-better-tests-2-debug.patch3.04 KBtstoeckler
FAILED: [[SimpleTest]]: [MySQL] 116 pass(es), 12 fail(s), and 0 exception(es).
[ View ]
1224838-libraries-better-tests-2.patch3 KBtstoeckler
FAILED: [[SimpleTest]]: [MySQL] 114 pass(es), 12 fail(s), and 0 exception(es).
[ View ]

Comments

tstoeckler’s picture

Status:Active» Needs review

Status:Needs review» Needs work

The last submitted patch, 1224838-libraries-better-tests-2.patch, failed testing.

tstoeckler’s picture

I don't get what I'm doing wrong. I get all greens with this one...

sun’s picture

You should be able to see "live" values on the testbot by squeezing in debug() lines.

btw, let's also rename $found to $expected.

tstoeckler’s picture

Status:Needs work» Needs review
StatusFileSize
new3.04 KB
FAILED: [[SimpleTest]]: [MySQL] 116 pass(es), 12 fail(s), and 0 exception(es).
[ View ]

Thanks for the tip, I wasn't aware of that!
Let's try this one.

Status:Needs review» Needs work

The last submitted patch, 1224838-libraries-better-tests-2-debug.patch, failed testing.

tstoeckler’s picture

Status:Needs work» Needs review
StatusFileSize
new2.93 KB
PASSED: [[SimpleTest]]: [MySQL] 128 pass(es).
[ View ]

Damn you, unclean URLs!!!
Either way, this revealed a little bit of cruft which can be removed. Let's see if this one works.

sun’s picture

Status:Needs review» Needs work
+++ b/tests/libraries.test
@@ -410,24 +410,40 @@ class LibrariesTestCase extends DrupalWebTestCase {
+        $message = ($expected ? "$name.$extension found." : "$name.$extension not found.");
...
+        ($expected ? $this->assertRaw($raw, $message) : $this->assertNoRaw($raw, $message));

Especially the latter line is a coding style not used in Drupal. Looks like a simple if/else control structure would be more appropriate here.

tstoeckler’s picture

Status:Needs work» Needs review
StatusFileSize
new2.99 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/libraries/tests/libraries.test.
[ View ]

How about this one?

Status:Needs review» Needs work

The last submitted patch, 1299076-9-libraries-better-tests.patch, failed testing.

tstoeckler’s picture

Status:Needs work» Needs review
StatusFileSize
new3 KB
PASSED: [[SimpleTest]]: [MySQL] 128 pass(es).
[ View ]

How on earth did that pass locally?!!?!?
Let's try this one.

sun’s picture

Status:Needs review» Needs work
+++ b/tests/libraries.test
@@ -410,24 +410,44 @@ class LibrariesTestCase extends DrupalWebTestCase {
+    foreach ($names as $name => $expected) {
       foreach ($extensions as $extension) {
...
+        $label = ($label !== '' ? "$label: " : '');

We either need a different assignment variable here or we need to move that label munging simply out of the foreachs.

tstoeckler’s picture

Sorry, I thought I had checked the messages, but evidently I didn't:

Version overloading: example_1.js found.
Version overloading: : example_1.css found.
Version overloading: : : example_1.php found.
Version overloading: : : : example_2.js found.
Version overloading: : : : : example_2.css found.
Version overloading: : : : : : example_2.php found.
Version overloading: : : : : : : example_3.js found.
Version overloading: : : : : : : : example_3.css found.
Version overloading: : : : : : : : : example_3.php found.
Version overloading: : : : : : : : : : example_4.js found.
Version overloading: : : : : : : : : : : example_4.css found.
Version overloading: : : : : : : : : : : : example_4.php found.

Will reroll with $label moved out of the foreach.

tstoeckler’s picture

Status:Needs work» Needs review
StatusFileSize
new3 KB
PASSED: [[SimpleTest]]: [MySQL] 128 pass(es).
[ View ]

There we go.

tstoeckler’s picture

Status:Needs review» Fixed

Gave this another look, and decided to commit this.
http://drupal.org/commitlog/commit/10030/abd2625f62f346613c7aedd74ad067e...

We already introduced one regression because of our poor current tests. This works and is definitely an improvement of the status quo. We can always refine in follow-ups. And at some point we're going to have to overhaul our test case anyway...

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.