/**
     * @param string $type
     * @param bool   $verbose
     * @param string $exceptionClass
     * @param string $validTrace
     *
     * @dataProvider getConfigIoForException
     */
    public function testTagWithTransportException($type, $verbose, $exceptionClass, $validTrace)
    {
        /* @var \PHPUnit_Framework_MockObject_MockObject $loader */
        $loader = $this->loader;
        $loader
            ->expects($this->any())
            ->method('load')
            ->will($this->throwException(new $exceptionClass('MESSAGE')));

        $this->lazyLoader = $this->createLazyLoaderConfigured($type, $verbose);
        $package = $this->lazyLoader->load($this->lazyPackage);

        $this->assertFalse($package);

        $filename = $this->assetType->getFilename();
        $validOutput = array('');

        if ($verbose) {
            $validOutput = array(
                'Reading ' . $filename . ' of <info>' . $this->lazyPackage->getName() . '</info> (<comment>' . $this->lazyPackage->getPrettyVersion() . '</comment>)',
                'Importing empty ' . $type . ' ' . $this->lazyPackage->getPrettyVersion() . ' (' . $this->lazyPackage->getVersion() . ')',
                $validTrace,
                '',
            );
        }
        $this->assertSame($validOutput, $this->io->getTraces());

        $packageCache = $this->lazyLoader->load($this->lazyPackage);
        $this->assertFalse($packageCache);
        $this->assertSame($validOutput, $this->io->getTraces());
    }
Пример #2
0
    public function testExecute()
    {
        $this->directoryList->expects($this->atLeastOnce())->method('getPath')->willReturn(null);
        $this->objectManager->expects($this->once())
            ->method('get')
            ->with('Magento\Framework\App\Cache')
            ->willReturn($this->cacheMock);
        $this->cacheMock->expects($this->once())->method('clean');
        $writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface');
        $writeDirectory->expects($this->atLeastOnce())->method('delete');
        $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory);

        $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
        $progressBar = $this->getMockBuilder(
            'Symfony\Component\Console\Helper\ProgressBar'
        )
            ->disableOriginalConstructor()
            ->getMock();

        $this->objectManager->expects($this->once())->method('configure');
        $this->objectManager
            ->expects($this->once())
            ->method('create')
            ->with('Symfony\Component\Console\Helper\ProgressBar')
            ->willReturn($progressBar);
        $this->manager->expects($this->exactly(7))->method('addOperation');
        $this->manager->expects($this->once())->method('process');
        $tester = new CommandTester($this->command);
        $tester->execute([]);
        $this->assertContains(
            'Generated code and dependency injection configuration successfully.',
            explode(PHP_EOL, $tester->getDisplay())
        );
        $this->assertSame(DiCompileCommand::NAME, $this->command->getName());
    }
Пример #3
0
 /**
  * @covers \Magento\Framework\Data\Form\Element\AbstractElement::getName()
  */
 public function testGetNameWithSuffix()
 {
     $returnValue = 'some_value';
     $formMock = $this->getMock('Magento\\Framework\\Data\\Form\\AbstractForm', ['getFieldNameSuffix', 'addSuffixToName'], [], '', false);
     $formMock->expects($this->once())->method('getFieldNameSuffix')->will($this->returnValue(true));
     $formMock->expects($this->once())->method('addSuffixToName')->will($this->returnValue($returnValue));
     $this->_model->setForm($formMock);
     $this->assertEquals($returnValue, $this->_model->getName());
 }
 public function testCreateWithCustomIgnoreSection()
 {
     $extra = array('custom-ignore-files' => array('foo-asset/foo' => array('PATTERN'), 'foo-asset/bar' => array()));
     $this->rootPackage->expects($this->any())->method('getExtra')->will($this->returnValue($extra));
     $manager = IgnoreFactory::create($this->composer, $this->package, null, 'custom-ignore-files');
     $this->assertTrue($manager->isEnabled());
     $this->assertTrue($manager->hasPattern());
     $this->validateInstallDir($manager, $this->config->get('vendor-dir') . '/' . $this->package->getName());
 }
 /**
  * @covers ::getType
  */
 public function testGetType()
 {
     // Ensure that FieldConfig::getType() is not delegated to
     // FieldStorage.
     $this->entityManager->expects($this->never())->method('getFieldStorageDefinitions');
     $this->fieldStorage->expects($this->never())->method('getType');
     $field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field'), $this->entityTypeId);
     $this->assertEquals('test_field', $field->getType());
 }
 /**
  * @covers ::toArray()
  */
 public function testToArray()
 {
     $values = array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle');
     $instance = new FieldInstanceConfig($values, $this->entityTypeId);
     $expected = array('id' => 'test_entity_type.test_bundle.field_test', 'uuid' => NULL, 'status' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'field_name' => 'field_test', 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'label' => '', 'description' => '', 'required' => FALSE, 'default_value' => array(), 'default_value_function' => '', 'settings' => array(), 'dependencies' => array(), 'field_type' => 'test_field');
     $this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
     $this->entityType->expects($this->once())->method('getKey')->with('id')->will($this->returnValue('id'));
     $this->typedConfigManager->expects($this->once())->method('getDefinition')->will($this->returnValue(array('mapping' => array_fill_keys(array_keys($expected), ''))));
     $export = $instance->toArray();
     $this->assertEquals($expected, $export);
 }
