TestClass example

/** * @coversDefaultClass \Drupal\KernelTests\AssertContentTrait * @group Test */
class AssertContentTraitTest extends UnitTestCase {

  /** * @covers ::getTextContent */
  public function testGetTextContent() {
    $test = new TestClass();
    $raw_content = <<<EOT <Head> <style> @import url("foo.css"); </style> </head> <body> bar </body> EOT;
    
protected function setUp(): void
    {
        $this->propertyAccessor = new PropertyAccessor();
    }

    public static function getPathsWithMissingProperty()
    {
        return [
            [(object) ['firstName' => 'Bernhard'], 'lastName'],
            [(object) ['property' => (object) ['firstName' => 'Bernhard']], 'property.lastName'],
            [['index' => (object) ['firstName' => 'Bernhard']], '[index].lastName'],
            [new TestClass('Bernhard'), 'protectedProperty'],
            [new TestClass('Bernhard'), 'privateProperty'],
            [new TestClass('Bernhard'), 'protectedAccessor'],
            [new TestClass('Bernhard'), 'protectedIsAccessor'],
            [new TestClass('Bernhard'), 'protectedHasAccessor'],
            [new TestClass('Bernhard'), 'privateAccessor'],
            [new TestClass('Bernhard'), 'privateIsAccessor'],
            [new TestClass('Bernhard'), 'privateHasAccessor'],

            // Properties are not camelized             [new TestClass('Bernhard'), 'public_property'],
        ];
    }
        ['the_revision_id', 'the_other_revision_id'],
      ],
    ];
  }

  /** * @covers ::getInlineBlockComponents * * @dataProvider providerSectionsWithInlineComponents */
  public function testGetInlineBlockComponents($sections$expected_components) {
    $test_class = new TestClass();
    $this->assertSame($expected_components$test_class->getInlineBlockComponents($sections));
  }

  /** * @covers ::getInlineBlockRevisionIdsInSections * * @dataProvider providerSectionsWithInlineComponents */
  public function testGetInlineBlockRevisionIdsInSections($sections$components$expected_revision_ids) {
    $test_class = new TestClass();
    $this->assertSame($expected_revision_ids$test_class->getInlineBlockRevisionIdsInSections($sections));
  }

  public function testGetFormClass(PluginWithFormsInterface $block_plugin$operation$expected_class) {
    $this->assertSame($expected_class$block_plugin->getFormClass($operation));
    $this->assertSame($expected_class !== NULL, $block_plugin->hasFormClass($operation));
  }

  /** * @return array */
  public function providerGetFormClass() {
    $block_plugin_without_forms = new TestClass([], 'block_plugin_without_forms', [
      'provider' => 'block_test',
    ]);
    // A block plugin that has a form defined for the 'poke' operation.     $block_plugin_with_forms = new TestClass([], 'block_plugin_with_forms', [
      'provider' => 'block_test',
      'forms' => [
        'poke' => static::class,
      ],
    ]);
    return [
      'block plugin without forms, "configure" operation' => [$block_plugin_without_forms, 'configure', TestClass::class],
      
$this->expectException(\RuntimeException::class);
    $this->expectExceptionMessage('requires a value for the "$foo" argument.');
    $resolver->getArguments($callable);
  }

  /** * Provides test data to testHandleUnresolvedArgument(). */
  public function providerTestHandleUnresolvedArgument() {
    $data = [];
    $data[] = [function D$foo) {}];
    $data[] = [[new TestClass(), 'access']];
    $data[] = ['Drupal\Tests\Component\Utility\test_access_arguments_resolver_access'];
    return $data;
  }

}

/** * Provides a test class. */
class TestClass {

  
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\TestUnserializeClass;
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\TestWakeupClass;

class LazyProxyTraitTest extends TestCase
{
    public function testGetter()
    {
        $initCounter = 0;
        $proxy = $this->createLazyProxy(TestClass::classfunction D) use (&$initCounter) {
            ++$initCounter;

            return new TestClass((object) ['hello' => 'world']);
        });

        $this->assertInstanceOf(TestClass::class$proxy);
        $this->assertSame(0, $initCounter);
        $this->assertFalse($proxy->isLazyObjectInitialized());

        $dep1 = $proxy->getDep();
        $this->assertTrue($proxy->isLazyObjectInitialized());
        $this->assertSame(1, $initCounter);

        $this->assertTrue($proxy->resetLazyObject());
        
Home | Imprint | This part of the site doesn't use cookies.