Skip to content

Commit

Permalink
[apigee#321] Add a test for user create with first_name and last_name…
Browse files Browse the repository at this point in the history
… fields
  • Loading branch information
shadcn committed Jan 29, 2020
1 parent 13ba194 commit 7ea3271
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/src/Kernel/UserCreateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* Copyright 2020 Google Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

namespace Drupal\Tests\apigee_edge\Kernel;

use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;

/**
* Test create operations for User entity type.
*
* @group apigee_edge
* @group apigee_edge_kernel
*/
class UserCreateTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'user',
'system',
'apigee_edge',
'key',
];

/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();

$this->installSchema('system', ['sequences']);
$this->installSchema('user', ['users_data']);
$this->installEntitySchema('user');
}

/**
* Test user create.
*/
public function testUserCreate() {
$user = User::create([
'mail' => $this->randomMachineName() . '@example.com',
'name' => $this->randomMachineName(),
'first_name' => $this->randomMachineName(64),
'last_name' => $this->randomMachineName(64),
]);

$this->assertEquals(SAVED_NEW, $user->save());
}

}

0 comments on commit 7ea3271

Please sign in to comment.