本文整理汇总了PHP中skipIf函数的典型用法代码示例。如果您正苦于以下问题:PHP skipIf函数的具体用法?PHP skipIf怎么用?PHP skipIf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skipIf函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foo
public function foo(\$a) {return parent::foo(\$a);}
public function foo2(\$b = NULL) {return parent::foo2(\$b);}
public function foo3(array \$b = array()) {return parent::foo3(\$b);}
public function foo4(callable \$fct) {return parent::foo4(\$fct);}
public function foo5(\\Closure \$fct) {return parent::foo5(\$fct);}
public function foo6(\\Exception \$e) {return parent::foo6(\$e);}
public function foo7(\\Kahlan\\Spec\\Fixture\\Plugin\\Stub\\DozInterface \$instance) {return parent::foo7(\$instance);}
}
?>
EOD;
expect($result)->toBe($expected);
});
it("adds ` = NULL` to optional parameter in PHP core method", function () {
skipIf(defined('HHVM_VERSION'));
$result = Stub::generate(['class' => 'Kahlan\\Spec\\Plugin\\Stub\\Stub', 'extends' => 'LogicException', 'layer' => true]);
$expected = <<<EOD
<?php
namespace Kahlan\\\\Spec\\\\Plugin\\\\Stub;
class Stub extends \\\\LogicException {
public function __construct\\(\\\$message = NULL, \\\$code = NULL, \\\$previous = NULL\\)
EOD;
expect($result)->toMatch('~' . $expected . '~i');
});
it("generates code without PHP tags", function () {
$result = Stub::generate(['class' => 'Kahlan\\Spec\\Plugin\\Stub\\Stub', 'magicMethods' => false, 'openTag' => false, 'closeTag' => false]);
$expected = <<<EOD
namespace Kahlan\\Spec\\Plugin\\Stub;
示例2: describe
<?php
namespace Kahlan\Spec\Suite\Reporter\Coverage;
use Kahlan\Reporter\Coverage\Collector;
use Kahlan\Reporter\Coverage\Driver\Xdebug;
use Kahlan\Reporter\Coverage\Driver\Phpdbg;
use Kahlan\Reporter\Coverage\Exporter\Coveralls;
use Kahlan\Spec\Fixture\Reporter\Coverage\NoEmptyLine;
use Kahlan\Spec\Fixture\Reporter\Coverage\ExtraEmptyLine;
use RuntimeException;
describe("Coveralls", function () {
beforeEach(function () {
if (!extension_loaded('xdebug') && PHP_SAPI !== 'phpdbg') {
skipIf(true);
}
$this->driver = PHP_SAPI !== 'phpdbg' ? new Xdebug() : new Phpdbg();
});
describe("::export()", function () {
it("exports the coverage of a file with no extra end line", function () {
$path = 'spec' . DS . 'Fixture' . DS . 'Reporter' . DS . 'Coverage' . DS . 'NoEmptyLine.php';
$collector = new Collector(['driver' => $this->driver, 'path' => $path]);
$code = new NoEmptyLine();
$collector->start();
$code->shallNotPass();
$collector->stop();
$json = Coveralls::export(['collector' => $collector, 'service_name' => 'kahlan-ci', 'service_job_id' => '123', 'repo_token' => 'ABC']);
$actual = json_decode($json, true);
unset($actual['run_at']);
expect($actual['service_name'])->toBe('kahlan-ci');
expect($actual['service_job_id'])->toBe('123');
示例3: describe
namespace Kahlan\Spec\Jit\Suite;
use Kahlan\Dir\Dir;
use Kahlan\Jit\JitException;
use Kahlan\Jit\Patchers;
use Kahlan\Jit\Interceptor;
use Kahlan\Plugin\Stub;
use Kahlan\Spec\Proxy\Autoloader;
use Kahlan\Spec\Mock\Patcher;
describe("Interceptor", function () {
before(function () {
$this->previous = Interceptor::instance();
Interceptor::unpatch();
$this->composer = Interceptor::composer();
skipIf(!$this->composer);
$composer = clone $this->composer[0];
$this->autoloader = new Autoloader($composer);
spl_autoload_register([$this->autoloader, 'loadClass']);
spl_autoload_unregister($this->composer);
$this->cachePath = Dir::tempnam(null, 'cache');
});
afterEach(function () {
Interceptor::unpatch();
});
after(function () {
spl_autoload_register($this->composer);
spl_autoload_unregister([$this->autoloader, 'loadClass']);
Dir::remove($this->cachePath);
Interceptor::load($this->previous);
});
示例4: box
namespace Chaos\Database\Spec\Suite;
use Lead\Set\Set;
use Chaos\ChaosException;
use Chaos\Database\DatabaseException;
use Chaos\Model;
use Chaos\Finders;
use Chaos\Database\Query;
use Chaos\Database\Schema;
use Chaos\Database\Spec\Fixture\Fixtures;
$box = box('chaos.spec');
$connections = ["MySQL" => $box->has('source.database.mysql') ? $box->get('source.database.mysql') : null, "PgSql" => $box->has('source.database.postgresql') ? $box->get('source.database.postgresql') : null];
foreach ($connections as $db => $connection) {
describe("Query[{$db}]", function () use($connection) {
beforeAll(function () use($connection) {
skipIf(!$connection);
});
beforeEach(function () use($connection) {
$this->connection = $connection;
$this->fixtures = new Fixtures(['connection' => $connection, 'fixtures' => ['gallery' => 'Chaos\\Database\\Spec\\Fixture\\Schema\\Gallery', 'gallery_detail' => 'Chaos\\Database\\Spec\\Fixture\\Schema\\GalleryDetail', 'image' => 'Chaos\\Database\\Spec\\Fixture\\Schema\\Image', 'image_tag' => 'Chaos\\Database\\Spec\\Fixture\\Schema\\ImageTag', 'tag' => 'Chaos\\Database\\Spec\\Fixture\\Schema\\Tag']]);
$this->fixtures->populate('gallery', ['create']);
$this->fixtures->populate('gallery_detail', ['create']);
$this->fixtures->populate('image', ['create']);
$this->fixtures->populate('image_tag', ['create']);
$this->fixtures->populate('tag', ['create']);
$this->gallery = $this->fixtures->get('gallery')->model();
$this->galleryDetail = $this->fixtures->get('gallery_detail')->model();
$this->image = $this->fixtures->get('image')->model();
$this->image_tag = $this->fixtures->get('image_tag')->model();
$this->tag = $this->fixtures->get('tag')->model();
$this->query = new Query(['model' => $this->gallery]);
示例5: expect
expect(Inspector::typehint($inspector[0]))->toBe('');
$inspector = Inspector::parameters($this->class, 'parameterByReference');
expect(Inspector::typehint($inspector[0]))->toBe('');
});
it("returns parameter typehint", function () {
$inspector = Inspector::parameters($this->class, 'exceptionTypeHint');
$typehint = Inspector::typehint(current($inspector));
expect($typehint)->toBeA('string');
expect($typehint)->toBe('\\Exception');
$inspector = Inspector::parameters($this->class, 'arrayTypeHint');
$typehint = Inspector::typehint(current($inspector));
expect($typehint)->toBeA('string');
expect($typehint)->toBe('array');
$inspector = Inspector::parameters($this->class, 'callableTypeHint');
$typehint = Inspector::typehint(current($inspector));
expect($typehint)->toBeA('string');
expect($typehint)->toBe('callable');
});
it("returns parameter typehint for scalar type hints", function () {
skipIf(PHP_MAJOR_VERSION < 7);
$inspector = Inspector::parameters('Kahlan\\Spec\\Fixture\\Analysis\\ScalarTypeHintsClass', 'intTypeHint');
$typehint = Inspector::typehint(current($inspector));
expect($typehint)->toBeA('string');
expect($typehint)->toBe('int');
$inspector = Inspector::parameters('Kahlan\\Spec\\Fixture\\Analysis\\ScalarTypeHintsClass', 'boolTypeHint');
$typehint = Inspector::typehint(current($inspector));
expect($typehint)->toBeA('string');
expect($typehint)->toBe('bool');
});
});
});
示例6: expect
expect($namespace->type)->toBe('namespace');
expect(Parser::unparse($root))->toBe($code);
});
it("correctly populates the `->inPhp` attribute", function () {
$sample = file_get_contents('spec/Fixture/Parser/Sample.php');
$root = Parser::parse($sample);
$plain = [];
foreach ($this->flattenTree($root->tree, $this) as $node) {
if (!$node->inPhp) {
$plain[] = (string) $node;
}
}
expect($plain)->toBe(["<?php\n", "?>\n", "\n<i> Hello World </i>\n\n", "<?php\n", "?>\n", "<?php\n"]);
});
it("correctly populates the `->isGenerator` attribute", function () {
skipIf(version_compare(phpversion(), '5.5', '<'));
$sample = file_get_contents('spec/Fixture/Parser/Generator.php');
$root = Parser::parse($sample);
foreach ($root->tree as $node) {
if ($node->type === 'function') {
expect($node->name)->toBe('myGenerator');
expect($node->isClosure)->toBe(false);
expect($node->isMethod)->toBe(false);
expect($node->isGenerator)->toBe(true);
expect($node->parent)->toBe($root);
}
}
});
});
describe("->debug()", function () {
it("attaches the correct lines", function () {
示例7: describe
});
});
describe('->moveTo', function () {
it('throws InvalidArgumentException when target path is empty', function () {
expect(function () {
(new UploadedFile('', 0, UPLOAD_ERR_NO_FILE))->moveTo('');
})->toThrow(new InvalidArgumentException());
});
it('throws RuntimeException when error is not UPLOAD_ERR_OK', function () {
expect(function () {
(new UploadedFile('', 0, UPLOAD_ERR_NO_FILE))->moveTo('/tmp/kahlan/ochentatmp');
})->toThrow(new RuntimeException());
});
it('renames the given file', function () {
$tmpfile = tempnam(sys_get_temp_dir(), 'kahlan/');
skipIf($tmpfile === FALSE);
touch($tmpfile);
(new UploadedFile($tmpfile, 0, UPLOAD_ERR_OK))->moveTo('/tmp/kahlan/ochentatmp');
expect(file_exists($tmpfile))->toBe(FALSE);
expect(file_exists('/tmp/kahlan/ochentatmp'))->toBe(TRUE);
unlink('/tmp/kahlan/ochentatmp');
});
});
describe('->getSize', function () {
it('returns the given size', function () {
expect((new UploadedFile('', 0, UPLOAD_ERR_NO_FILE))->getSize())->toBe(0);
});
});
describe('->getError', function () {
it('returns the given error', function () {
expect((new UploadedFile('', 0, UPLOAD_ERR_NO_FILE))->getError())->toBe(UPLOAD_ERR_NO_FILE);
示例8: describe
<?php
namespace Chaos\Database\Spec\Suite\Adapter;
use DateTime;
use Chaos\Database\DatabaseException;
use Chaos\Database\Adapter\Sqlite;
use Chaos\Database\Schema;
describe("Sqlite", function () {
beforeAll(function () {
$box = box('chaos.spec');
skipIf(!$box->has('source.database.sqlite'));
});
beforeEach(function () {
$box = box('chaos.spec');
$this->adapter = $box->get('source.database.sqlite');
});
describe("::enabled()", function () {
it("returns `true` for enabled features, false otherwise.", function () {
expect(Sqlite::enabled())->toEqual(['arrays' => false, 'transactions' => false, 'booleans' => true, 'default' => false]);
expect(Sqlite::enabled('arrays'))->toBe(false);
expect(Sqlite::enabled('transactions'))->toBe(false);
expect(Sqlite::enabled('booleans'))->toBe(true);
expect(Sqlite::enabled('default'))->toBe(false);
});
it("throws an exception if the extension is not loaded.", function () {
allow('extension_loaded')->toBeCalled()->andReturn(false);
expect(function () {
Sqlite::enabled();
})->toThrow(new DatabaseException("The PDO SQLite extension is not installed."));
});
示例9: describe
<?php
namespace chaos\database\spec\suite\adapter;
use chaos\database\DatabaseException;
use chaos\database\adapter\MySql;
use chaos\database\Schema;
use kahlan\plugin\Stub;
use kahlan\plugin\Monkey;
describe("MySql", function () {
before(function () {
$box = box('chaos.spec');
skipIf(!$box->has('source.database.mysql'));
});
beforeEach(function () {
$box = box('chaos.spec');
$this->adapter = $box->get('source.database.mysql');
});
describe("::enabled()", function () {
it("returns `true` for enabled features, false otherwise.", function () {
expect(MySql::enabled())->toEqual(['arrays' => false, 'transactions' => true, 'booleans' => true, 'default' => false]);
expect(MySql::enabled('arrays'))->toBe(false);
expect(MySql::enabled('transactions'))->toBe(true);
expect(MySql::enabled('booleans'))->toBe(true);
expect(MySql::enabled('default'))->toBe(false);
});
it("throws an exception if the extension is not loaded.", function () {
Monkey::patch('extension_loaded', function () {
return false;
});
expect(function () {
示例10: expect
expect(file_exists($this->tmpDir . $target))->toBe(false);
}
expect(file_exists($this->tmpDir))->toBe(false);
});
});
describe("::make()", function () {
beforeEach(function () {
$this->umask = umask(0);
$this->tmpDir = Dir::tempnam(sys_get_temp_dir(), 'spec');
});
afterEach(function () {
Dir::remove($this->tmpDir, ['recursive' => true]);
umask($this->umask);
});
it("creates a nested directory", function () {
skipIf(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
$path = $this->tmpDir . '/My/Nested/Directory';
$actual = Dir::make($path);
expect($actual)->toBe(true);
expect(file_exists($path))->toBe(true);
$stat = stat($path);
$mode = $stat['mode'] & 0777;
expect($mode)->toBe(0755);
});
it("creates a nested directory with a specific mode", function () {
$path = $this->tmpDir . '/My/Nested/Directory';
$actual = Dir::make($path, ['mode' => 0777]);
expect($actual)->toBe(true);
expect(file_exists($path))->toBe(true);
$stat = stat($path);
$mode = $stat['mode'] & 0777;
示例11: describe
<?php
namespace chaos\database\spec\suite\adapter;
use chaos\database\DatabaseException;
use chaos\database\adapter\PostgreSql;
use chaos\database\Schema;
use kahlan\plugin\Stub;
use kahlan\plugin\Monkey;
use chaos\database\spec\fixture\Fixtures;
describe("PostgreSql", function () {
before(function () {
$box = box('chaos.spec');
skipIf(!$box->has('source.database.postgresql'));
});
beforeEach(function () {
$box = box('chaos.spec');
$this->adapter = $box->get('source.database.postgresql');
});
describe("::enabled()", function () {
it("returns `true` for enabled features, false otherwise.", function () {
expect(PostgreSql::enabled())->toEqual(['arrays' => true, 'transactions' => true, 'booleans' => true, 'default' => true]);
expect(PostgreSql::enabled('arrays'))->toBe(true);
expect(PostgreSql::enabled('transactions'))->toBe(true);
expect(PostgreSql::enabled('booleans'))->toBe(true);
expect(PostgreSql::enabled('default'))->toBe(true);
});
it("throws an exception if the extension is not loaded.", function () {
Monkey::patch('extension_loaded', function () {
return false;
});
示例12: expect
expect($stream->mime())->toBe('application/x-tar');
$stream->close();
});
it("returns the jpg mime", function () {
$stream = new Stream(['data' => fopen('spec/Fixture/favicon.jpg', 'r+'), 'mime' => true]);
expect($stream->mime())->toBe('image/jpeg');
$stream->close();
});
it("returns the png mime", function () {
$stream = new Stream(['data' => fopen('spec/Fixture/favicon.png', 'r+'), 'mime' => true]);
expect($stream->mime())->toBe('image/png');
$stream->close();
});
it("returns the gif mime", function () {
$stream = new Stream(['data' => fopen('spec/Fixture/favicon.gif', 'r+'), 'mime' => true]);
skipIf(version_compare(PHP_VERSION, '5.6.6', '<'));
// Skip for PHP since https://bugs.php.net/bug.php?id=67647
expect($stream->mime())->toBe('image/gif');
$stream->close();
});
it("returns the wav mime", function () {
$stream = new Stream(['data' => fopen('spec/Fixture/sound.wav', 'r+'), 'mime' => true]);
expect($stream->mime())->toBe('audio/x-wav');
$stream->close();
});
});
/**
* PSR-7 interoperability aliases
*/
describe("->getContents()", function () {
it("delegates to `->flush()`", function () {
示例13: function
For additional help you must use [0;32;49m--help[0m
EOD;
$closure = function () {
try {
$this->specs->loadConfig(['--version', '--no-header']);
} catch (Exception $e) {
}
};
Quit::disable();
expect($closure)->toEcho($message);
});
it("isolates `kahlan-config.php` execution in a dedicated scope", function () {
skipIf(!$this->console->colors());
$version = Kahlan::VERSION;
$message = <<<EOD
version [0;32;49m{$version}[0m
For additional help you must use [0;32;49m--help[0m
EOD;
$closure = function () {
try {
$this->specs->loadConfig(['--config=spec/Fixture/Kahlan/kahlan-config.php', '--version', '--no-header']);
} catch (Exception $e) {
}
};
Quit::disable();