While the development of mongodb_session the following line was in the session test:

    $this->assertTrue(db_query('SELECT sid FROM {sessions} WHERE sid = :sid AND ssid = :ssid', $args)->fetchField(), 'Session has both SIDs');

So it would be cool if this sql specific part could be moved out into a extra function and then mongodb session tests could extend the test class much easier.

Comments

dawehner’s picture

StatusFileSize
new1.73 KB

Here is the patch

dawehner’s picture

StatusFileSize
new2.65 KB

Next version.

dawehner’s picture

StatusFileSize
new2.65 KB

changed sid to ssid, to make it clear that the ssid is used here

Status: Needs review » Needs work

The last submitted patch failed testing.

Status: Needs work » Needs review

Re-test of 663814-bothSid.patch from comment was requested by chx.

dww’s picture

StatusFileSize
new2.85 KB

In IRC DamZ pointed out that a test class function name starting with "test" implies it's actually a test. ;) In this case, we're just checking something. We briefly discussed two options:

A) Name this function checkBothSid().

B) Name it assertBothSid() and move the actual assertion inside.

Here's a patch for (B). All session tests pass locally with this.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Yay nice.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Two things:

1. The new assertion needs PHPDoc.
2. assertBothSids() assumes an awful lot of familiarity with how the session system works. Let's make that more obvious. On IRC we decided on assertSessionIdsEquals().

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new3.32 KB

Fixes both concerns in #8. All session tests pass locally. This is IMHO RTBC again, but it's my patch so I can't actually say that. ;)

dww’s picture

StatusFileSize
new3.3 KB

Now that webchick reads the PHPDoc, she agrees with what I proposed in IRC in the first place: assertSessionIds(). We're not testing if two session IDs are equal. We're testing if there's a session with both sids...

webchick’s picture

Status: Needs review » Fixed

Awesome, thanks. Committed to HEAD!

Status: Fixed » Closed (fixed)

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