<commit_before><?php

namespace Algolia\SearchBundle\TestCase;

use Algolia\SearchBundle\BaseTest;
use Algolia\SearchBundle\Normalizer\CommentNormalizer;
use Algolia\SearchBundle\Searchable;
use Algolia\SearchBundle\SearchableEntity;
use Algolia\SearchBundle\TestApp\Entity\Comment;
use Algolia\SearchBundle\TestApp\Entity\Post;
use Algolia\SearchBundle\TestApp\Entity\Tag;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Serializer;

class SerializationTest extends BaseTest
{
    public function testSerializerHasRequiredNormalizers()
    {
        $serializer = $this->get('serializer');

        $refl                = new \ReflectionClass($serializer);
        $normalizersProperty = $refl->getProperty('normalizers');
        $normalizersProperty->setAccessible(true);
        $normalizers = $normalizersProperty->getValue($serializer);

        $classes = array_map(function ($value) {
            return get_class($value);
        }, $normalizers);

        $this->assertContains('ObjectNormalizer', end($classes));
        $this->assertContains('CustomNormalizer', $classes[1]);
        $this->assertEquals(CommentNormalizer::class, $classes[0]);
        $this->assertGreaterThan(3, count($classes));
    }

    public function testSimpleEntityToSearchableArray()
    {
        $datetime       = new \DateTime();<commit_msg>fix(tests): serializer test (#352)<commit_after><?php

namespace Algolia\SearchBundle\TestCase;

use Algolia\SearchBundle\BaseTest;
use Algolia\SearchBundle\Normalizer\CommentNormalizer;
use Algolia\SearchBundle\Searchable;
use Algolia\SearchBundle\SearchableEntity;
use Algolia\SearchBundle\TestApp\Entity\Comment;
use Algolia\SearchBundle\TestApp\Entity\Post;
use Algolia\SearchBundle\TestApp\Entity\Tag;
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Serializer;

class SerializationTest extends BaseTest
{
    public function testSerializerHasRequiredNormalizers()
    {
        $serializer = $this->get('serializer');

        $refl                = new \ReflectionClass($serializer);
        $normalizersProperty = $refl->getProperty('normalizers');
        $normalizersProperty->setAccessible(true);
        $normalizers = $normalizersProperty->getValue($serializer);

        $classes = array_map(function ($value) {
            return get_class($value);
        }, $normalizers);

        $this->assertContains('ObjectNormalizer', end($classes));
        $this->assertContains(CustomNormalizer::class, $classes);
        $this->assertContains(CommentNormalizer::class, $classes);
        $this->assertGreaterThan(3, count($classes));
    }

    public function testSimpleEntityToSearchableArray()
    {
        $datetime       = new \DateTime();
{'fraction_non_alphanumeric': 0.11692415730337079, 'fraction_numerical': 0.0024578651685393258, 'mean_word_length': 4.275925925925926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6871296', 'n_tokens_mistral': 786, 'n_tokens_neox': 775, 'n_words': 120}