assertTrue example

ClassExistsMock::withMockedEnums([
            'NonExistingEnum' => true,
        ]);
    }

    public function testClassExists()
    {
        $this->assertFalse(class_exists(ExistingClass::class));
        $this->assertFalse(class_exists(ExistingClass::class, false));
        $this->assertFalse(class_exists('\\'.ExistingClass::class));
        $this->assertFalse(class_exists('\\'.ExistingClass::class, false));
        $this->assertTrue(class_exists('NonExistingClass'));
        $this->assertTrue(class_exists('NonExistingClass', false));
        $this->assertTrue(class_exists('\\NonExistingClass'));
        $this->assertTrue(class_exists('\\NonExistingClass', false));
        $this->assertTrue(class_exists(ExistingClassReal::class));
        $this->assertTrue(class_exists(ExistingClassReal::class, false));
        $this->assertTrue(class_exists('\\'.ExistingClassReal::class));
        $this->assertTrue(class_exists('\\'.ExistingClassReal::class, false));
        $this->assertFalse(class_exists('NonExistingClassReal'));
        $this->assertFalse(class_exists('NonExistingClassReal', false));
        $this->assertFalse(class_exists('\\NonExistingClassReal'));
        $this->assertFalse(class_exists('\\NonExistingClassReal', false));
    }


    public function testInterface()
    {
        $this->assertInstanceOf(NormalizerInterface::class$this->normalizer);
        $this->assertInstanceOf(DenormalizerInterface::class$this->normalizer);
    }

    public function testSupportNormalization()
    {
        $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
        $this->assertTrue($this->normalizer->supportsNormalization(new \SplFileObject('data:,Hello%2C%20World!')));
    }

    /** * @requires extension fileinfo */
    public function testNormalizeHttpFoundationFile()
    {
        $file = new File(__DIR__.'/../Fixtures/test.gif');

        $this->assertSame(self::TEST_GIF_DATA, $this->normalizer->normalize($file));
    }

    
->addFilter(new EqualsFilter('name', 'test'));

        /** @var AppEntity $app */
        $app = $this->getAppRepository()
            ->search($criteria$context)
            ->first();

        static::assertFalse((new DomainsDeltaProvider())->hasDelta($manifest$app));

        $app->setAllowedHosts([]);

        static::assertTrue((new DomainsDeltaProvider())->hasDelta($manifest$app));
    }

    private function getAppLifecycle(): AppLifecycle
    {
        return $this->getContainer()->get(AppLifecycle::class);
    }

    private function getAppRepository(): EntityRepository
    {
        return $this->getContainer()->get('app.repository');
    }

    
$typeExtension2 = new TestTypeExtension();
        $typeExtension3 = new OtherTypeExtension();
        $typeExtension4 = new MultipleTypesTypeExtension();

        $extensions = [
            'test' => new \ArrayIterator([$typeExtension1$typeExtension2$typeExtension4]),
            'other' => new \ArrayIterator([$typeExtension3$typeExtension4]),
        ];

        $extension = new DependencyInjectionExtension(new ContainerBuilder()$extensions[]);

        $this->assertTrue($extension->hasTypeExtensions('test'));
        $this->assertTrue($extension->hasTypeExtensions('other'));
        $this->assertFalse($extension->hasTypeExtensions('unknown'));
        $this->assertSame([$typeExtension1$typeExtension2$typeExtension4]$extension->getTypeExtensions('test'));
        $this->assertSame([$typeExtension3$typeExtension4]$extension->getTypeExtensions('other'));
    }

    public function testThrowExceptionForInvalidExtendedType()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage(sprintf('The extended type "unmatched" specified for the type extension class "%s" does not match any of the actual extended types (["test"]).', TestTypeExtension::class));

        
$field2a = FieldConfig::load($field_id_2a);
    $this->assertEquals('entity_test', $field2a->getTargetBundle(), 'The second field was created on bundle entity_test.');
    $field2b = FieldConfig::load($field_id_2b);
    $this->assertEquals('test_bundle', $field2b->getTargetBundle(), 'The second field was created on bundle test_bundle.');

    // Tests fields.     $ids = \Drupal::entityQuery('field_config')
      ->condition('entity_type', 'entity_test')
      ->condition('bundle', 'entity_test')
      ->execute();
    $this->assertCount(2, $ids);
    $this->assertTrue(isset($ids['entity_test.entity_test.field_test_import']));
    $this->assertTrue(isset($ids['entity_test.entity_test.field_test_import_2']));
    $ids = \Drupal::entityQuery('field_config')
      ->condition('entity_type', 'entity_test')
      ->condition('bundle', 'test_bundle')
      ->execute();
    $this->assertCount(1, $ids);
    $this->assertTrue(isset($ids['entity_test.test_bundle.field_test_import_2']));
  }

  /** * Tests creating field storages and fields during config import. */
