Ejemplo n.º 1
0
 public function it_delegates_getCodepointsByBlock_calls($repository)
 {
     $ranges = Codepoint\Range\Collection::fromArray([]);
     $block = Block::fromValue(Block::CYRILLIC);
     $repository->getCodepointsByBlock($block)->willReturn($ranges);
     $this->getCodepointsByBlock($block)->shouldReturn($ranges);
 }
Ejemplo n.º 2
0
 /**
  * @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();
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function it_displays_characters_residing_in_a_supplied_block()
 {
     $repository = new InMemoryRepository();
     $codepoint = Codepoint::fromInt(97);
     $block = Block::fromValue(Block::BASIC_LATIN);
     $character = $this->buildCharacterWithCodepoint($codepoint, $block);
     $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_BLOCK, 'value' => $block->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)));
 }
Ejemplo n.º 4
0
 /**
  * @test
  */
 public function it_can_provide_all_codepoints_residing_in_a_block()
 {
     $block = Block::fromValue(Block::BASIC_LATIN);
     $codepoints = $this->repository->getCodepointsByBlock($block);
     ha::assertThat('count', count($codepoints), hm::is(hm::equalTo(1)));
 }
Ejemplo n.º 5
0
 public function it_throws_BlockNotFoundException_if_a_supplied_block_is_not_known()
 {
     $this->shouldThrow(BlockNotFoundException::class)->during('getCodepointsByBlock', [Block::fromValue(Block::ALCHEMICAL_SYMBOLS)]);
 }
Ejemplo n.º 6
0
 public function it_should_always_throw_a_BlockNotFoundException_when_searching_by_block()
 {
     $this->shouldThrow(BlockNotFoundException::class)->during('getCodepointsByBlock', [Block::fromValue(Block::ALCHEMICAL_SYMBOLS)]);
 }
Ejemplo n.º 7
0
 /**
  * @param Block $block
  * @return bool
  */
 private function isValidBlock(Block $block)
 {
     static $valid = [Block::HIGH_PRIVATE_USE_SURROGATES => true, Block::HIGH_SURROGATES => true, Block::LOW_SURROGATES => true];
     return array_key_exists($block->getValue(), $valid);
 }
Ejemplo n.º 8
0
 public function it_exposes_codepoints_for_a_requested_block($propertiesDirectory, PropertyFile $file)
 {
     $propertiesDirectory->getFileForProperty(Property::ofType(Property::BLOCK))->willReturn($file);
     $file->read()->willReturn([Block::AEGEAN_NUMBERS => 's:{}']);
     $this->serializer->unserialize('s:{}')->willReturn($r = [Codepoint\Range::between(Codepoint::fromInt(0), Codepoint::fromInt(1))]);
     $this->getCodepointsByBlock(Block::fromValue(Block::AEGEAN_NUMBERS))->shouldBeLike(Collection::fromArray($r));
 }
Ejemplo n.º 9
0
 public function it_can_provide_all_codepoint_assigned_entities_in_a_specific_block()
 {
     $characters = Character\Collection::fromArray([]);
     $codepoint = Codepoint::fromInt(1);
     $ranges = Codepoint\Range\Collection::fromArray([$codepoint]);
     $block = Block::fromValue(Block::AEGEAN_NUMBERS);
     $this->repository->getCodepointsByBlock($block)->willReturn($ranges);
     $this->repository->getByCodepoints($ranges->expand())->willReturn($characters);
     $this->getByBlock($block)->shouldReturn($characters);
 }