On some glibc implementations strncmp is a macro. This commit simply creates a
`redis_strncmp` static inline wrapper function so we can `ZEND_STRL` instead of
manually counting the length or using `sizeof(s)-1` each time.
Fixes#2565
PHP switched from `ZEND_ASSUME` to `ZEND_ASSERT` when making sure
`Z_PTR_P(zv)` was nonnull in `zend_hash_str_update_ptr`.
This commit just switches to `zend_hash_str_add_empty_element` which
is semantically more correct anyway.
Fixes#2539
Redis requires the user to send a count if `WITHVALUES` is specified,
otherwise it sees the `WITHVALUES` argument as the count and will error
out that it's not a number.
We can also return false if the key doesn't exist.
* Remove/update mentions of removed methods
These methods were deprecated in a previous release
* Correct documentation for zInter/zinterstore
* Correct documentation for zUnion/zunionstore
* Add documentation for zDiff/zdiffstore
* Add documentation for zMscore
* Adds `GETEX` to the README.md documentation.
* Allow the user to send `PERSIST` either as an array key or just in the
array, to conform with similar methods.
* Implement getEx for `RedisCluster`
Fixes#2512
* More unit test utility functions/usage.
* Add `assertKeyEquals` and `assertKeyEqualsWeak` as we test key values
hundreds of places in `RedisTest.php`
* We are almost always using `$this->redis` when we want to run an
assertion that needs access to the client, so make this argument
optional and default to `$this->redis`.
* Update a few more assertions to use our new methods.
* Various minor fixes/tweaks.
* Update RedisTest.php
typo
This probably isn't a very common scenerio since we've never had someone
ask it in a decade, but it was very simple to get them working.
Primarily we just needed to test for `STDTOUT`/`STDERR` and use
`__DIR__` instead of `$_SERVER['PHP_SELF']`.
Fixes#2507
There is a very strange edge case whn you try to run PHP under valgrind
and use certain specific strings like "$k1".
PHP interns these values in such a way that valgrind can't handle it and
hard aborts on sigsegv. I don't know what the actual cause is but
simply renaming the variables is a workaround.
A microsecond resolution timestamp combined with a monotonically
incremented counter should be sufficient.
This also fixes PHP 8.4 compilation as PHP 8.4 doesn't seem to have
`php_rand()`.
* Switch remaining old-style PHP 5.4 `Array(...)` declarations to `[...]`
* Update variable names getting rid hungarian notation prefixes (e.g.
`str_`, `i_`, etc).
* Allow cluster seeds to be passed on the command-line instead of soley
relying on either a node environment variable or our
tests/nodes/nodemap file. This should make it easier to run ad-hoc
cluster tests by specifying just a single seed.
* Add some diagnostics for when we can't find a suitable cluster to run
our tests against indicating exactly where we looked for the env var
and node file.
* Refactor RedisArray tests to use our newer TestSuite assertions.
* Allow `RedisArray` ports to be specified on the command-line as well.
* Various formatting fixes.
* More robust KeyDB detection.
* Tighten up `assertTrue` and `assertFalse` such that they test that
passed arguments `===` `true` and `===` `false` respectively, instead
of testing for truth-like or false-like.
* Start modernizing our unit tests to use explicit types for arguments,
return types, member variables, etc.
* Multiple assertion fixes that were exposed when making `assertTrue`
and `assertFalse` more explicit.
* Some formatting cleanup to style for incorrect indentation, etc, that
had crept in over many years.
* Add some more assertion helpers like `assertNull`, `assertGT`,
`assertGTE`, `assertLT`, and `assertLTE`.
Our tests have a ton of instances where we do something like:
```php
$this->assert(TRUE === $this->redis->command1());
$this->assert($this->redis->command2() === 42);
```
Which should be written like this:
```php
$this->assertTrue($this->command1());
$this->assertEquals(42, $this->command2());
```
Additionally it changes some assertions to use more relevant assertions
like `assertInArray` rather than `assertTrue(in_array())`.
* Add `assertEqualsCanonicalizing` assertion similar to what PHPUnit
has.
* Add `assertStringContains` helper assertion.
* Refactor session tests
* Update these external scripts to take formal arguments with `getopt` to
make it more straightforward what each of the currently positional
arguments are actually for.
* Create small helper classes for invoking these external scripts.
Instead of `startSessionProcess` that takes a dozen argument all but
three of which have defaults, we can use a construct like this:
```php
$runner = $this->sessionRunner()
->maxExecutionTime(300)
->lockingEnabled(true)
->lockWaitTime(-1)
->lockExpires(0)
->data($data)
->compression($name);
// Invokes startSession.php with above args.
$result = $runner->execFg();
// Invokes regenerateSessionId.php with above args
$new_id = $runner->regenerateId();
// Invokes getSessionData.php for this session ID.
$data = $runner->getData();
```
* Add a bit of logic to TestSuite to dump more information about the
source of an assertion to make it easier to track down problems when
we assert outside of a top level public `test_*` method.
* Create a few new assertions like `assertKeyExists` and
`assertKeyMissing` which will generate much nicer assertions as
opposed to
```php
$this->assertTrue($this->redis->exists($some_key));
```
* If our externally spawned session scripts fail output the exact call
that was made along with all arguments as well as the output that we
received to make it easier to narrow down.
* snake_case -> camelCase