<commit_before><?php

/*
 * This file is part of the Predis package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Predis\Cluster;

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\Cluster\Distribution\HashRing;
use Predis\Profile\ServerProfile;

/**
 *
 */
class PredisClusterHashStrategyTest extends StandardTestCase
{
    /**
     * @group disconnected
     */
    public function testSupportsKeyTags()
    {
        $expected = -1938594527;
        $strategy = $this->getHashStrategy();

        $this->assertSame($expected, $strategy->getKeyHash('{foo}'));
        $this->assertSame($expected, $strategy->getKeyHash('{foo}:bar'));
        $this->assertSame($expected, $strategy->getKeyHash('{foo}:baz'));
        $this->assertSame($expected, $strategy->getKeyHash('bar:{foo}:bar'));
<commit_msg>Fix test to handle different hashes generated on 64bits builds of PHP.<commit_after><?php

/*
 * This file is part of the Predis package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Predis\Cluster;

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\Cluster\Distribution\HashRing;
use Predis\Profile\ServerProfile;

/**
 *
 */
class PredisClusterHashStrategyTest extends StandardTestCase
{
    /**
     * @group disconnected
     */
    public function testSupportsKeyTags()
    {
        // NOTE: 32 and 64 bits PHP runtimes can produce different hash values.
        $expected = PHP_INT_SIZE == 4 ? -1938594527 : 2356372769;

        $strategy = $this->getHashStrategy();

        $this->assertSame($expected, $strategy->getKeyHash('{foo}'));
        $this->assertSame($expected, $strategy->getKeyHash('{foo}:bar'));
        $this->assertSame($expected, $strategy->getKeyHash('{foo}:baz'));
        $this->assertSame($expected, $strategy->getKeyHash('bar:{foo}:bar'));

{'fraction_non_alphanumeric': 0.1386861313868613, 'fraction_numerical': 0.01800486618004866, 'mean_word_length': 3.849056603773585, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3628505', 'n_tokens_mistral': 622, 'n_tokens_neox': 594, 'n_words': 150}