public function PageContextTest::setUp in Acquia Lift Connector 8.3
Same name and namespace in other branches
- 8.4 tests/src/Unit/Service/Context/PageContextTest.php \Drupal\Tests\acquia_lift\Unit\Service\Context\PageContextTest::setUp()
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Service/ Context/ PageContextTest.php, line 100
Class
- PageContextTest
- PageContextTest Test.
Namespace
Drupal\Tests\acquia_lift\Unit\Service\ContextCode
public function setUp() {
parent::setUp();
// Get config factory mock
$this->configFactory = $this
->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
// Get settings mock
$this->settings = $this
->getMockBuilder('Drupal\\Core\\Config\\ImmutableConfig')
->disableOriginalConstructor()
->getMock();
// Get entity manager mock
$this->entityTypeManager = $this
->getMock('Drupal\\Core\\Entity\\EntityTypeManagerInterface');
// Get taxonomy term mock
$this->taxonomyTermStorage = $this
->getMock('Drupal\\taxonomy\\TermStorageInterface');
// Get request class mocks
$this->requestStack = $this
->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
$this->request = $this
->getMock('Symfony\\Component\\HttpFoundation\\Request');
$this->requestParameterBag = $this
->getMock('Symfony\\Component\\HttpFoundation\\ParameterBag');
// Get route mocks
$this->routeMatch = $this
->getMock('Drupal\\Core\\Routing\\RouteMatchInterface');
$this->route = $this
->getMockBuilder('Symfony\\Component\\Routing\\Route')
->disableOriginalConstructor()
->getMock();
// Get title resolver mock
$this->titleResolver = $this
->getMock('Drupal\\Core\\Controller\\TitleResolverInterface');
// Get language mock
$this->language = $this
->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
// Get language object mock
$this->languageInterface = $this
->getMock('Drupal\\Core\\Language\\LanguageInterface');
// Mock method and return val
$this->languageInterface
->expects($this
->any())
->method('getId')
->willReturn('fr');
// Mock config factory
$this->configFactory
->expects($this
->once())
->method('get')
->with('acquia_lift.settings')
->willReturn($this->settings);
// Mock settings credential method and return val
$this->settings
->expects($this
->at(0))
->method('get')
->with('credential')
->willReturn($this
->getValidCredentialSettings());
// Mock settings field_mapping method and return val
$this->settings
->expects($this
->at(1))
->method('get')
->with('field_mappings')
->willReturn($this
->getValidFieldMappingsSettings());
// Mock settings udf_person_mappings method and return val
$this->settings
->expects($this
->at(2))
->method('get')
->with('udf_person_mappings')
->willReturn($this
->getValidUdfPersonMappingsSettings());
// Mock settings udf_touch_mappings method and return val
$this->settings
->expects($this
->at(3))
->method('get')
->with('udf_touch_mappings')
->willReturn($this
->getValidUdfTouchMappingsSettings());
// Mock settings udf_event_mappings method and return val
$this->settings
->expects($this
->at(4))
->method('get')
->with('udf_event_mappings')
->willReturn($this
->getValidUdfEventMappingsSettings());
// Mock settings advanced method and return val
$this->settings
->expects($this
->at(5))
->method('get')
->with('advanced')
->willReturn($this
->getValidAdvancedSettings());
// Mock entity type manager getStorage method and return val
$this->entityTypeManager
->expects($this
->once())
->method('getStorage')
->with('taxonomy_term')
->willReturn($this->taxonomyTermStorage);
// Mock request stack's getCurrentRequest method and return val
$this->requestStack
->expects($this
->once())
->method('getCurrentRequest')
->willReturn($this->request);
// Set param bag
$this->request->attributes = $this->requestParameterBag;
// Mock routeMatch getRouteObject method and return val
$this->routeMatch
->expects($this
->once())
->method('getRouteObject')
->willReturn($this->route);
}