Skip to content

Improve consistency of tests used on L1s.#71

Merged
davidstrauss merged 12 commits intomasterfrom
L1-test-parity
Dec 6, 2016
Merged

Improve consistency of tests used on L1s.#71
davidstrauss merged 12 commits intomasterfrom
L1-test-parity

Conversation

@stevector
Copy link
Copy Markdown
Contributor

@stevector stevector commented Dec 5, 2016

Overview

This pull request:

  • Fixes inconsistent behavior between L1s.
  • Adds tests.

Summary

This PR is the first step in #70 and is a precursor to a test refactoring in #72

Description

The test suite currently uses a convention of helper methods (performL1HitMissTest(), performL1AntirollbackTest() etc) along with test* methods per implementation (testStaticL1Antirollback(), testSQLiteL1Antirollback()). I would like to switch to using inheritance or traits to share these tests among implementations (#72). Before considering that pull request, I'd like to first validate that all of these tests are appropriate to run on all L1s (with the exception of NullL1).

This pull request also makes a change to resolve inconsistent handling of hit/miss counting between the L1 implementations. Right now only the APCuL1 resets its hit/miss count as a result of a cache clear. This PR makes it so that StaticL1 and SQLiteL1 also reset their counts as the result of a cache clear.

The PR also fixes a bug in APCuL1::setWithExpiration() where the $created variable was not used.

Todo

  • Validate with David that the added tests are appropriate to run on all L1s.
  • Determine why testEmptyCleanUpDatabaseL2() makes no assertions. (I suppose this is not a hard blocker but I'd like to get this answered before refactoring tests further)

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 5, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 35736ea on L1-test-parity into 7adddaa on master.

composer.json Outdated
"autoload":{
"psr-4":{
"LCache\\": "src"
"LCache\\": ["src/", "tests/"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to go in autoload, or could you put it in autoload-dev? I prefer to put autoloaded classes used by the tests in tests/src, to differentiate them from files that are loaded by phpunit because they are test files. See the existing entry in autoload-dev. No one is using the LCache\TestUtils namespace; I just put it in as an example. This could just be LCache. You could make the directory tests instead of tests/src too. But I'd recommend keeping it out of autoload.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @greg-1-anderson! You're right and I'll update this file.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 5, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling da2f5c3 on L1-test-parity into 7adddaa on master.


public function testEmptyCleanUpDatabaseL2()
{
// Why does this test make no assertions?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's testing that destructors run properly (without errors/exceptions) with an empty data set. Because all other tests write data, they don't trigger the destuctor in an empty state.

@davidstrauss davidstrauss added this to the v1.0.0 milestone Dec 6, 2016
@stevector
Copy link
Copy Markdown
Contributor Author

I just had a verbal conversation with Greg and David. They consider this PR ready to merge and would like #72 broken apart so that L1s and L2s can be addressed in separate PRs.

@davidstrauss Can you now "Squash and merge" this PR? I don't know why Coveralls hasn't reported back. The most recent commit was just a comment removal.

@davidstrauss davidstrauss merged commit 85ca4fd into master Dec 6, 2016
@davidstrauss davidstrauss deleted the L1-test-parity branch December 6, 2016 23:46
@coveralls
Copy link
Copy Markdown

coveralls commented Dec 6, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling f440416 on L1-test-parity into 7adddaa on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants