<commit_before><?php

namespace Tests\App\Service\File;

use App\Service\Crawler\BuddySchoolProfileFetcher;
use App\Service\File\BuddySchoolProfileFileGenerator;
use App\Service\File\FileExporterInterface;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as Mock;

class BuddySchoolProfileFileGeneratorTest extends TestCase
{
    /** @var BuddySchoolProfileFileGenerator|Mock */
    protected $generatorMock;

    /** @var FileExporterInterface|Mock */
    protected $fileExporterMock;

    /** @var BuddySchoolProfileFetcher|Mock */
    protected $profileFetcherMock;

    public function setUp()
    {
        $this->fileExporterMock = $this->createMock(FileExporterInterface::class);
        $this->profileFetcherMock = $this->createMock(BuddySchoolProfileFetcher::class);

        $this->generatorMock = $this->getMockBuilder(BuddySchoolProfileFileGenerator::class)
            ->setConstructorArgs([
                $this->fileExporterMock,
                $this->profileFetcherMock
            ])
            ->setMethods(['generateName'])
            ->getMock();
    }

    /**
     * @test
     */
    public function should_generate_profile_file()
    {
        $keyword = 'bar';
        $position = 1;

        $this->generatorMock->setWebPath('/var');

        $this->generatorMock
            ->expects(self::once())
            ->method('generateName')
            ->willReturn('foo.txt');

        $this->profileFetcherMock
            ->expects(self::once())
            ->method('getProfileContent')
            ->with($keyword, $position)
            ->willReturn('<body>baz</body>');

        $this->fileExporterMock
            ->expects(self::once())
            ->method('exportToFile')
            ->with('/var/files/foo.txt', '<body>baz</body>');

        $this->generatorMock->generateProfileFile($keyword, $position);
    }
}<commit_msg>tests on unmocked service<commit_after><?php

namespace Tests\App\Service\File;

use App\Service\Crawler\BuddySchoolProfileFetcher;
use App\Service\File\BuddySchoolProfileFileGenerator;
use App\Service\File\FileExporterInterface;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as Mock;

class BuddySchoolProfileFileGeneratorTest extends TestCase
{
    /** @var BuddySchoolProfileFileGenerator */
    protected $generator;

    /** @var FileExporterInterface|Mock */
    protected $fileExporterMock;

    /** @var BuddySchoolProfileFetcher|Mock */
    protected $profileFetcherMock;

    public function setUp()
    {
        $this->fileExporterMock = $this->createMock(FileExporterInterface::class);
        $this->profileFetcherMock = $this->createMock(BuddySchoolProfileFetcher::class);

        $this->generator = new BuddySchoolProfileFileGenerator(
            $this->fileExporterMock,
            $this->profileFetcherMock
        );
    }

    /**
     * @test
     */
    public function should_generate_profile_file()
    {
        $keyword = 'bar';
        $position = 1;

        $this->generator->setWebPath('/var');

        $this->profileFetcherMock
            ->expects(self::once())
            ->method('getProfileContent')
            ->with($keyword, $position)
            ->willReturn('<body>baz</body>');

        $this->fileExporterMock
            ->expects(self::once())
            ->method('exportToFile')
            ->with($this->stringContains('/var/files/'), '<body>baz</body>');

        $result = $this->generator->generateProfileFile($keyword, $position);

        $this->assertContains('.txt', $result);
    }
}
{'fraction_non_alphanumeric': 0.1351654514862591, 'fraction_numerical': 0.0005608524957936063, 'mean_word_length': 2.88139281828074, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 61, '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': '3953551', 'n_tokens_mistral': 1023, 'n_tokens_neox': 989, 'n_words': 142}