public function it_can_be_constructed_from_a_property() { $dbPath = new \SplFileInfo('/props'); $property = Property::ofType(Property::BLOCK); $this->beConstructedThrough('fromProperty', [$dbPath, $property]); $this->shouldImplement(PHPPropertyFile::class); }
/** * @param Container $container */ private function setupPHPFileRepository(Container $container) { $this->addMany($container, ['pfr.serializer' => function () { return new PHPSerializer(); }, 'pfr.database_path' => function (Container $container) { return new \SplFileInfo($container[ConfigurationProvider::CONFIG_KEY_DB_PATH]); }, 'pfr.properties_path' => function (Container $container) { return new \SplFileInfo($container[ConfigurationProvider::CONFIG_KEY_PROPS_PATH]); }, 'pfr.characters_directory' => function (Container $container) { return PHPRangeFileDirectory::fromPath($container['pfr.database_path']); }, 'pfr.properties_directory' => function (Container $container) { return PHPPropertyFileDirectory::fromPath($container['pfr.properties_path']); }, 'pft.property_aggregators.block' => function () { return new AggregatorRelay(new BlockKeyGenerator()); }, 'pft.property_aggregators.general_category' => function () { return new AggregatorRelay(new GeneralCategoryKeyGenerator()); }, 'pft.property_aggregators.script' => function () { return new AggregatorRelay(new ScriptKeyGenerator()); }, 'pfr.property_aggregators' => function (Container $container) { $aggregators = new PropertyAggregators(); $aggregators->registerAggregatorRelay(Property::ofType(Property::BLOCK), $container['pft.property_aggregators.block']); $aggregators->registerAggregatorRelay(Property::ofType(Property::GENERAL_CATEGORY), $container['pft.property_aggregators.general_category']); $aggregators->registerAggregatorRelay(Property::ofType(Property::SCRIPT), $container['pft.property_aggregators.script']); return $aggregators; }, 'repository.php' => function (Container $container) { return new FileRepository($container['pfr.characters_directory'], $container['pfr.properties_directory'], $container['pfr.property_aggregators'], $container['pfr.serializer']); }]); }
/** * @param \SplFileInfo $fileInfo * @return PHPPropertyFile * @throws InvalidArgumentException */ public static function fromFileInfo(\SplFileInfo $fileInfo) { if (preg_match(self::FILE_NAME_REGEX, $fileInfo->getBasename(), $matches) !== 1) { throw new InvalidArgumentException(); } $file = new PHPFile($fileInfo); $property = Property::ofType($matches['type']); return new self($file, $property); }
public function it_can_have_new_files_added_to_it_by_property_details() { $dbPath = new \SplFileInfo('/props'); $fileInfo = new \SplFileInfo('/props/block.php'); $propertyFiles = new PropertyFiles(); $property = Property::ofType(Property::BLOCK); $this->beConstructedWith($dbPath, $propertyFiles); $this->addFileForProperty($property)->shouldBeLike(new PHPPropertyFile(new PHPFile($fileInfo), $property)); }
public function let(File $file) { $property = Property::ofType(Property::BLOCK); $this->beConstructedWith($file, $property); }
public function it_throws_UnexpectedValueException_if_no_file_exists_for_a_supplied_property() { $property = Property::ofType(Property::BLOCK); $this->shouldThrow(UnexpectedValueException::class)->duringGetByProperty($property); }
public function it_can_be_iterated(AggregatorRelay $aggregatorRelay) { $property = Property::ofType(Property::BLOCK); $this->givenCollectionContains($property, $aggregatorRelay); $this->shouldYieldFromIteratorAggregate($property, $aggregatorRelay); }
/** * {@inheritDoc} */ public function getCodepointsByScript(Properties\General\Script $script) { return $this->resolveCodepointsByProperty(Property::ofType(Property::SCRIPT), (string) $script, Repository\ScriptNotFoundException::withScript($script)); }
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)); }