<NME> UsernameValidationTest.php
<BEF> ADDFILE
<MSG> Merge pull request #3945 from notbakaneko/feature/namechange-auto-block-rules

Add additional username reservation checks
<DFF> @@ -0,0 +1,39 @@
+<?php
+
+/**
+ *    Copyright 2015-2018 ppy Pty. Ltd.
+ *
+ *    This file is part of osu!web. osu!web is distributed with the hope of
+ *    attracting more community contributions to the core ecosystem of osu!.
+ *
+ *    osu!web is free software: you can redistribute it and/or modify
+ *    it under the terms of the Affero GNU General Public License version 3
+ *    as published by the Free Software Foundation.
+ *
+ *    osu!web is distributed WITHOUT ANY WARRANTY; without even the implied
+ *    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *    See the GNU Affero General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Affero General Public License
+ *    along with osu!web.  If not, see <http://www.gnu.org/licenses/>.
+ */
+use App\Libraries\UsernameValidation;
+use App\Models\User;
+use Carbon\Carbon;
+
+// FIXME: need more tests
+class UsernameValidationTest extends TestCase
+{
+    public function testusersOfUsernameIncludesCurrentUsernameOwner()
+    {
+        $existing = factory(User::class)->create([
+            'username' => 'user1',
+            'username_clean' => 'user1',
+            'user_lastvisit' => Carbon::now()->subYear(),
+        ]);
+
+        $users = UsernameValidation::usersOfUsername('user1');
+        $this->assertCount(1, $users);
+        $this->assertTrue($existing->is($users->first()));
+    }
+}

{'addition_count': 39, 'commit_subject': 'Merge pull request #3945 from notbakaneko/feature/namechange-auto-block-rules', 'deletion_count': 0, 'file_extension': '.php', 'lang': 'php', 'license': 'agpl-3.0', 'repo_name': 'ppy/osu-web'}