Ejemplo n.º 1
0
 protected function setUp()
 {
     $dbPath = $this->fs->path('/db');
     $propsPath = $this->fs->path('/props');
     mkdir($dbPath);
     mkdir($propsPath);
     $codepoint = Codepoint::fromInt(0);
     $path = $this->fs->path('/db/00000000-00000000!0001.php');
     $character = $this->buildCharacterWithCodepoint($codepoint);
     $content = sprintf("<?php\nreturn %s;", var_export([0 => serialize($character)], true));
     file_put_contents($path, $content);
     $path = $this->fs->path('/props/block.php');
     $collection = Codepoint\Range\Collection::fromArray([Codepoint\Range::between($codepoint, $codepoint)]);
     $content = sprintf("<?php\nreturn %s;", var_export(['ASCII' => serialize($collection->toArray())], true));
     file_put_contents($path, $content);
     $path = $this->fs->path('/props/gc.php');
     $collection = Codepoint\Range\Collection::fromArray([Codepoint\Range::between($codepoint, $codepoint)]);
     $content = sprintf("<?php\nreturn %s;", var_export(['Cc' => serialize($collection->toArray())], true));
     file_put_contents($path, $content);
     $path = $this->fs->path('/props/script.php');
     $collection = Codepoint\Range\Collection::fromArray([Codepoint\Range::between($codepoint, $codepoint)]);
     $content = sprintf("<?php\nreturn %s;", var_export(['Zyyy' => serialize($collection->toArray())], true));
     file_put_contents($path, $content);
     $this->registerContainerProviders();
     $this->container[ConfigurationProvider::CONFIG_KEY_DB_PATH] = $dbPath;
     $this->container[ConfigurationProvider::CONFIG_KEY_PROPS_PATH] = $propsPath;
     $this->repository = $this->container['repository.php'];
 }
Ejemplo n.º 2
0
 public function it_exposes_all_ranges_built_by_aggregators(KeyGenerator $keyGenerator, CodepointAssigned $item)
 {
     $key = 'key';
     $cp = Codepoint::fromInt(1);
     $item->getCodepoint()->willReturn($cp);
     $keyGenerator->generateFor($item)->willReturn($key);
     $this->beConstructedWith($keyGenerator);
     $this->add($item);
     $this->getAllRanges()->shouldBeLike([$key => Range\Collection::fromArray([Range::between($cp, $cp)])]);
 }
Ejemplo n.º 3
0
 /**
  * @param Property $property
  * @param string $key
  * @param Exception $notFoundException
  * @return Codepoint\Range[]
  * @throws Exception
  */
 private function resolveCodepointsByProperty(Property $property, $key, Exception $notFoundException)
 {
     $file = $this->propertiesDirectory->getFileForProperty($property);
     $map = $file->read();
     $codepoints = array_key_exists($key, $map) ? $this->serializer->unserialize($map[$key]) : [];
     if (count($codepoints) === 0) {
         throw $notFoundException;
     }
     return Codepoint\Range\Collection::fromArray($codepoints);
 }
Ejemplo n.º 4
0
 public function it_delegates_getCodepointsByScript_calls($repository)
 {
     $ranges = Codepoint\Range\Collection::fromArray([]);
     $script = Script::fromValue(Script::SAMARITAN);
     $repository->getCodepointsByScript($script)->willReturn($ranges);
     $this->getCodepointsByScript($script)->shouldReturn($ranges);
 }
Ejemplo n.º 5
0
 /**
  * @param Codepoint\Range\Collection $ranges
  * @return CodepointAssigned[]
  */
 private function getByCodepointRanges(Codepoint\Range\Collection $ranges)
 {
     return $this->getByCodepoints($ranges->expand());
 }
Ejemplo n.º 6
0
 public function it_exposes_codepoints_for_a_requested_script($propertiesDirectory, PropertyFile $file)
 {
     $propertiesDirectory->getFileForProperty(Property::ofType(Property::SCRIPT))->willReturn($file);
     $file->read()->willReturn([Script::SAMARITAN => 's:{}']);
     $this->serializer->unserialize('s:{}')->willReturn($r = [Codepoint\Range::between(Codepoint::fromInt(0), Codepoint::fromInt(1))]);
     $this->getCodepointsByScript(Script::fromValue(Script::SAMARITAN))->shouldBeLike(Collection::fromArray($r));
 }
Ejemplo n.º 7
0
 public function it_can_provide_all_codepoint_assigned_entities_in_a_given_script()
 {
     $characters = Character\Collection::fromArray([]);
     $codepoint = Codepoint::fromInt(1);
     $ranges = Codepoint\Range\Collection::fromArray([$codepoint]);
     $script = Script::fromValue(Script::COMMON);
     $this->repository->getCodepointsByScript($script)->willReturn($ranges);
     $this->repository->getByCodepoints($ranges->expand())->willReturn($characters);
     $this->getByScript($script)->shouldReturn($characters);
 }