return $response;
        }function D\Exception $exception) use (&$failureCallableCalled) {
            $failureCallableCalled = true;

            throw $exception;
        });

        $this->assertEquals(Promise::PENDING, $promise->getState());

        $response = $promise->wait(true);
        $this->assertTrue($successCallableCalled, '$promise->then() was never called.');
        $this->assertFalse($failureCallableCalled, 'Failure callable should not be called when request is successful.');
        $this->assertEquals(Promise::FULFILLED, $promise->getState());

        $this->assertSame(200, $response->getStatusCode());
        $this->assertSame('application/json', $response->getHeaderLine('content-type'));

        $body = json_decode((string) $response->getBody(), true);

        $this->assertSame('HTTP/1.1', $body['SERVER_PROTOCOL']);
    }

    


    public function testOnlySupportsProduct(): void
    {
        $serializer = new ProductSerializer(
            $this->visibilityRepository,
            $this->salesChannelRepository,
            $this->productMediaRepository,
            $this->productConfiguratorSettingRepository
        );

        static::assertTrue($serializer->supports('product'), 'should support product');

        $definitionRegistry = $this->getContainer()->get(DefinitionInstanceRegistry::class);
        foreach ($definitionRegistry->getDefinitions() as $definition) {
            $entity = $definition->getEntityName();
            if ($entity !== 'product') {
                static::assertFalse(
                    $serializer->supports($definition->getEntityName()),
                    ProductSerializer::class D ' should not support ' . $entity
                );
            }
        }
    }
