本文整理汇总了PHP中it函数的典型用法代码示例。如果您正苦于以下问题:PHP it函数的具体用法?PHP it怎么用?PHP it使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了it函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: it_setups
function it_setups()
{
$command = new Command();
$this->setup($command);
it($command->isGlobal())->shouldBe(true);
it($command->isHidden())->shouldBe(true);
}
开发者ID:weew,项目名称:console,代码行数:7,代码来源:GlobalVerbosityCommandSpec.php
示例2: it_provides_five_entry_points
/**
* @test
*/
public function it_provides_five_entry_points()
{
$instances = [it(null), this(null), these(null), those(null), that(null)];
foreach ($instances as $instance) {
$this->assertInstanceOf("Essence\\Essence", $instance);
}
}
开发者ID:bound1ess,项目名称:essence,代码行数:10,代码来源:FunctionsTest.php
示例3: testBothFunctions
protected function testBothFunctions($input, $expected)
{
$actual = $this->fibonacciProduct($input);
it(sprintf('computes Fibonacci product for %d as %d -- clear code', $input, $actual), $actual === $expected);
$actual = $this->getFunctionOutput(function () use($input) {
return $this->fbnccPrdct(2, array(__FILE__, $input));
});
it(sprintf('computes Fibonacci product for %d as %d -- golfed code', $input, $actual), $actual == $expected);
}
开发者ID:axiac,项目名称:code-golf,代码行数:9,代码来源:fibonacci-products.php
示例4: it_has_valid_masks
function it_has_valid_masks()
{
it(OutputVerbosity::NORMAL & OutputVerbosity::VERBOSE)->shouldBe(OutputVerbosity::NORMAL);
it(OutputVerbosity::NORMAL & OutputVerbosity::DEBUG)->shouldBe(OutputVerbosity::NORMAL);
it(OutputVerbosity::VERBOSE & OutputVerbosity::DEBUG)->shouldBe(OutputVerbosity::VERBOSE);
it(OutputVerbosity::NORMAL & OutputVerbosity::SILENT)->shouldBe(0);
it(OutputVerbosity::VERBOSE & OutputVerbosity::SILENT)->shouldBe(0);
it(OutputVerbosity::DEBUG & OutputVerbosity::SILENT)->shouldBe(0);
}
开发者ID:weew,项目名称:console,代码行数:9,代码来源:OutputVerbositySpec.php
示例5: it_initializes
function it_initializes()
{
$container = new Container();
$this->initialize($container);
it($container->has(TwigLoader::class))->shouldBe(true);
it($container->has(Twig_Loader_Filesystem::class))->shouldBe(true);
it($container->has(Twig::class))->shouldBe(true);
it($container->has(Twig_Environment::class))->shouldBe(true);
}
开发者ID:weew,项目名称:app-twig,代码行数:9,代码来源:TwigProviderSpec.php
示例6: it_formats_with_ansi_and_styles
function it_formats_with_ansi_and_styles()
{
$this->style('red')->setColor('red')->setBackground('white')->setFormat(['bold', 'dim']);
$this->style('blue')->allowInheritance(true)->setColor('blue')->setBackground('red')->setFormat('italic');
$result = $this->format('<style color=red><red>red<blue>blue\\<x><red>red</red></blue>red</red></style>')->getWrappedObject();
$result = str_replace("", '', $result);
$expected = '[0;31m[0;31;107;1;2mred[34;41;3mblue<x>[0;31;107;1;2mred[34;41;3m[0;31;107;1;2mred[0;31m[0m';
it($result)->shouldBe($expected);
}
开发者ID:weew,项目名称:console-formatter,代码行数:9,代码来源:ConsoleFormatterSpec.php
示例7: describe
public function describe(array $data = null)
{
if ($data) {
$this->data = $data;
}
$self = $this;
describe("TOKEN SERVEICE", function () use($self) {
it("CAN STORE & LOAD EACH DATA", [$self, "testStoreAndLoadData"]);
});
}
开发者ID:chatbox-inc,项目名称:token,代码行数:10,代码来源:TokenServiceSpecs.php
示例8: it_initializes
function it_initializes()
{
$container = new Container();
$this->beConstructedWith($container);
$this->initialize($container);
it($container->has(ISwiftMailerManager::class))->shouldBe(true);
it($container->has(SwiftMailerManager::class))->shouldBe(true);
it($container->has(SwiftMailer::class))->shouldBe(true);
it($container->has(Swift_Mailer::class))->shouldBe(true);
}
开发者ID:weew,项目名称:app-swift-mailer,代码行数:10,代码来源:SwiftMailerProviderSpec.php
示例9: testBothMethods
protected function testBothMethods($input, $expected)
{
// The clean code
$actual = $this->checkIfPangram($input);
it(sprintf("thinks '%s' %s a pangram (clear code).", $input, $actual ? 'is' : 'is not'), $actual == $expected);
// The golfed code
$actual = $this->getFunctionOutput(function () use($input) {
$this->chkPngrm(2, array(__FILE__, $input));
});
it(sprintf("thinks '%s' %s a pangram (golfed code).", $input, $actual ? 'is' : 'is not'), $actual == $expected);
}
开发者ID:axiac,项目名称:code-golf,代码行数:11,代码来源:is-it-a-pangram.php
示例10: testDoorStatus
/**
* Test helper. Test both scripts (plain and golfed version) using the test framework.
* Check their actual output against the expected output.
*
* @param int[] $delays the input argument (the number of seconds to wait before pushing the button)
* @param string $expected the expected program output
*/
protected function testDoorStatus(array $delays, $expected)
{
// Format the input for display
$input = implode(' ', $delays);
// Put the script path in front of the arguments; the real program gets its arguments from the command line
array_unshift($delays, __FILE__);
// Test the plain-code function
it(sprintf("turns input '%s' into output '%s' -- clear version", $input, $expected), $this->getFunctionOutput(function () use($delays) {
$this->handleDoor($delays);
}) === $expected);
// Test the golfed function
it(sprintf("turns input '%s' into output '%s' -- golfed version", $input, $expected), $this->getFunctionOutput(function () use($delays) {
$this->hndlDr($delays);
}) === $expected);
}
开发者ID:axiac,项目名称:code-golf,代码行数:22,代码来源:is-the-electric-garage-door-open.php
示例11: testImplementation
function testImplementation($implementation)
{
it('can boot using given papertrail log host and port', function () use($implementation) {
$logger = $implementation::boot($this->host, $this->port);
$message = 'this is a test log message';
$logger->info($message);
expect($this->papertrailClient->getLastEvent()->message)->toContain($message);
});
it('can boot using given log message prefix', function () use($implementation) {
$prefix = '@PREFIX@';
$logger = $implementation::bootWithPrefix($prefix);
$message = 'this is a test log message';
$logger->info($message);
$actualMessage = $this->papertrailClient->getLastEvent()->message;
expect($actualMessage)->toContain("[{$prefix}]");
expect($actualMessage)->toContain($message);
});
}
开发者ID:stephanecoinon,项目名称:papertrail,代码行数:18,代码来源:AllImplentationsSpec.php
示例12: gensuite
public static function gensuite($config = array(), $current_depth = 1)
{
$config = array_merge(array('befores' => 0, 'before_alls' => 0, 'afters' => 0, 'after_alls' => 0, 'tests' => 1, 'depth' => 0, 'describes' => array('L', 'R'), 'callbacks' => array('it' => function ($ctx) {
expect(true)->to->eql(true);
}, 'before' => function ($ctx) {
$ctx->value = 3;
}, 'before_all' => function ($ctx) {
$ctx->value = 5;
}, 'after' => function ($ctx) {
$ctx->value = 7;
}, 'after_all' => function ($ctx) {
$ctx->value = 11;
})), $config);
if ($config['depth'] == 0) {
return;
}
foreach ($config['describes'] as $side) {
describe("Level {$side}{$current_depth}", function ($ctx) use($config, $current_depth) {
for ($i = 1; $i <= $config['tests']; $i++) {
it("nested {$i}", $config['callbacks']['it']);
}
for ($i = 1; $i <= $config['befores']; $i++) {
before($config['callbacks']['before']);
}
for ($i = 1; $i <= $config['before_alls']; $i++) {
before_all($config['callbacks']['before_all']);
}
for ($i = 1; $i <= $config['after_alls']; $i++) {
after_all($config['callbacks']['after_all']);
}
for ($i = 1; $i <= $config['afters']; $i++) {
after($config['callbacks']['after']);
}
$config['depth']--;
Util::gensuite($config, $current_depth + 1);
});
}
}
开发者ID:aaron-em,项目名称:matura,代码行数:38,代码来源:Util.php
示例13: testAllFunctions
/**
* The tester for both methods, the clean code and the golfed code
*
* @param int $n
* @param int $expected
*/
protected function testAllFunctions($n, $expected)
{
// The clean code method 1
$startTime = microtime(TRUE);
$result = $this->countLatticePoints1($n) === $expected;
$runTime = microtime(TRUE) - $startTime;
it(sprintf('it computes f(%d)=%d -- clean code #1; time=%f s', $n, $expected, $runTime), $result);
// The golfed code method 1
$startTime = microtime(TRUE);
$result = $this->cntLttcPnts1($n) === $expected;
$runTime = microtime(TRUE) - $startTime;
it(sprintf('it computes f(%d)=%d -- golfed code #1; time=%f s', $n, $expected, $runTime), $result);
// The clean code method 2
$startTime = microtime(TRUE);
$result = $this->countLatticePoints2($n) === $expected;
$runTime = microtime(TRUE) - $startTime;
it(sprintf('it computes f(%d)=%d -- clean code #2; time=%f s', $n, $expected, $runTime), $result);
// The golfed code method 2
$startTime = microtime(TRUE);
$result = $this->cntLttcPnts2($n) === $expected;
$runTime = microtime(TRUE) - $startTime;
it(sprintf('it computes f(%d)=%d -- golfed code #2; time=%f s', $n, $expected, $runTime), $result);
}
开发者ID:axiac,项目名称:code-golf,代码行数:29,代码来源:lattice-points-inside-a-circle.php
示例14: it
});
it('throws RuntimeException when the resource is already closed', function () {
expect(function () {
$resource = fopen('php://memory', 'r');
fclose($resource);
$stream = new Stream($resource);
$stream->getContents();
})->toThrow(new RuntimeException());
});
it('returns content', function () {
$resource = fopen('php://memory', 'w+');
fwrite($resource, 'Hello');
fseek($resource, 0);
expect((new Stream($resource))->getContents())->toBe('Hello');
});
});
describe('->getMetadata', function () {
it('returns null if when there is no resource', function () {
expect((new Stream(NULL))->getMetadata())->toBeNull();
expect((new Stream(NULL))->getMetadata('anykey'))->toBeNull();
});
it('returns all metadata when no key given', function () {
$stream = new Stream(fopen('php://memory', 'r'));
expect($stream->getMetadata())->toBeA('array')->toContainKey('uri');
expect($stream->getMetadata()['uri'])->toBe('php://memory');
});
it('returns value for given key', function () {
expect((new Stream(fopen('php://memory', 'r')))->getMetadata('uri'))->toBe('php://memory');
});
});
});
开发者ID:guide42,项目名称:ochenta,代码行数:31,代码来源:StreamSpec.php
示例15: expect
$title = $console->formatter->grey($spec->getTitle());
expect($afterSpec)->toPrint($title . PHP_EOL);
});
it('prints the spec title in red if it failed', function () use(&$console, &$spec) {
$suite = new Suite('test', function () {
});
$spec = new Spec('testspec', function () {
throw new \Exception('test');
}, $suite);
$spec->run();
$afterSpec = function () use($console, $spec) {
$reporter = new SpecReporter($console);
$reporter->afterSpec($spec);
};
$specTitle = $console->formatter->red($spec->getTitle());
expect($afterSpec)->toPrint($specTitle . PHP_EOL);
});
it('prints the spec title in cyan if incomplete', function () use(&$console, $spec) {
$suite = new Suite('test', function () {
});
$spec = new Spec('testspec', null, $suite);
$spec->run();
$afterSpec = function () use($console, $spec) {
$reporter = new SpecReporter($console);
$reporter->afterSpec($spec);
};
$specTitle = $console->formatter->cyan($spec->getTitle());
expect($afterSpec)->toPrint($specTitle . PHP_EOL);
});
});
});
开发者ID:ciarand,项目名称:pho,代码行数:31,代码来源:SpecReporterSpec.php
示例16: shared_example
<?php
namespace Preview\DSL\BDD;
require_once __DIR__ . '/../ok.php';
shared_example("to share test", function () {
it("will use the caller's context", function () {
ok($this->name == "wenjun.yan");
});
describe("create a test suite here", function () {
it("and still have access to vars defined caller", function () {
ok($this->name == "wenjun.yan");
});
});
});
describe("it_behaves_like", function () {
before_each(function () {
$this->name = "wenjun.yan";
});
/*
* the following line will be replaced by
* code defined in shared_exmaple "to share test";
*/
it_behaves_like("to share test");
});
开发者ID:v2e4lisp,项目名称:preview,代码行数:25,代码来源:shared_example_and_behave_like_spec.php
示例17: describe
<?php
use Vnn\Places\Formatter\LatLngFormatter;
describe('Vnn\\Places\\Formatter\\LatLngFormatter', function () {
describe('__invoke()', function () {
it('should format a single result', function () {
$data = ['formatted_address' => '123 main st', 'geometry' => ['location' => ['lat' => 5, 'lng' => 9]]];
$expected = ['address' => '123 main st', 'lat' => 5, 'lng' => 9];
$formatter = new LatLngFormatter(true);
$result = $formatter($data);
expect($result)->to->equal($expected);
});
it('should remove the country on multiple results', function () {
$data = [['formatted_address' => '123 main st', 'geometry' => ['location' => ['lat' => 5, 'lng' => 9]]], ['formatted_address' => '862 first st', 'geometry' => ['location' => ['lat' => 55, 'lng' => 12]]]];
$expected = [['address' => '123 main st', 'lat' => 5, 'lng' => 9], ['address' => '862 first st', 'lat' => 55, 'lng' => 12]];
$formatter = new LatLngFormatter();
$result = $formatter($data);
expect($result)->to->equal($expected);
});
});
});
开发者ID:varsitynewsnetwork,项目名称:php-google-places-api,代码行数:21,代码来源:lat-lng.spec.php
示例18: afterAll
*/
afterAll(function () {
Interceptor::load($this->previous);
});
describe("::enable()", function () {
it("enables quit statements", function () {
Quit::disable();
expect(Quit::enabled())->toBe(false);
Quit::enable();
expect(Quit::enabled())->toBe(true);
});
});
describe("::disable()", function () {
it("disables quit statements", function () {
Quit::enable();
expect(Quit::enabled())->toBe(true);
Quit::disable();
expect(Quit::enabled())->toBe(false);
});
});
describe("::disable()", function () {
it("throws an exception when an exit statement occurs if not allowed", function () {
Quit::disable();
$closure = function () {
$foo = new Foo();
$foo->exitStatement(-1);
};
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));
});
});
});
开发者ID:crysalead,项目名称:kahlan,代码行数:31,代码来源:Quit.spec.php
示例19: describe
* Time: 11:29 PM
*/
use Notes\Domain\Entity\UserGroup\Admin;
use Notes\Domain\ValueObject\Uuid;
use Notes\Domain\Entity\User;
use Notes\Domain\ValueObject\StringLiteral;
use Notes\Domain\Entity\Roles\AdminRole;
describe('Notes\\Domain\\Entity\\Roles\\AdminRole', function () {
describe('->__construct()', function () {
it('should return a Admin object', function () {
$actual = new AdminRole();
expect($actual)->to->be->instanceof('Notes\\Domain\\Entity\\Roles\\AdminRole');
});
});
// this tests what exists of this class atm im not sure if i will have to add the other methods to it later or if im on the right track
describe('->__construct(params)', function () {
it('should return a AdminRole object', function () {
$roleID = new Uuid();
$name = "Full admins";
$createPermission = true;
$deletePermission = true;
$permissions = array("Can Create" => $createPermission, "Can Delete" => $deletePermission);
$actual = new AdminRole($roleID, $name, $createPermission, $deletePermission);
expect($actual)->to->be->instanceof('Notes\\Domain\\Entity\\Roles\\AdminRole');
expect($actual->getID())->equal($roleID->__toString());
expect($actual->getPermissions())->equal($permissions);
expect($actual->getName())->equal($name);
});
});
});
// end tests
开发者ID:Ascheere,项目名称:project-final_deliverable-2,代码行数:31,代码来源:admin-role.spec.php
示例20: describe
describe("::compile()", function () {
it("compiles a tokens structure", function () {
$token = Parser::tokenize('/test[/{name}[/{id:[0-9]+}]]');
$rules = Parser::compile($token);
expect($rules)->toBe(['/test(?:/([^/]+)(?:/([0-9]+))?)?', ['name' => false, 'id' => false]]);
});
it("compiles a tokens structure with repeatable patterns", function () {
$tokens = Parser::tokenize('/test[/{name}[/{id:[0-9]+}]*]');
$rules = Parser::compile($tokens);
expect($rules)->toBe(['/test(?:/([^/]+)((?:/[0-9]+)*))?', ['name' => false, 'id' => '/{id:[0-9]+}']]);
});
it("throws an exception when a placeholder is present several time", function () {
$closure = function () {
Parser::compile(Parser::tokenize('/test/{var}/{var}'));
};
expect($closure)->toThrow(ParserException::duplicatePlaceholder('var'));
});
it("throws an exception when a placeholder is present several time through different segments", function () {
$closure = function () {
Parser::compile(Parser::tokenize('/test/{var}[/{var}]'));
};
expect($closure)->toThrow(ParserException::duplicatePlaceholder('var'));
});
it("throws an exception when multiple placeholder are present in repeatable segments", function () {
$closure = function () {
Parser::compile(Parser::tokenize('/test[/{var1}/{var2}]*'));
};
expect($closure)->toThrow(ParserException::placeholderExceeded());
});
});
});
开发者ID:crysalead,项目名称:router,代码行数:31,代码来源:ParserSpec.php
注:本文中的it函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论