Best Atoum code snippet using configurable.testClass
LayoutEntityHelperTraitTest.php
Source:LayoutEntityHelperTraitTest.php
1<?php2namespace Drupal\Tests\layout_builder\Unit;3use Drupal\Component\Plugin\ConfigurablePluginInterface;4use Drupal\Component\Plugin\DerivativeInspectionInterface;5use Drupal\Component\Plugin\PluginInspectionInterface;6use Drupal\Core\Entity\EntityInterface;7use Drupal\Core\Entity\FieldableEntityInterface;8use Drupal\layout_builder\LayoutEntityHelperTrait;9use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage;10use Drupal\layout_builder\Section;11use Drupal\layout_builder\SectionComponent;12use Drupal\Tests\UnitTestCase;13/**14 * @coversDefaultClass \Drupal\layout_builder\LayoutEntityHelperTrait15 *16 * @group layout_builder17 */18class LayoutEntityHelperTraitTest extends UnitTestCase {19 /**20 * @covers ::isEntityUsingFieldOverride21 *22 * @dataProvider providerTestIsEntityUsingFieldOverride23 *24 * @expectedDeprecation \Drupal\layout_builder\LayoutEntityHelperTrait::isEntityUsingFieldOverride() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Internal storage of overrides may change so the existence of the field does not necessarily guarantee an overridable entity. See https://www.drupal.org/node/3030609.25 *26 * @group legacy27 */28 public function testIsEntityUsingFieldOverride(EntityInterface $entity, $expected) {29 $test_class = new TestClass();30 $this->assertSame($expected, $test_class->isEntityUsingFieldOverride($entity));31 }32 /**33 * Dataprovider for testIsEntityUsingFieldOverride().34 */35 public function providerTestIsEntityUsingFieldOverride() {36 $data['non fieldable entity'] = [37 $this->prophesize(EntityInterface::class)->reveal(),38 FALSE,39 ];40 $fieldable_entity = $this->prophesize(FieldableEntityInterface::class);41 $fieldable_entity->hasField(OverridesSectionStorage::FIELD_NAME)->willReturn(FALSE);42 $data['fieldable entity without layout field'] = [43 $fieldable_entity->reveal(),44 FALSE,45 ];46 $entity_using_field = $this->prophesize(FieldableEntityInterface::class);47 $entity_using_field->hasField(OverridesSectionStorage::FIELD_NAME)->willReturn(TRUE);48 $data['fieldable entity with layout field'] = [49 $entity_using_field->reveal(),50 TRUE,51 ];52 return $data;53 }54 /**55 * Dataprovider method for tests that need sections with inline blocks.56 */57 public function providerSectionsWithInlineComponents() {58 $components = [];59 // Ensure a non-derivative component is not returned.60 $non_derivative_component = $this->prophesize(SectionComponent::class);61 $non_derivative_component->getPlugin()->willReturn($this->prophesize(PluginInspectionInterface::class)->reveal());62 $components[] = $non_derivative_component->reveal();63 // Ensure a derivative component with a different base Id is not returned.64 $derivative_non_inline_component = $this->prophesize(SectionComponent::class);65 $plugin = $this->prophesize(DerivativeInspectionInterface::class);66 $plugin->getBaseId()->willReturn('some_other_base_id_which_we_do_not_care_about_but_it_is_nothing_personal');67 $derivative_non_inline_component->getPlugin()->willReturn($plugin);68 $components[] = $derivative_non_inline_component->reveal();69 // Ensure that inline block component is returned.70 $inline_component = $this->prophesize(SectionComponent::class);71 $inline_plugin = $this->prophesize(DerivativeInspectionInterface::class)->willImplement(ConfigurablePluginInterface::class);72 $inline_plugin->getBaseId()->willReturn('inline_block');73 $inline_plugin->getConfiguration()->willReturn(['block_revision_id' => 'the_revision_id']);74 $inline_component->getPlugin()->willReturn($inline_plugin->reveal());75 $inline_component = $inline_component->reveal();76 $components[] = $inline_component;77 // Ensure that inline block component without revision is returned.78 $inline_component_without_revision_id = $this->prophesize(SectionComponent::class);79 $inline_plugin_without_revision_id = $this->prophesize(DerivativeInspectionInterface::class)->willImplement(ConfigurablePluginInterface::class);80 $inline_plugin_without_revision_id->getBaseId()->willReturn('inline_block');81 $inline_plugin_without_revision_id->getConfiguration()->willReturn(['other_key' => 'other_value']);82 $inline_component_without_revision_id->getPlugin()->willReturn($inline_plugin_without_revision_id->reveal());83 $inline_component_without_revision_id = $inline_component_without_revision_id->reveal();84 $components[] = $inline_component_without_revision_id;85 $section = $this->prophesize(Section::class);86 $section->getComponents()->willReturn($components);87 $components = [];88 // Ensure that inline block components in all sections are returned.89 $inline_component2 = $this->prophesize(SectionComponent::class);90 $inline_plugin2 = $this->prophesize(DerivativeInspectionInterface::class)->willImplement(ConfigurablePluginInterface::class);91 $inline_plugin2->getBaseId()->willReturn('inline_block');92 $inline_plugin2->getConfiguration()->willReturn(['block_revision_id' => 'the_other_revision_id']);93 $inline_component2->getPlugin()->willReturn($inline_plugin2->reveal());94 $inline_component2 = $inline_component2->reveal();95 $components[] = $inline_component2;96 $section2 = $this->prophesize(Section::class);97 $section2->getComponents()->willReturn($components);98 return [99 [100 [$section->reveal(), $section2->reveal()],101 // getInlineBlockComponents() should return inline blocks even if they102 // have no revision Id.103 [104 $inline_component,105 $inline_component_without_revision_id,106 $inline_component2,107 ],108 // getInlineBlockRevisionIdsInSections should just the revision Ids.109 ['the_revision_id', 'the_other_revision_id'],110 ],111 ];112 }113 /**114 * @covers ::getInlineBlockComponents115 *116 * @dataProvider providerSectionsWithInlineComponents117 */118 public function testGetInlineBlockComponents($sections, $expected_components) {119 $test_class = new TestClass();120 $this->assertSame($expected_components, $test_class->getInlineBlockComponents($sections));121 }122 /**123 * @covers ::getInlineBlockRevisionIdsInSections124 *125 * @dataProvider providerSectionsWithInlineComponents126 */127 public function testGetInlineBlockRevisionIdsInSections($sections, $components, $expected_revision_ids) {128 $test_class = new TestClass();129 $this->assertSame($expected_revision_ids, $test_class->getInlineBlockRevisionIdsInSections($sections));130 }131}132/**133 * Test class using the trait.134 */135class TestClass {136 use LayoutEntityHelperTrait {137 isEntityUsingFieldOverride as public;138 getInlineBlockComponents as public;139 getInlineBlockRevisionIdsInSections as public;140 }141}...
ConfigCacheTest.php
Source:ConfigCacheTest.php
...26 unset($this->modelCacheProvider);27 }28 public function testPutConfigInCache()29 {30 $className = 'testClass';31 $scope = 'testScope';32 $configId = new EntityConfigId($scope, $className);33 $config = new Config($configId);34 $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider);35 $this->cacheProvider->expects($this->once())36 ->method('save')37 ->will($this->returnValue(true));38 $this->assertTrue($configCache->putConfigInCache($config));39 }40 public function testRemoveConfigFromCache()41 {42 $className = 'testClass';43 $scope = 'testScope';44 $configId = new EntityConfigId($scope, $className);45 $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider);46 $this->cacheProvider->expects($this->once())47 ->method('delete')48 ->will($this->returnValue(true));49 $this->assertTrue($configCache->removeConfigFromCache($configId));50 }51 public function testRemoveAll()52 {53 $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider);54 $this->cacheProvider->expects($this->once())55 ->method('deleteAll')56 ->will($this->returnValue(true));57 $this->assertTrue($configCache->removeAll());58 }59 public function testLoadConfigFromCache()60 {61 $className = 'testClass';62 $scope = 'testScope';63 $configId = new EntityConfigId($scope, $className);64 $config = new Config($configId);65 $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider);66 $this->cacheProvider->expects($this->once())67 ->method('fetch')68 ->will($this->returnValue($config));69 $this->assertEquals($config, $configCache->loadConfigFromCache($configId));70 }71 /**72 * @dataProvider setConfigurableProvider73 */74 public function testSetConfigurable($flag, $expectedCacheValue)75 {76 $className = 'testClass';77 $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider);78 $this->modelCacheProvider->expects($this->once())79 ->method('save')80 ->with($className, $this->identicalTo($expectedCacheValue))81 ->will($this->returnValue(true));82 $this->assertTrue($configCache->setConfigurable($flag, $className));83 }84 public function setConfigurableProvider()85 {86 return [87 [true, true],88 [false, null],89 ];90 }91 /**92 * @dataProvider getConfigurableProvider93 */94 public function testGetConfigurable($expectedFlag, $cachedValue)95 {96 $className = 'testClass';97 $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider);98 $this->modelCacheProvider->expects($this->once())99 ->method('fetch')100 ->with($className)101 ->will($this->returnValue($cachedValue));102 $this->assertTrue($expectedFlag === $configCache->getConfigurable($className));103 }104 public function getConfigurableProvider()105 {106 return [107 [true, true],108 [null, false],109 [false, null],110 ];...
testClass
Using AI Code Generation
1$testClass = new testClass();2$testClass->testMethod();3$testClass = new testClass();4$testClass->testMethod();5$testClass = new testClass();6$testClass->testMethod();7$testClass = new testClass();8$testClass->testMethod();9$testClass = new testClass();10$testClass->testMethod();11$testClass = new testClass();12$testClass->testMethod();13$testClass = new testClass();14$testClass->testMethod();15$testClass = new testClass();16$testClass->testMethod();17$testClass = new testClass();18$testClass->testMethod();19$testClass = new testClass();20$testClass->testMethod();21$testClass = new testClass();22$testClass->testMethod();23$testClass = new testClass();24$testClass->testMethod();25$testClass = new testClass();26$testClass->testMethod();27$testClass = new testClass();28$testClass->testMethod();29$testClass = new testClass();30$testClass->testMethod();
testClass
Using AI Code Generation
1$test = new testClass();2$test->testMethod();3$test = new testClass();4$test->testMethod();5$test = new testClass();6$test->testMethod();7$test = new testClass();8$test->testMethod();9$test = new testClass();10$test->testMethod();11$test = new testClass();12$test->testMethod();13$test = new testClass();14$test->testMethod();15$test = new testClass();16$test->testMethod();17$test = new testClass();18$test->testMethod();19$test = new testClass();20$test->testMethod();21$test = new testClass();22$test->testMethod();23$test = new testClass();24$test->testMethod();25$test = new testClass();26$test->testMethod();27$test = new testClass();28$test->testMethod();29$test = new testClass();30$test->testMethod();31$test = new testClass();32$test->testMethod();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with testClass on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!