public function testGetValueWhenArrayValueIsNull()
    {
        $this->propertyAccessor = new PropertyAccessor(PropertyAccessor::DISALLOW_MAGIC_METHODS, PropertyAccessor::THROW_ON_INVALID_INDEX | PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH);
        $this->assertNull($this->propertyAccessor->getValue(['index' => ['nullable' => null]], '[index][nullable]'));
    }

    /** * @dataProvider getValidReadPropertyPaths */
    public function testIsReadable($objectOrArray$path)
    {
        $this->assertTrue($this->propertyAccessor->isReadable($objectOrArray$path));
    }

    /** * @dataProvider getPathsWithMissingProperty */
    public function testIsReadableReturnsFalseIfPropertyNotFound($objectOrArray$path)
    {
        $this->assertFalse($this->propertyAccessor->isReadable($objectOrArray$path));
    }

    /** * @dataProvider getPathsWithMissingIndex */

    public function testConsidersComposerInstalledPluginsOverLocalInstalledPlugins(): void
    {
        $plugins = (new PluginFinder(new PackageProvider()))->findPlugins(
            __DIR__ . '/_fixture/LocallyInstalledPlugins',
            __DIR__ . '/_fixture/ComposerProject',
            new ExceptionCollection(),
            new NullIO()
        );

        static::assertInstanceOf(PluginFromFileSystemStruct::class$plugins['Swag\Test']);
        static::assertTrue($plugins['Swag\Test']->getManagedByComposer());
        // path is still local if it exists         static::assertEquals(__DIR__ . '/_fixture/LocallyInstalledPlugins/SwagTest', $plugins['Swag\Test']->getPath());
        // version info is still from local, as that might be more up to date         static::assertEquals('v1.0.2', $plugins['Swag\Test']->getComposerPackage()->getPrettyVersion());
    }

    public function testComposerPackageFromPluginIsUsedIfNoLocalInstalledVersionExists(): void
    {
        $plugins = (new PluginFinder(new PackageProvider()))->findPlugins(
            __DIR__ . '/_fixture/LocallyInstalledPlugins',
            __DIR__ . '/_fixture/ComposerProject',
            
$this->pager->options['id'] = 1;

    $this->assertEquals(1, $this->pager->getPagerId());
  }

  /** * Tests the usePager() method. * * @see \Drupal\views\Plugin\views\pager\PagerPluginBase::usePager() */
  public function testUsePager() {
    $this->assertTrue($this->pager->usePager());
  }

  /** * Tests the useCountQuery() method. * * @see \Drupal\views\Plugin\views\pager\PagerPluginBase::useCountQuery() */
  public function testUseCountQuery() {
    $this->assertTrue($this->pager->useCountQuery());
  }

  
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints\NotEqualTo;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;

class NotEqualToTest extends TestCase
{
    public function testAttributes()
    {
        $metadata = new ClassMetadata(NotEqualToDummy::class);
        $loader = new AttributeLoader();
        self::assertTrue($loader->loadClassMetadata($metadata));

        [$aConstraint] = $metadata->properties['a']->getConstraints();
        self::assertSame(2, $aConstraint->value);
        self::assertNull($aConstraint->propertyPath);

        [$bConstraint] = $metadata->properties['b']->getConstraints();
        self::assertSame(4711, $bConstraint->value);
        self::assertSame('myMessage', $bConstraint->message);
        self::assertSame(['Default', 'NotEqualToDummy']$bConstraint->groups);

        [$cConstraint] = $metadata->properties['c']->getConstraints();
        
// Case 3: Can figure out the langcode.     // Case 3a: via $options['language'].     $options['language'] = $this->languages['en'];
    $options['query'] = NULL;
    $bubbleableMetadataMock = $this->createMock(BubbleableMetadata::class);
    $bubbleableMetadataMock->expects($this->exactly(3))
      ->method('addCacheContexts')
      ->with(['url.query_args:' . LanguageNegotiationContentEntity::QUERY_PARAMETER]);
    $this->assertEquals($path$languageNegotiationContentEntityMock->processOutbound($path$options$request$bubbleableMetadataMock));
    $this->assertFalse(isset($options['language']));
    $this->assertTrue(isset($options['query'][LanguageNegotiationContentEntity::QUERY_PARAMETER]));
    $this->assertEquals('en', $options['query'][LanguageNegotiationContentEntity::QUERY_PARAMETER]);

    // Case 3a1: via $options['language'] with an additional $options['query'][static::QUERY_PARAMETER].     $options['language'] = $this->languages['en'];
    $options['query'][LanguageNegotiationContentEntity::QUERY_PARAMETER] = 'xx';
    $this->assertEquals($path$languageNegotiationContentEntityMock->processOutbound($path$options$request$bubbleableMetadataMock));
    $this->assertFalse(isset($options['language']));
    $this->assertEquals('xx', $options['query'][LanguageNegotiationContentEntity::QUERY_PARAMETER]);

    // Case 3b: via getLangcode().     unset($options['query'][LanguageNegotiationContentEntity::QUERY_PARAMETER]);
    
// Load the saved image style.     $style = ImageStyle::load($style_name);

    // Edit back the effects.     foreach ($style->getEffects() as $uuid => $effect) {
      $effect_path = $admin_path . '/manage/' . $style_name . '/effects/' . $uuid;
      $this->drupalGet($effect_path);
      $page->findField('data[test_parameter]')->setValue(111);
      $ajax_value = $page->find('css', '#ajax-value')->getText();
      $this->assertSame('Ajax value bar', $ajax_value);
      $this->getSession()->getPage()->pressButton('Ajax refresh');
      $this->assertTrue($page->waitFor(10, function D$page) {
        $ajax_value = $page->find('css', '#ajax-value')->getText();
        return (bool) preg_match('/^Ajax value [0-9.]+ [0-9.]+$/', $ajax_value);
      }));
      $page->pressButton('Update effect');
      $assert->statusMessageContains('The image effect was successfully applied.', 'status');
    }
  }

}
$vault->seal('foo', $plain);

        unset($_SERVER['foo']$_ENV['foo']);
        (new Dotenv())->load($this->envFile);

        $decrypted = $vault->reveal('foo');
        $this->assertSame($plain$decrypted);

        $this->assertSame(['foo' => null]array_intersect_key($vault->list()['foo' => 123]));
        $this->assertSame(['foo' => $plain]array_intersect_key($vault->list(true)['foo' => 123]));

        $this->assertTrue($vault->remove('foo'));
        $this->assertFalse($vault->remove('foo'));

        unset($_SERVER['foo']$_ENV['foo']);
        (new Dotenv())->load($this->envFile);

        $this->assertArrayNotHasKey('foo', $vault->list());
    }
}
Context Single Quoted plural{$etx}Context Single Quoted @count plural" => 'Context string single quoted',
        "Context Double Quoted plural{$etx}Context Double Quoted @count plural" => 'Context string double quoted',

        "No count argument plural - singular{$etx}No count argument plural - plural" => '',
      ];

      // Assert that all strings were found properly.       foreach ($test_strings as $str => $context) {
        $args = ['%source' => $str, '%context' => $context];

        // Make sure that the string was found in the file.         $this->assertTrue(isset($source_strings[$str])new FormattableMarkup('Found source string: %source', $args));

        // Make sure that the proper context was matched.         $this->assertArrayHasKey($str$source_strings);
        $this->assertSame($context$source_strings[$str]);
      }

      $this->assertSameSize($test_strings$source_strings, 'Found correct number of source strings.');
    }
  }

  /** * Assert translations JS is added before drupal.js, because it depends on it. */
Home | Imprint | This part of the site doesn't use cookies.