hasChild() public method

checks whether the container contains a child with the given name
public hasChild ( string $name ) : boolean
$name string
return boolean
 /**
  * @depends testInstanceOf
  */
 public function testWriteIsWritingYamlIntoFile()
 {
     $yamlWriterProvider = new YamlWriterProvider($this->mockWriter);
     $this->mockWriter->expects($this->once())->method('dump')->with(array('result' => false))->willReturn('result: false');
     $yamlWriterProvider->write(vfsStream::url('settings/config.yml'), array('result' => false));
     $this->assertTrue($this->root->hasChild('settings/config.yml'));
 }
Beispiel #2
0
 public function testSavingConfig()
 {
     $this->object->setGeneratorDirectory('generator/test/dir');
     $this->assertTrue($this->filesystem->hasChild('.phpteda'));
     $actualConfiguration = unserialize($this->filesystem->getChild('.phpteda')->getContent());
     $expectedConfiguration = array('GeneratorDirectory' => 'generator/test/dir');
     $this->assertEquals($expectedConfiguration, $actualConfiguration);
 }
 protected function pathToUrl($path = '')
 {
     //@todo Consider adding hasChild() test and throw exception if test fails?
     if ($this->root->hasChild(ltrim($path, '/'))) {
         return $this->root->getChild(ltrim($path, '/'))->url();
     }
     return $this->root->url() . $path;
 }
 public function testItSavesTypeClassFiles()
 {
     $this->sut->save(FooBarType::class, 'foobar_type_class_content');
     $filename = base64_encode(FooBarType::class) . '.php';
     $this->assertTrue($this->root->hasChild($filename));
     $child = $this->root->getChild($filename);
     $this->assertEquals('<?php foobar_type_class_content', file_get_contents($child->url()));
 }
Beispiel #5
0
 /**
  * @covers \EscoMail\Service\MailLogger::__construct
  * @covers \EscoMail\Service\MailLogger::getLogDirPath
  */
 public function testCanCreateInstanceWithLogDirCreation()
 {
     $configArray = array('log_dir' => vfsStream::url('exampleDir') . '/tmp');
     $serviceManager = new ServiceManager();
     $options = new ModuleOptions($configArray);
     $mailLogger = new MailLogger($options, $serviceManager);
     $this->assertInstanceOf('EscoMail\\Service\\MailLogger', $mailLogger);
     $this->assertTrue($this->root->hasChild('tmp/mail.log'));
 }
 /**
  * @covers ::updateAddressFormats
  */
 public function testUpdateAddressFormatsRemovesLegacyFiles()
 {
     $this->root->addChild(new vfsStreamFile('legacy.json'));
     $httpClient = new HttpClient();
     $httpClient->setAdapter(new HttpTestAdapter());
     $maintenanceService = new MaintenanceService($this->options, $httpClient);
     $maintenanceService->updateAddressFormats();
     $this->assertFalse($this->root->hasChild('legacy.json'));
 }
 /**
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::process
  */
 public function testProcessCreatesDirectories()
 {
     $this->schemaService->expects($this->once())->method('getSchemas')->will($this->returnValue([]));
     ob_start();
     $this->generator->process();
     ob_end_clean();
     $this->assertTrue(file_exists(vfsStream::url('root')));
     $this->assertTrue($this->root->hasChild('cache'));
 }
 public function testCreateServiceWithDirectoryCreation()
 {
     $configArray = array('transport_class' => 'Zend\\Mail\\Transport\\File', 'transport_options' => array('path' => vfsStream::url('exampleDir') . '/tmp'));
     $config = new ModuleOptions($configArray);
     $this->serviceManager->setService('EscoMail\\Options', $config);
     $factory = new TransportFactory();
     $transport = $factory->createService($this->serviceManager);
     $this->assertInstanceOf('Zend\\Mail\\Transport\\File', $transport);
     $this->assertTrue($this->root->hasChild('tmp'));
 }
Beispiel #9
0
 public function testUpload()
 {
     $this->assertTrue($this->vfs->getChild('tmp')->hasChild('foo.txt'));
     $this->assertFalse($this->vfs->getChild('uploads')->hasChild('bar'));
     $input = new File('foo.txt', vfsStream::url('root/tmp/foo.txt'));
     $this->adapter->upload('bar/foo.txt', $input);
     $this->assertFalse($this->vfs->hasChild('foo.txt'));
     $this->assertTrue($this->vfs->getChild('uploads')->hasChild('bar'));
     $this->assertTrue($this->vfs->getChild('uploads')->getChild('bar')->hasChild('foo.txt'));
 }
 /**
  * @covers \Heystack\Core\Console\Command\GenerateContainer::__construct
  * @covers \Heystack\Core\Console\Command\GenerateContainer::execute
  * @covers \Heystack\Core\Console\Command\GenerateContainer::configure
  * @covers \Heystack\Core\Console\Command\GenerateContainer::createContainer
  * @covers \Heystack\Core\Console\Command\GenerateContainer::loadConfig
  * @covers \Heystack\Core\Console\Command\GenerateContainer::dumpContainer
  */
 public function testContainerCreated()
 {
     $command = $this->getMock(__NAMESPACE__ . '\\GenerateContainer', ['getRealPath'], [vfsStream::url('root'), vfsStream::url('root/heystack')]);
     $command->expects($this->once())->method('getRealPath')->will($this->returnArgument(0));
     $application = new Application();
     $application->add($command);
     $application->find('generate-container');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     $this->assertTrue($this->rootFileSystem->hasChild('heystack/cache/HeystackServiceContainerlive.php'));
     $this->assertContains('class HeystackServiceContainerlive extends Heystack\\Core\\DependencyInjection\\SilverStripe\\HeystackSilverStripeContainer', file_get_contents(vfsStream::url('root/heystack/cache/HeystackServiceContainerlive.php')));
 }
