You are here

public function JsonLogDataTest::testCanSetUsernameAndUidBasedOnAccount in JSONlog 8.2

Same name and namespace in other branches
  1. 8 tests/src/Unit/JsonLogDataTest.php \Drupal\Tests\jsonlog\Unit\JsonLogDataTest::testCanSetUsernameAndUidBasedOnAccount()
  2. 3.x tests/src/Unit/JsonLogDataTest.php \Drupal\Tests\jsonlog\Unit\JsonLogDataTest::testCanSetUsernameAndUidBasedOnAccount()

File

tests/src/Unit/JsonLogDataTest.php, line 156

Class

JsonLogDataTest
Unit tests for JsonLogData class

Namespace

Drupal\Tests\jsonlog\Unit

Code

public function testCanSetUsernameAndUidBasedOnAccount() {
  $accountMock = $this
    ->createMock('Drupal\\Core\\Session\\AccountProxyInterface');
  $accountMock
    ->expects($this
    ->exactly(1))
    ->method('getAccountName')
    ->willReturn('dummy');
  $accountMock
    ->expects($this
    ->exactly(1))
    ->method('id')
    ->willReturn(1234);
  $this->data = new JsonLogData('test_site_id', 'test_canonical');

  /** @var \Drupal\Core\Session\AccountProxyInterface $accountMock */
  $this->data
    ->setAccount($accountMock);
  $this
    ->assertEquals('dummy', $this->data
    ->getUsername(), 'Username set.');
  $this
    ->assertEquals(1234, $this->data
    ->getUid(), 'UID set.');
}