tests/UsersTest.php
/**
     * @testdox The first user to log in is made an Administrator, and can edit users' roles.
     */
@testdox The first user to log in is made an Administrator, and can edit users' roles.
@testdox The first user to log in is made an Administrator and can edit users ' roles .
public function firstUser()
    {
        $this->assertEquals(0, User::count());
        $user1 = new User();
        $user1->username = 'User One';
        $user1->save();
        $this->assertTrue($user1->hasRole('Administrator'));
        $this->assertTrue($user1->isAdmin());
        $this->assertEquals(1, User::count());
        $user1->username = 'User 1';
        $user1->save();
        $this->assertTrue($user1->isAdmin());
        $this->assertEquals(1, User::count());
        $user2 = new User();
        $user2->username = 'User Two';
        $user2->save();
        $this->assertFalse($user2->hasRole('Administrator'));
        $this->assertFalse($user2->isAdmin());
        $this->assertTrue($user1->isAdmin());
        $this->assertEquals(2, User::count());
    }
public function firstUser ( ) { $ this -> assertEquals ( 0 , User :: count ( ) ) ; $ user1 = new User ( ) ; $ user1 -> username = 'User One' ; $ user1 -> save ( ) ; $ this -> assertTrue ( $ user1 -> hasRole ( 'Administrator' ) ) ; $ this -> assertTrue ( $ user1 -> isAdmin ( ) ) ; $ this -> assertEquals ( 1 , User :: count ( ) ) ; $ user1 -> username = 'User 1' ; $ user1 -> save ( ) ; $ this -> assertTrue ( $ user1 -> isAdmin ( ) ) ; $ this -> assertEquals ( 1 , User :: count ( ) ) ; $ user2 = new User ( ) ; $ user2 -> username = 'User Two' ; $ user2 -> save ( ) ; $ this -> assertFalse ( $ user2 -> hasRole ( 'Administrator' ) ) ; $ this -> assertFalse ( $ user2 -> isAdmin ( ) ) ; $ this -> assertTrue ( $ user1 -> isAdmin ( ) ) ; $ this -> assertEquals ( 2 , User :: count ( ) ) ; }
@testdox The first user to log in is made an Administrator, and can edit users' roles.
@testdox The first user to log in is made an Administrator and can edit users ' roles .
// Start with 0 users. // Save a first user, and they should be made an admin. // Check that resaving the first user doesn't break this (like it was doing). // Save a second user, and they shouldn't be an admin.