Beispiel #11
0
 public function testExecute()
 {
     $application = new Application();
     $application->add(new Init(null, vfsStream::url('root')));
     $command = $application->find('init');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     $this->assertTrue($this->fs->hasChild('views'));
     $this->assertTrue($this->fs->hasChild('cache'));
     $this->assertTrue($this->fs->hasChild('compiled'));
     $this->assertTrue($this->fs->hasChild('public'));
     $this->assertFileExists(vfsStream::url('root/public/index.php'));
     $this->assertRegExp('/Initialization complete!/', $commandTester->getDisplay());
 }
 public function testModuleInit()
 {
     $this->vfsRoot->addChild($this->createFile('file1'));
     $this->vfsRoot->addChild($this->createFile('file1'));
     $this->vfsRoot->addChild(vfsStream::newDirectory('dir1'));
     AspectMock::double(\Codeception\Configuration::class, ['outputDir' => vfsStream::url('outputDir')]);
     // Cleansman needs no configuration atm
     $event = m::mock(\Codeception\Event\SuiteEvent::class);
     $sut = new \Codeception\Extension\Cleansman([], ['silent' => false]);
     // Actual cleanup happens here
     $sut->moduleInit($event);
     $this->assertFalse($this->vfsRoot->hasChild('file1'));
     $this->assertFalse($this->vfsRoot->hasChild('file2'));
     $this->assertFalse($this->vfsRoot->hasChild('dir1'));
 }
Beispiel #13
0
 public function testUpload()
 {
     $this->assertTrue($this->vfs->getChild('tmp')->hasChild('foo.txt'));
     $this->assertFalse($this->vfs->getChild('uploads')->hasChild('bar'));
     $input = new File('foo.txt', vfsStream::url('root/tmp/foo.txt'));
     $id = $this->uploads->upload($input);
     $this->assertFalse($this->vfs->hasChild('foo.txt'));
     $parts = explode('/', $id);
     $leaf = array_pop($parts);
     $child = $this->vfs->getChild('uploads');
     foreach ($parts as $part) {
         $this->assertTrue($child->hasChild($part));
         $child = $child->getChild($part);
     }
     $this->assertTrue($child->hasChild($leaf));
 }
 public function testProcess()
 {
     $file = new \SplFileInfo(vfsStream::url('root/sample.jpg'));
     $resultFile = $this->provider->process($this->media, $this->variant, $file);
     $filename = $resultFile->getBasename();
     $this->assertStringEndsWith('-temp-sample.jpg', $filename);
     $this->assertTrue($this->dir->hasChild($filename));
 }
    /**
     * @covers Intacct\Functions\Company\AttachmentFile::writeXml
     */
    public function testConstruct()
    {
        $expected = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<attachment>
    <attachmentname>input</attachmentname>
    <attachmenttype>csv</attachmenttype>
    <attachmentdata>aGVsbG8sd29ybGQKdW5pdCx0ZXN0</attachmentdata>
</attachment>
EOF;
        $xml = new XMLWriter();
        $xml->openMemory();
        $xml->setIndent(true);
        $xml->setIndentString('    ');
        $xml->startDocument();
        $record = new AttachmentFile();
        $this->assertTrue($this->root->hasChild('csv/input.csv'));
        $record->setFilePath($this->root->url() . '/csv/input.csv');
        $record->writeXml($xml);
        $this->assertXmlStringEqualsXmlString($expected, $xml->flush());
    }
Beispiel #16
0
 /**
  * Checkers whether the container contains
  * a child with the given name
  *
  * @param   string $name
  *
  * @return  bool
  */
 public function hasChild($name)
 {
     $this->assertVfsHasBeenSetUp();
     return $this->vfs->hasChild($name);
 }
 /**
  * Checking folder creation & retrieval
  */
 public function testCheckDirectory()
 {
     $this->assertFalse($this->root->hasChild('mypath'));
     $this->wrapper->checkDirectory(vfsStream::url('exampleDir/mypath/.'));
     $this->assertTrue($this->root->hasChild('mypath'));
 }
Beispiel #18
0
 function its_purge_deletes_dump_file()
 {
     $this->given_dump_file('');
     $this->subject->purge();
     expect($this->tmp_dir->hasChild(self::DUMP_FILE))->toBe(FALSE);
 }
Beispiel #19
0
 public function test_deleteFile()
 {
     $this->assertTrue($this->root->hasChild('some.ext'), 'Целевой файл перед удалением существует');
     FS::deleteFile($this->rootPath . 'some.ext');
     $this->assertFalse($this->root->hasChild('some.ext'), 'Целевой файл после удаления исчез');
 }