/** * Returns a new TimeZone object * * @param StringLiteral $name * @throws InvalidTimeZoneException */ public function __construct(StringLiteral $name) { if (!in_array($name->toNative(), timezone_identifiers_list())) { throw new InvalidTimeZoneException($name); } $this->name = $name; }
protected function createNodeReportFromValidatorResult(\SimpleHealth\ValidatorResult $result, Collection $endpoint_reports) { if ($result->pass === true) { return new \SimpleHealth\NodeReport(true, StringLiteral::fromNative(''), $endpoint_reports); } else { return new \SimpleHealth\NodeReport(false, $result->message, $endpoint_reports); } }
public function isValid(Collection $reports) { foreach ($reports->toArray() as $report) { if ($report->pass === false) { return new ValidatorResult(false, $report->message); } } return new ValidatorResult(true, StringLiteral::fromNative('')); }
public function check() { try { $response = $this->mechanism->request(); } catch (\GuzzleHttp\Exception\TransferException $ex) { return new EndpointReport($this->endpoint, false, StringLiteral::fromNative($ex->getMessage())); } $report = $this->validator->isValid($response); return new EndpointReport($this->endpoint, $report->pass, $report->message); }
public function testWhenThereIsAFailedReport() { $report_mock = \Mockery::mock('\\SimpleHealth\\EndpointReport'); $report_mock->pass = false; $report_mock->message = StringLiteral::fromNative(''); $reports = new Collection(\SplFixedArray::fromArray([$report_mock])); $subject = new NodeValidator(); $report = $subject->isValid($reports); $this->assertEquals($report->pass, false); }
public function testWhenMechanismWorksTheCorrectReportIsReturned() { $mechanism_mock = \Mockery::mock('\\SimpleHealth\\EndpointMechanismInterface'); $validator_mock = \Mockery::mock('\\SimpleHealth\\ValidatorInterface'); $response_mock = \Mockery::mock('\\Guzzle\\ResponseInterface'); $report_mock = \Mockery::mock('\\SimpleHealth\\ValidatorResult'); $mechanism_mock->shouldReceive('request')->andReturn($response_mock); $validator_mock->shouldReceive('isValid')->andReturn($report_mock); $report_mock->pass = true; $report_mock->message = StringLiteral::fromNative(''); $healthcheck = new EndpointHealthCheck(Url::fromNative('http://www.php.net'), $mechanism_mock, $validator_mock); $report = $healthcheck->check(); $this->assertEquals($report->pass, true); }
/** * Returns the full name * * @return StringLiteral */ public function getFullName() { $fullNameString = $this->firstName . ($this->middleName->isEmpty() ? '' : ' ' . $this->middleName) . ($this->lastName->isEmpty() ? '' : ' ' . $this->lastName); $fullName = new StringLiteral($fullNameString); return $fullName; }
/** * @return StringLiteral */ public function getPassWord() { return $this->passWord->toNative(); }
public function testToString() { $foo = new StringLiteral('foo'); $this->assertEquals('foo', $foo->__toString()); }
public function testGetName() { $name = new StringLiteral('Europe/Madrid'); $timeZone = new TimeZone($name); $this->assertTrue($name->sameValueAs($timeZone->getName())); }