<commit_before><?php

/*
 * This file is part of PHP CS Fixer.
 *
 * (c) <NAME> <<EMAIL>>
 *     <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace PhpCsFixer\Tests\Cache;

use PhpCsFixer\Cache\CacheInterface;
use PhpCsFixer\Cache\FileCacheManager;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

/**
 * @author <NAME> <<EMAIL>>
 *
 * @internal
 *
 * @covers \PhpCsFixer\Cache\FileCacheManager
 */
final class FileCacheManagerTest extends TestCase
{
    public function testIsFinal()
    {
        $reflection = new \ReflectionClass(\PhpCsFixer\Cache\FileCacheManager::class);

        $this->assertTrue($reflection->isFinal());
    }

    public function testImplementsCacheManagerInterface()
    {
        $reflection = new \ReflectionClass(\PhpCsFixer\Cache\FileCacheManager::class);

        $this->assertTrue($reflection->implementsInterface(\PhpCsFixer\Cache\CacheManagerInterface::class));
    }

    public function testCreatesCacheIfHandlerReturnedNoCache()
    {
        $signature = $this->prophesize(\PhpCsFixer\Cache\SignatureInterface::class)->reveal();

        $handlerProphecy = $this->prophesize(\PhpCsFixer\Cache\FileHandlerInterface::class);
        $handlerProphecy = $this->prophesize(\PhpCsFixer\Cache\FileHandlerInterface::class);
        $handlerProphecy->read()->shouldBeCalled()->willReturn(null);
        $handlerProphecy->write(Argument::that(function (CacheInterface $cache) use ($signature) {
            return $cache->getSignature() === $signature;
        }))->shouldBeCalled()->willReturn(null);
        $handler = $handlerProphecy->reveal();

        $manager = new FileCacheManager(
            $handler,
            $signature
        );

        unset($manager);
    }

    public function testCreatesCacheIfCachedSignatureIsDifferent()
    {<commit_msg>FileCacheManagerTest - drop duplicated line<commit_after><?php

/*
 * This file is part of PHP CS Fixer.
 *
 * (c) <NAME> <<EMAIL>>
 *     <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace PhpCsFixer\Tests\Cache;

use PhpCsFixer\Cache\CacheInterface;
use PhpCsFixer\Cache\FileCacheManager;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

/**
 * @author <NAME> <<EMAIL>>
 *
 * @internal
 *
 * @covers \PhpCsFixer\Cache\FileCacheManager
 */
final class FileCacheManagerTest extends TestCase
{
    public function testIsFinal()
    {
        $reflection = new \ReflectionClass(\PhpCsFixer\Cache\FileCacheManager::class);

        $this->assertTrue($reflection->isFinal());
    }

    public function testImplementsCacheManagerInterface()
    {
        $reflection = new \ReflectionClass(\PhpCsFixer\Cache\FileCacheManager::class);

        $this->assertTrue($reflection->implementsInterface(\PhpCsFixer\Cache\CacheManagerInterface::class));
    }

    public function testCreatesCacheIfHandlerReturnedNoCache()
    {
        $signature = $this->prophesize(\PhpCsFixer\Cache\SignatureInterface::class)->reveal();

        $handlerProphecy = $this->prophesize(\PhpCsFixer\Cache\FileHandlerInterface::class);
        $handlerProphecy->read()->shouldBeCalled()->willReturn(null);
        $handlerProphecy->write(Argument::that(function (CacheInterface $cache) use ($signature) {
            return $cache->getSignature() === $signature;
        }))->shouldBeCalled()->willReturn(null);
        $handler = $handlerProphecy->reveal();

        $manager = new FileCacheManager(
            $handler,
            $signature
        );

        unset($manager);
    }

    public function testCreatesCacheIfCachedSignatureIsDifferent()
    {
{'fraction_non_alphanumeric': 0.12865183596890914, 'fraction_numerical': 0.0, 'mean_word_length': 3.62453531598513, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 52, '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': '4135652', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1086, 'n_words': 199}