<?php

use Notes\Domain\Entity\UserGroup\Owner;
use Notes\Domain\ValueObject\Permissions;
describe('Notes\\Domain\\Entity\\UserGroup\\Owner', function () {
    describe('->__construct()', function () {
        it('should return an Owner object', function () {
            $actual = new Owner();
            expect($actual)->to->be->instanceof('\\Notes\\Domain\\Entity\\UserGroup\\Owner');
        });
    });
    describe('->getPermissions()', function () {
        it('should return an array of permission constants', function () {
            $actual = new Owner();
            expect(is_array($actual->getPermissions()))->equal(true);
        });
    });
    describe('->hasPermission()', function () {
        it('should return an Owner object', function () {
            $actual = new Owner();
            expect($actual->hasPermission(Permissions::ADD_NOTE))->equal(true);
            expect($actual->hasPermission(Permissions::READ_NOTE))->equal(true);
            expect($actual->hasPermission(Permissions::MODIFY_NOTE))->equal(true);
            expect($actual->hasPermission(Permissions::DELETE_NOTE))->equal(true);
        });
    });
});
            $owner->addUser($bob);
            $owner->addUser($joe);
            $owner->addUser($blah);
            $expectArray = array($bob, $joe, $blah);
            $actualArray = $owner->getUsers();
            expect($actualArray)->to->be->{$expectArray};
        });
    });
    describe('->removeUser()', function () {
        it('should return a list of users', function () {
            $owner = new Owner();
            expect($owner)->to->be->instanceof('Notes\\Domain\\Entity\\UserGroup\\Owner');
            $bob = new User(new StringLiteral('Bob'));
            $joe = new User(new StringLiteral('joe'));
            $blah = new User(new StringLiteral('Blah'));
            $owner->addUser($bob);
            $owner->addUser($joe);
            $owner->addUser($blah);
            $owner->removeUser($blah);
            $expectArray = array($bob, $joe);
            $actualArray = $owner->getUsers();
            expect($actualArray)->to->be->{$expectArray};
        });
    });
    describe('->getName()', function () {
        it('should return the default name of the group', function () {
            $owner = new Owner();
            expect($owner->getName())->equal('Owner');
        });
    });
});
         $lastName5 = "Kelly";
         $user2 = new User($username1, $password2, $email3, $firstName4, $lastName5);
         $user1Key = $user1->getUserID();
         $user2Key = $user2->getUserID();
         $initialUsers = array($user1Key => $user1, $user2Key => $user2);
         $groupName = "cs3620";
         $actual = new Owner($groupName, $initialUsers);
         // create new owner group with name cs3620 and add an array with 2 users as initial users
         expect($actual->getUser($user1Key))->equal($user1);
         $actual->removeUser($user1Key);
         expect($actual->containsUser($user1Key))->to->be->false;
     });
 });
 describe('->updateUser(swagzilla)', function () {
     it('should add a user to an empty owner usergroup', function () {
         $actual = new Owner();
         $username = "******";
         $password = "******";
         $email = "*****@*****.**";
         $firstName = "Gary";
         $lastName = "Grice";
         $user1 = new User($username, $password, $email, $firstName, $lastName);
         $user1Key = $user1->getUserID();
         $actual->addUser($user1);
         expect($actual->getUser($user1Key))->equal($user1);
         $passwordU = "OldDannyBrown12\$";
         $emailU = "*****@*****.**";
         $updatedUser1 = new User($username, $passwordU, $emailU, $firstName, $lastName);
         $actual->updateUser($user1Key, '', '', $passwordU, $emailU, '');
         expect($actual->getUser($user1Key))->equal($updatedUser1);
     });
            expect($actual->containsUser($user1Key))->to->be->false;
        });
    });
    describe('->updateUser(swagzilla)', function () {
        it('should add a user to an empty owner usergroup', function () {
            $actual = new Owner();
            $username = "******";
            $password = "******";
            $email = "*****@*****.**";
            $firstName = "Gary";
            $lastName = "Grice";
            $user1 = new User($username, $password, $email, $firstName, $lastName);
            $user1Key = $user1->getUserID();
            $actual->addUser($user1);
            expect($actual->getUser($user1Key))->equal($user1);
            $passwordU = "OldDannyBrown12\$";
            $emailU = "*****@*****.**";
            $updatedUser1 = new User($username, $passwordU, $emailU, $firstName, $lastName);
            $actual->updateUser($user1Key, '', '', $passwordU, $emailU, '');
            expect($actual->getUser($user1Key))->equal($updatedUser1);
        });
    });
    describe('->setCanManipulateNotes()', function () {
        it('determines whether or not a group can create/edit notes if a user is added to the banned owner group then they cant create or edit notes', function () {
            $actual = new Owner();
            $actual->setName("banned");
            $actual->setCanManipulateNotes(false);
            expect($actual->canManipulateNotes())->to->be->false;
        });
    });
});