Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * This file is part of PhpRedisJSON library * * @project phpredis-json * @..
Decoded Output download
<?php
/**
* This file is part of PhpRedisJSON library
*
* @project phpredis-json
* @author Rafael Campoy <[email protected]>
* @copyright 2019 Rafael Campoy <[email protected]>
* @license MIT
* @link https://github.com/averias/phpredis-json
*
* Copyright and license information, is included in
* the LICENSE file that is distributed with this source code.
*/
namespace Averias\RedisJson\Tests\Unit\Command\Traits;
use Averias\RedisJson\Enum\JsonCommands;
use Averias\RedisJson\Exception\ResponseException;
use Averias\RedisJson\Enum\Keys;
use Averias\RedisJson\Tests\Unit\Command\BaseTestJsonCommandTrait;
class JsonArrayInsertCommandTest extends BaseTestJsonCommandTrait
{
/**
* @dataProvider getJsonArrayInsertDataProvider
* @param array $arguments
* @param int $returnedValue
* @param string $key
* @param string $path
* @param int $index
* @param array $values
*/
public function testJsonInsertAppend(
array $arguments,
int $returnedValue,
string $key,
string $path,
int $index,
array $values
): void {
$mock = $this->getRedisJsonClient($returnedValue, $arguments);
$result = $mock->jsonArrayInsert($key, $path, $index, ...$values);
$this->assertEquals($returnedValue, $result);
}
public function testJsonArrayInsertException(): void
{
$this->expectException(ResponseException::class);
$this->expectExceptionMessage('you need to provide at least one value to insert in JSON.ARRINSERT command');
$mock = $this->getRedisJsonClient(
5,
[JsonCommands::ARRAY_INSERT, [Keys::DEFAULT_KEY], [Keys::DEFAULT_KEY, '.', 1]]
);
$mock->jsonArrayInsert(Keys::DEFAULT_KEY, '.', 1, ...[]);
}
public function getJsonArrayInsertDataProvider(): array
{
return [
[
[JsonCommands::ARRAY_INSERT, [Keys::DEFAULT_KEY], [Keys::DEFAULT_KEY, '.', 3, '"value1"', '14.3']],
5,
Keys::DEFAULT_KEY,
'.',
3,
['value1', 14.3]
],
[
[JsonCommands::ARRAY_INSERT, [Keys::DEFAULT_KEY], [Keys::DEFAULT_KEY, '.', 2, '{"name":"foo"}', 'true']],
4,
Keys::DEFAULT_KEY,
'.',
2,
[["name" => "foo"], true]
]
];
}
}
?>
Did this file decode correctly?
Original Code
<?php
/**
* This file is part of PhpRedisJSON library
*
* @project phpredis-json
* @author Rafael Campoy <[email protected]>
* @copyright 2019 Rafael Campoy <[email protected]>
* @license MIT
* @link https://github.com/averias/phpredis-json
*
* Copyright and license information, is included in
* the LICENSE file that is distributed with this source code.
*/
namespace Averias\RedisJson\Tests\Unit\Command\Traits;
use Averias\RedisJson\Enum\JsonCommands;
use Averias\RedisJson\Exception\ResponseException;
use Averias\RedisJson\Enum\Keys;
use Averias\RedisJson\Tests\Unit\Command\BaseTestJsonCommandTrait;
class JsonArrayInsertCommandTest extends BaseTestJsonCommandTrait
{
/**
* @dataProvider getJsonArrayInsertDataProvider
* @param array $arguments
* @param int $returnedValue
* @param string $key
* @param string $path
* @param int $index
* @param array $values
*/
public function testJsonInsertAppend(
array $arguments,
int $returnedValue,
string $key,
string $path,
int $index,
array $values
): void {
$mock = $this->getRedisJsonClient($returnedValue, $arguments);
$result = $mock->jsonArrayInsert($key, $path, $index, ...$values);
$this->assertEquals($returnedValue, $result);
}
public function testJsonArrayInsertException(): void
{
$this->expectException(ResponseException::class);
$this->expectExceptionMessage('you need to provide at least one value to insert in JSON.ARRINSERT command');
$mock = $this->getRedisJsonClient(
5,
[JsonCommands::ARRAY_INSERT, [Keys::DEFAULT_KEY], [Keys::DEFAULT_KEY, '.', 1]]
);
$mock->jsonArrayInsert(Keys::DEFAULT_KEY, '.', 1, ...[]);
}
public function getJsonArrayInsertDataProvider(): array
{
return [
[
[JsonCommands::ARRAY_INSERT, [Keys::DEFAULT_KEY], [Keys::DEFAULT_KEY, '.', 3, '"value1"', '14.3']],
5,
Keys::DEFAULT_KEY,
'.',
3,
['value1', 14.3]
],
[
[JsonCommands::ARRAY_INSERT, [Keys::DEFAULT_KEY], [Keys::DEFAULT_KEY, '.', 2, '{"name":"foo"}', 'true']],
4,
Keys::DEFAULT_KEY,
'.',
2,
[["name" => "foo"], true]
]
];
}
}
Function Calls
None |
Stats
MD5 | 56607a7575a4bc598156ad41c9bc3b39 |
Eval Count | 0 |
Decode Time | 94 ms |