/** * @depends test_newUser */ public function test_find($User) { $Admin = new Admin(); foreach ($Admin->find($User->username) as $ThisUser) { $this->assertInstanceOf("\\Railpage\\Users\\User", $ThisUser); } foreach ($Admin->find($User->username, true) as $ThisUser) { $this->assertInstanceOf("\\Railpage\\Users\\User", $ThisUser); } foreach ($Admin->find("adfasfasdfa") as $row) { $this->assertEquals(NULL, $row); } $this->setExpectedException("Exception", "Cannot perform user lookup because no partial username was provided"); foreach ($Admin->find() as $row) { } }
/** * Validate changes to this item * @since Version 3.10.0 * @return boolean */ private function validate() { if (!$this->Date instanceof DateTime && empty($this->Date)) { $this->Date = new DateTime(); } if (is_null($this->user_id)) { $this->user_id = 0; } if (is_null($this->assigned_to)) { $this->assigned_to = 0; } if (is_null($this->username)) { $this->username = ""; } if (!filter_var($this->status_id, FILTER_VALIDATE_INT)) { $this->status_id = 1; } if ($this->user_id == 0 && !empty($this->username)) { $UserAdmin = new UserAdmin(); $search = $UserAdmin->find($this->username, true); foreach ($search as $User) { $this->user_id = $User->id; break; } } return true; }