BlackBox icon indicating copy to clipboard operation
BlackBox copied to clipboard

Storage specifications

Open mnapoli opened this issue 10 years ago • 0 comments

As I adapted the implementation with the storage interface, I also tried to add more tests and specify a few edge cases.

This is just started, nothing very extensive for now. The way I did it is I wrote a BaseStorageTest class that PHPUnit tests can extend. This guarantees running the same tests for all storages.

Here is the result running phpunit --testdox:

 [x] it should store data as map
 [x] add should store data with autogenerated id
 [x] get non existent key should return null
 [x] set null should store null
 [x] remove should delete the entry
 [x] it should be traversable

So, questions:

  • get non existent key should return null?

    Should it throw an exception or return null?

  • set null should store null

    Previously it did remove the value, but now that we have remove($id) I guess being able to store null is great.

  • should remove non existent id throw an exception?

    I'd say, just like in REST, remove('unknown-id') shouldn't throw an exception. But I don't know, maybe it's better to throw… What do you think?

... more to come, suggestions welcome.

mnapoli avatar Feb 08 '15 02:02 mnapoli