public function it_delegates_getCodepointsByCategory_calls($repository) { $ranges = Codepoint\Range\Collection::fromArray([]); $category = GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH); $repository->getCodepointsByCategory($category)->willReturn($ranges); $this->getCodepointsByCategory($category)->shouldReturn($ranges); }
public function it_exposes_codepoints_for_a_requested_category(Character $c1, Character $c2, Character $c3) { $this->givenCharacterHasCodepointWithValue($c1, 1); $this->givenCharacterHasCodepointWithValue($c2, 2); $this->givenCharacterHasCodepointWithValue($c3, 3); $this->givenCharacterResidesInCategory($c1, GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH)); $this->givenCharacterResidesInCategory($c2, GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH)); $this->givenCharacterResidesInCategory($c3, GeneralCategory::fromValue(GeneralCategory::NUMBER_LETTER)); $this->givenTheXMLParsesTo([$c1, $c2, $c3]); $this->getCodepointsByCategory(GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH))->shouldIterateLike([Range::between(Codepoint::fromInt(1), Codepoint::fromInt(2))]); }
/** * @param Database $db * @param string $propertyType * @param string $searchBy * @return Collection|CodepointAssigned[] * @throws UnexpectedValueException */ private function resolveCodepoints(Database $db, $propertyType, $searchBy) { switch ($propertyType) { case self::PROPERTY_BLOCK: $block = Block::fromValue($searchBy); return $db->getByBlock($block); case self::PROPERTY_CATEGORY: $category = GeneralCategory::fromValue($searchBy); return $db->getByCategory($category); case self::PROPERTY_SCRIPT: $script = Script::fromValue($searchBy); return $db->getByScript($script); } throw new UnexpectedValueException(); }
/** * @test */ public function it_displays_characters_residing_in_a_supplied_category() { $repository = new InMemoryRepository(); $codepoint = Codepoint::fromInt(97); $category = GeneralCategory::fromValue(GeneralCategory::LETTER_LOWERCASE); $character = $this->buildCharacterWithCodepoint($codepoint, null, $category); $characters = Collection::fromArray([$character]); $repository->addMany($characters); $this->container['repository.test'] = $repository; $this->commandTester->execute(['command' => PropertiesCommand::COMMAND_NAME, '--from' => 'test', 'property-type' => PropertiesCommand::PROPERTY_CATEGORY, 'value' => $category->getValue()]); $output = $this->commandTester->getDisplay(); $statusCode = $this->commandTester->getStatusCode(); ha::assertThat('output', $output, hm::containsString('U+61:')); ha::assertThat('status code', $statusCode, hm::is(hm::identicalTo(0))); }
/** * @test */ public function it_can_provide_all_codepoints_residing_in_a_specific_category() { $category = GeneralCategory::fromValue(GeneralCategory::OTHER_CONTROL); $codepoints = $this->repository->getCodepointsByCategory($category); ha::assertThat('count', count($codepoints), hm::is(hm::equalTo(1))); }
public function it_should_always_throw_a_CategoryNotFoundException_when_searching_by_category() { $this->shouldThrow(GeneralCategoryNotFoundException::class)->during('getCodepointsByCategory', [GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH)]); }
public function it_exposes_codepoints_for_a_requested_category($propertiesDirectory, PropertyFile $file) { $propertiesDirectory->getFileForProperty(Property::ofType(Property::GENERAL_CATEGORY))->willReturn($file); $file->read()->willReturn([GeneralCategory::SYMBOL_MATH => 's:{}']); $this->serializer->unserialize('s:{}')->willReturn($r = [Codepoint\Range::between(Codepoint::fromInt(0), Codepoint::fromInt(1))]); $this->getCodepointsByCategory(GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH))->shouldBeLike(Collection::fromArray($r)); }
public function it_can_provide_all_codepoint_assigned_entities_in_a_given_general_category() { $characters = Character\Collection::fromArray([]); $codepoint = Codepoint::fromInt(1); $ranges = Codepoint\Range\Collection::fromArray([$codepoint]); $category = GeneralCategory::fromValue(GeneralCategory::SYMBOL_MATH); $this->repository->getCodepointsByCategory($category)->willReturn($ranges); $this->repository->getByCodepoints($ranges->expand())->willReturn($characters); $this->getByCategory($category)->shouldReturn($characters); }