mirror of
https://github.com/expo/fbshipit.git
synced 2026-11-15 17:33:57 -10:00
Reviewed By: fredemmott Differential Revision: D3417957 fbshipit-source-id: 0f7099b1d36905558e55021240c51cb87840456a
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?hh
|
|
/**
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
namespace Facebook\ShipIt;
|
|
|
|
abstract class BaseTest extends \PHPUnit_Framework_TestCase {
|
|
protected static function diffsFromMap(
|
|
ImmMap<string, string> $diffs,
|
|
): ImmVector<ShipItDiff> {
|
|
return $diffs->mapWithKey(
|
|
($path, $body) ==> shape('path' => $path, 'body' => $body)
|
|
)->toImmVector();
|
|
}
|
|
|
|
protected function execSteps(
|
|
string $cwd,
|
|
...$steps
|
|
): void {
|
|
foreach ($steps as $step) {
|
|
ShipItUtil::shellExec(
|
|
$cwd,
|
|
/* stdin = */ null,
|
|
ShipItUtil::DONT_VERBOSE,
|
|
...$step,
|
|
);
|
|
}
|
|
}
|
|
|
|
static protected function invoke_static_bypass_visibility<T>(
|
|
classname<T> $classname,
|
|
string $method,
|
|
...$args
|
|
) {
|
|
invariant(
|
|
method_exists($classname, $method),
|
|
'Method "%s" does not exists on "%s"!',
|
|
$method,
|
|
$classname,
|
|
);
|
|
$rm = new \ReflectionMethod($classname, $method);
|
|
invariant(
|
|
$rm->isStatic(),
|
|
'"%s" is not a static method on "%s"!',
|
|
$method,
|
|
$classname,
|
|
);
|
|
invariant(
|
|
null !== $rm->getAttribute('TestsBypassVisibility'),
|
|
'"%s" is not annotated with "TestsBypassVisibility" on "%s"',
|
|
$method,
|
|
$classname,
|
|
);
|
|
$rm->setAccessible(true);
|
|
return $rm->invokeArgs(null, $args);
|
|
}
|
|
}
|