本文整理汇总了PHP中Symfony\Component\Finder\SplFileInfo::getWrappedObject方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getWrappedObject方法的具体用法?PHP SplFileInfo::getWrappedObject怎么用?PHP SplFileInfo::getWrappedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Finder\SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getWrappedObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_searches_for_files(FinderFactoryInterface $finderFactory, Finder $finder, SplFileInfo $firstSplFileInfo, SplFileInfo $secondSplFileInfo)
{
$finderFactory->create()->willReturn($finder);
$finder->name('readme.md')->shouldBeCalled()->willReturn($finder);
$finder->in(['/search/path/'])->shouldBeCalled()->willReturn($finder);
$finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder);
$finder->files()->shouldBeCalled()->willReturn($finder);
$finder->getIterator()->willReturn(new \ArrayIterator([$firstSplFileInfo->getWrappedObject(), $secondSplFileInfo->getWrappedObject()]));
$finder->count()->willReturn(2);
$firstSplFileInfo->getPathname()->willReturn('/search/path/nested1/readme.md');
$secondSplFileInfo->getPathname()->willReturn('/search/path/nested2/readme.md');
$this->locateFilesNamed('readme.md')->shouldReturn(['/search/path/nested1/readme.md', '/search/path/nested2/readme.md']);
}
示例2:
function it_should_filter_by_a_list_of_files(SplFileInfo $file1, SplFileInfo $file2)
{
$file1->getPathname()->willReturn('path1/file.php');
$file2->getPathname()->willReturn('path2/file.php');
$iterator = new \ArrayIterator(array($file1->getWrappedObject()));
$result = $this->filterByFileList($iterator);
$result->count()->shouldBe(1);
$files = $result->toArray();
$files[0]->shouldBe($file1);
}
示例3:
function it_silences_finder_exceptions_even_if_searching_in_multiple_sources(FinderFactoryInterface $finderFactory, Finder $firstFinder, Finder $secondFinder, SplFileInfo $splFileInfo)
{
$this->beConstructedWith($finderFactory, ['/search/path/first/', '/search/path/second/']);
$finderFactory->create()->willReturn($firstFinder, $secondFinder);
$firstFinder->name('readme.md')->shouldBeCalled()->willReturn($firstFinder);
$firstFinder->in('/search/path/first/')->shouldBeCalled()->willReturn($firstFinder);
$firstFinder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($firstFinder);
$firstFinder->files()->shouldBeCalled()->willReturn($firstFinder);
$secondFinder->name('readme.md')->shouldBeCalled()->willReturn($secondFinder);
$secondFinder->in('/search/path/second/')->shouldBeCalled()->willReturn($secondFinder);
$secondFinder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($secondFinder);
$secondFinder->files()->shouldBeCalled()->willReturn($secondFinder);
$firstFinder->getIterator()->willReturn(new \ArrayIterator([$splFileInfo->getWrappedObject()]));
$secondFinder->getIterator()->willThrow(\InvalidArgumentException::class);
$splFileInfo->getPathname()->willReturn('/search/path/first/nested/readme.md');
$this->locateFilesNamed('readme.md')->shouldReturn(['/search/path/first/nested/readme.md']);
}