/** * @test */ function it_finds_records_by_translated_attribute_value() { // finds by translation exact $this->assertInstanceOf(TestExtendedModel::class, $this->repository->findByTranslation(self::TRANSLATED_FIELD, 'vertaalde_attribuutwaarde hoepla', 'nl'), "Did not find exact match for find"); $this->assertNotInstanceOf(TestExtendedModel::class, $this->repository->findByTranslation(self::TRANSLATED_FIELD, 'vertaalde_attribuutwaarde hoepla', 'en'), "Should not have found match for different locale"); // finds by translation LIKE $this->assertInstanceOf(TestExtendedModel::class, $this->repository->findByTranslation(self::TRANSLATED_FIELD, '%attribuutwaarde hoe%', 'nl', false), "Did not find loosy match for find"); // finds ALL by translation exact $this->assertCount(1, $this->repository->findAllByTranslation(self::TRANSLATED_FIELD, 'vertaalde_attribuutwaarde hoepla', 'nl'), "Incorrect count with exact match for all"); // finds ALL by translation LIKE // also check if we don't get duplicates for multiple hits $this->assertCount(1, $this->repository->findAllByTranslation(self::TRANSLATED_FIELD, '%vertaalde_attribuutwaarde%', 'nl', false), "Incorrect count with loosy match for all"); }