SimplenewsTestSubscriptionOutput.php in Simplenews 3.x
File
tests/src/Functional/SimplenewsTestSubscriptionOutput.php
View source
<?php
namespace Drupal\Tests\simplenews\Functional;
class SimplenewsTestSubscriptionOutput extends SimplenewsTestBase {
public function testSubscriptionVisiblity() {
\Drupal::service('entity_display.repository')
->getViewDisplay('user', 'user')
->setComponent('simplenews', [
'label' => 'hidden',
'type' => 'simplenews',
])
->save();
$admin_user = $this
->drupalCreateUser([
'administer users',
]);
$user = $this
->drupalCreateUser([
'access user profiles',
'subscribe to newsletters',
'access content',
]);
$this
->drupalLogin($admin_user);
$this
->drupalGet('user/' . $admin_user
->id());
$this
->assertLink('Manage subscriptions');
$this
->drupalLogout();
$this
->drupalLogin($user);
$this
->drupalGet('user/' . $admin_user
->id());
$this
->assertNoLink('Manage subscriptions');
$this
->drupalGet('user/' . $user
->id());
$this
->assertLink('Manage subscriptions');
$this
->drupalLogout();
$this
->drupalGet('user/' . $admin_user
->id());
$this
->assertNoLink('Manage subscriptions');
$this
->drupalGet('user/' . $user
->id());
$this
->assertNoLink('Manage subscriptions');
}
}