/** * @return void * @param string $host * @param int $port * @param string $message * * @throws \PHPUnit_Framework_AssertionFailedError */ public function check($host, $port, $message) { try { $errNo = $errStr = null; if (!@fsockopen($host, $port, $errNo, $errStr, 1)) { throw new \PHPUnit_Framework_AssertionFailedError(); } } catch (\PHPUnit_Framework_AssertionFailedError $e) { \PHPUnit_Framework_Assert::markTestSkipped(sprintf($message, $host, $port)); } }
/** * If you need a Session for testing but don't want to create a backend to * construct one, use this. * @param object $backend Object to serve as the SessionBackend * @param int $index Index * @return Session */ public static function getDummySession($backend = null, $index = -1) { $rc = new \ReflectionClass('MediaWiki\\Session\\Session'); if (!method_exists($rc, 'newInstanceWithoutConstructor')) { \PHPUnit_Framework_Assert::markTestSkipped('ReflectionClass::newInstanceWithoutConstructor isn\'t available'); } if ($backend === null) { $backend = new DummySessionBackend(); } $session = $rc->newInstanceWithoutConstructor(); $priv = \TestingAccessWrapper::newFromObject($session); $priv->backend = $backend; $priv->index = $index; return $session; }
<?php require __DIR__ . '/../../vendor/autoload.php'; /** * @param string $params */ $kawaiiGherkinCheck = function ($params) { if (!is_string($params)) { PHPUnit_Framework_Assert::markTestSkipped(sprintf('$param was expected to be a "string", "%s" given.', gettype($params))); } $basePath = realpath(__DIR__ . '/../../'); system("{$basePath}/bin/kawaii gherkin:check {$params}"); };