manager = new AccountManager($GLOBALS['httpSession']); $this->account = new NullAccount(3); $this->account->generatePassword('abcd'); } /** * @testdox The manager has the expected default values after initialization * @covers \phpOMS\Account\AccountManager * @group framework */ public function testDefault() : void { self::assertEquals(0, $this->manager->count()); self::assertInstanceOf('\phpOMS\Account\Account', $this->manager->get(0)); self::assertInstanceOf('\phpOMS\Account\NullAccount', $this->manager->get(-1)); } /** * @testdox An account can be added to the manager * @covers \phpOMS\Account\AccountManager * @group framework */ public function testAddAccount() : void { $added = $this->manager->add($this->account); self::assertTrue($added); self::assertEquals(1, $this->manager->count()); } /** * @testdox An account can be retrieved from the manager * @covers \phpOMS\Account\AccountManager * @group framework */ public function testRetrieveAccount() : void { $this->manager->add($this->account); self::assertEquals($this->account, $this->manager->get($this->account->id)); } /** * @testdox An account can only be added once to the account manager (no duplication) * @covers \phpOMS\Account\AccountManager * @group framework */ public function testNoAccountDuplication() : void { $this->manager->add($this->account); $added = $this->manager->add($this->account); self::assertFalse($added); self::assertTrue($this->manager->remove($this->account->id)); self::assertFalse($this->manager->remove(-1)); self::assertEquals(0, $this->manager->count()); } /** * @testdox An account can be removed from the account manager * @covers \phpOMS\Account\AccountManager * @group framework */ public function testRemoveAccount() : void { $this->manager->add($this->account); self::assertTrue($this->manager->remove($this->account->id)); self::assertEquals(0, $this->manager->count()); self::assertFalse($this->manager->remove(-1)); } /** * @testdox Only a valid account can be removed from the manager * @covers \phpOMS\Account\AccountManager * @group framework */ public function testRemoveOnlyValidAccount() : void { $this->manager->add($this->account); self::assertFalse($this->manager->remove(-1)); self::assertEquals(1, $this->manager->count()); self::assertTrue($this->manager->remove($this->account->id)); self::assertEquals(0, $this->manager->count()); } }