Пример #7
0
 public function testGetPackageCopy()
 {
     $this->initJob([], $this->atLeastOnce());
     $this->package->expects($this->atLeastOnce())->method('getName')->will($this->returnValue('foo/bar'));
     $this->package->expects($this->atLeastOnce())->method('getVersion')->will($this->returnValue('1.0.0'));
     $this->package->expects($this->atLeastOnce())->method('getPrettyVersion')->will($this->returnValue('1'));
     $this->package->expects($this->atLeastOnce())->method('getType')->will($this->returnValue('lib'));
     $copy = $this->job->getPackageCopy();
     // test
     $this->assertInstanceOf('\\Composer\\Package\\Package', $copy);
     $this->assertEquals($this->package->getName(), $copy->getName());
     $this->assertEquals($this->package->getVersion(), $copy->getVersion());
     $this->assertEquals($this->package->getPrettyVersion(), $copy->getPrettyVersion());
     $this->assertEquals($this->package->getType(), $copy->getType());
     $this->assertEquals($this->package->getExtra(), $copy->getExtra());
 }
 /**
  * Tests getName.
  */
 public function testGetName()
 {
     $result = $this->pagerExtension->getName();
     $this->assertNotEmpty($result);
 }
 /**
  * @covers ::setName
  * @covers ::getName
  */
 public function testGetName()
 {
     $name = $this->randomMachineName();
     $this->assertSame($this->sut, $this->sut->setName($name));
     $this->assertSame($name, $this->sut->getName());
 }
 public function testGetName()
 {
     $this->assertEquals('oro_typed_address', $this->type->getName());
 }
Пример #11
0
 public function testGetNameReturnsExtensionName()
 {
     $expected = 'Server Basics';
     $this->assertEquals($expected, $this->extension->getName());
 }
Пример #12
0
 /**
  * @param object|\PHPUnit_Framework_MockObject_MockObject $file
  * @param $filename
  *
  * @return array
  */
 private function mockDownloadData($file, $filename)
 {
     $download = ['preview' => $file->getContent(), 'mimetype' => $file->getMimeType()];
     if ($download) {
         if (is_null($filename)) {
             $filename = $file->getName();
         }
         $download['name'] = $filename;
     }
     return $download;
 }
 public function testBaseCommandClassIsCalled()
 {
     $this->assertEquals($this->commandName, $this->command->getName());
 }
 /**
  * @covers ::getName
  */
 public function testGetName()
 {
     $this->assertNull($this->entity->getName());
 }
Пример #15
0
 public function testGetName()
 {
     $this->assertEquals('oro_email_email_folder', $this->emailFolderType->getName());
 }
Пример #16
0
 public function testGetNameThrowsExceptionWhenNameUndefined()
 {
     $this->setExpectedException('Exception', 'Extension name has not been defined');
     $this->extension->getName();
 }
Пример #17
0
 /**
  * @test
  */
 public function setNameSetsName()
 {
     $this->service->setName('foo bar');
     $this->assertSame('foo bar', $this->service->getName());
 }