当前位置: 首页>>代码示例>>PHP>>正文


PHP describe函数代码示例

本文整理汇总了PHP中describe函数的典型用法代码示例。如果您正苦于以下问题:PHP describe函数的具体用法?PHP describe怎么用?PHP describe使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了describe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gentree

function gentree($spy, $max_depth, $describes, $methods = array())
{
    $generate_test_block = function ($block_method, $path, $index, $spy) {
        array_push($path, $block_method, $index);
        $spy_method_name = implode(".", $path);
        if ($block_method == 'it') {
            call_user_func($block_method, $spy_method_name, array($spy, $spy_method_name));
        } else {
            call_user_func($block_method, array($spy, $spy_method_name));
        }
    };
    $generate = function ($depth, $path) use(&$generate, $describes, $methods, &$generate_test_block, $spy, $max_depth) {
        foreach ($methods as $block_method => $num) {
            foreach (range(1, $num) as $index) {
                $generate_test_block($block_method, $path, $index, $spy);
            }
        }
        if ($depth < $max_depth) {
            foreach (range(1, $describes) as $index) {
                describe("describe_{$index}", function () use(&$generate, $depth, $path, $index) {
                    $generate($depth + 1, array_merge($path, array("describe", "{$index}")));
                });
            }
        }
    };
    return suite('Root', function ($ctx) use($generate) {
        $generate(1, array());
    });
}
开发者ID:aaron-em,项目名称:matura,代码行数:29,代码来源:test_ordering.php

示例2: 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

示例3: 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

示例4: expect

            $response->headers['Content-Type'] = 'text/html';
            $response->headers['Set-Cookie'] = 'username=skeletor';
            $response->flush();
            $headers = pipes\headers();
            expect($headers[0])->to_be('Content-Type: text/html');
            expect($headers[1])->to_be('Set-Cookie: username=skeletor');
            expect(ob_get_clean())->to_be_empty();
        });
        it("should implode and echo \$body", function ($context) {
            extract($context);
            ob_start();
            $response->write("foo\n");
            $response->write("bar");
            $response->write("baz");
            $response->flush();
            expect(ob_get_clean())->to_be("foo\nbarbaz");
        });
    });
    describe("write()", function () {
        it("should append the string to \$body and increase \$length", function ($context) {
            extract($context);
            expect($response->body)->to_have_count(0);
            $response->write("foo");
            expect($response->body)->to_have_count(1);
            $response->write("bar");
            expect($response->body)->to_have_count(2);
            expect($response->body)->to_be(array('foo', 'bar'));
            expect($response->length)->to_be(6);
        });
    });
});
开发者ID:noonat,项目名称:pipes,代码行数:31,代码来源:test_response.php

示例5: describe

describe('TypeMatcher', function () {
    it('implements the MatcherInterface', function () {
        $matcher = new TypeMatcher('string');
        if (!$matcher instanceof MatcherInterface) {
            throw new \Exception('Does not implement MatcherInterface');
        }
    });
    context('match', function () {
        it('returns true if the value has the expected type', function () {
            $matcher = new TypeMatcher('string');
            if (!$matcher->match('test')) {
                throw new \Exception('Does not return true');
            }
        });
        it('returns false if the value is not of the correct type', function () {
            $matcher = new TypeMatcher('integer');
            if ($matcher->match('test')) {
                throw new \Exception('Does not return false');
            }
        });
    });
    context('getFailureMessage', function () {
        it('lists the expected type and the type of the value', function () {
            $matcher = new TypeMatcher('integer');
            $matcher->match(false);
            $expected = 'Expected integer, got boolean';
            if ($expected !== $matcher->getFailureMessage()) {
                throw new \Exception('Did not return expected failure message');
            }
        });
        it('lists the expected and actual type with inversed logic', function () {
            $matcher = new TypeMatcher('integer');
            $matcher->match(0);
            $expected = 'Expected a type other than integer';
            if ($expected !== $matcher->getFailureMessage(true)) {
                throw new \Exception('Did not return expected failure message');
            }
        });
    });
});
开发者ID:ciarand,项目名称:pho,代码行数:40,代码来源:TypeMatcherSpec.php

示例6: describe

describe('Searchable Query Builder', function () {
    before(function () {
        (new Searchable(new Parser()))->boot();
    });
    given('query', function () {
        $connection = Stub::create(['extends' => Connection::class, 'methods' => ['__construct']]);
        $grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar();
        $processor = new Illuminate\Database\Query\Processors\MySqlProcessor();
        return (new Builder($connection, $grammar, $processor))->from('users');
    });
    it('replaces query with custom implementation on call', function () {
        expect($this->query)->toBeAnInstanceOf(Builder::class);
        expect($this->query->search('word', ['column']))->toBeAnInstanceOf(Query::class);
    });
    it('adds basic SELECT, WHERE and GROUP BY clauses', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`name` = ? then 15 else 0 end) as relevance ' . 'from `users` where (`users`.`name` like ?) group by `users`.`id`) as `users` ' . 'where `relevance` >= 1 order by `relevance` desc';
        $query = $this->query->search('Jarek', ['name'], false, 1);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe(['Jarek', 'Jarek']);
    });
    it('splits string into separate keywords and adds valid clauses for multiple columns', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`first_name` = ? or `users`.`first_name` = ? then 15 else 0 end ' . '+ case when `users`.`last_name` = ? or `users`.`last_name` = ? then 30 else 0 end) as relevance from `users` ' . 'where (`users`.`first_name` like ? or `users`.`first_name` like ? or `users`.`last_name` like ? or `users`.`last_name` like ?) ' . 'group by `users`.`id`) as `users` where `relevance` >= 0.75 order by `relevance` desc';
        $bindings = ['jarek', 'tkaczyk', 'jarek', 'tkaczyk', 'jarek', 'tkaczyk', 'jarek', 'tkaczyk'];
        $query = $this->query->search('jarek tkaczyk', ['first_name', 'last_name' => 2], false);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('handles wildcards provided with keyword', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`first_name` = ? then 15 else 0 end ' . '+ case when `users`.`first_name` like ? then 5 else 0 end) ' . 'as relevance from `users` where (`users`.`first_name` like ?) ' . 'group by `users`.`id`) as `users` where `relevance` >= 0.25 order by `relevance` desc';
        $bindings = ['jarek', 'jarek%', 'jarek%'];
        $query = $this->query->search('jarek*', ['first_name'], false);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('lets you use wildcards manually', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`last_name` = ? or `users`.`last_name` = ? or `users`.`last_name` = ? then 150 else 0 end ' . '+ case when `users`.`last_name` like ? or `users`.`last_name` like ? then 50 else 0 end ' . '+ case when `users`.`last_name` like ? then 10 else 0 end ' . '+ case when `companies`.`name` = ? or `companies`.`name` = ? or `companies`.`name` = ? then 75 else 0 end ' . '+ case when `companies`.`name` like ? or `companies`.`name` like ? then 25 else 0 end ' . '+ case when `companies`.`name` like ? then 5 else 0 end) ' . 'as relevance from `users` left join `company_user` on `company_user`.`user_id` = `users`.`id` ' . 'left join `companies` on `company_user`.`company_id` = `companies`.`id` ' . 'where (`users`.`last_name` like ? or `users`.`last_name` like ? or `users`.`last_name` like ? ' . 'or `companies`.`name` like ? or `companies`.`name` like ? or `companies`.`name` like ?) ' . 'group by `users`.`id`) as `users` where `relevance` >= 3.75 order by `relevance` desc';
        $bindings = ['jarek', 'tkaczyk', 'sofa', 'jarek%', 'tkaczyk%', '%jarek%', 'jarek', 'tkaczyk', 'sofa', 'jarek%', 'tkaczyk%', '%jarek%', '%jarek%', 'tkaczyk%', 'sofa', '%jarek%', 'tkaczyk%', 'sofa'];
        $query = $this->query->search('*jarek* tkaczyk* sofa', ['last_name' => 10, 'companies.name' => 5], false)->leftJoin('company_user', 'company_user.user_id', '=', 'users.id')->leftJoin('companies', 'company_user.company_id', '=', 'companies.id');
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('runs fulltext search by default and allows custom key for grouping', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`last_name` = ? then 150 else 0 end ' . '+ case when `users`.`last_name` like ? then 50 else 0 end ' . '+ case when `users`.`last_name` like ? then 10 else 0 end) ' . 'as relevance from `users` where (`users`.`last_name` like ?) ' . 'group by `users`.`custom_key`) as `users` where `relevance` >= 2.5 order by `relevance` desc';
        $bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];
        $query = $this->query->search(' jarek ', ['last_name' => 10], true, null, 'custom_key');
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('fails silently if no words or columns were provided', function () {
        $sql = 'select * from `users`';
        expect($this->query->search('   ', [])->toSql())->toBe($sql);
    });
    it('uses valid case insensitive operator in postgres', function () {
        $connection = Stub::create(['extends' => Connection::class, 'methods' => ['__construct']]);
        $grammar = new Illuminate\Database\Query\Grammars\PostgresGrammar();
        $processor = new Illuminate\Database\Query\Processors\PostgresProcessor();
        $sql = 'select * from (select "users".*, max(case when "users"."last_name" = ? then 150 else 0 end ' . '+ case when "users"."last_name" ilike ? then 50 else 0 end ' . '+ case when "users"."last_name" ilike ? then 10 else 0 end) ' . 'as relevance from "users" where ("users"."last_name" ilike ?) ' . 'group by "users"."id") as "users" where "relevance" >= 2.5 order by "relevance" desc';
        $bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];
        $query = (new Builder($connection, $grammar, $processor))->from('users')->search(' jarek ', ['last_name' => 10]);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('supports length aware pagination', function () {
        $sql = 'select count(*) as aggregate from (select `users`.*, max(case when `users`.`last_name` = ? then 150 else 0 end ' . '+ case when `users`.`last_name` like ? then 50 else 0 end ' . '+ case when `users`.`last_name` like ? then 10 else 0 end) ' . 'as relevance from `users` where (`users`.`last_name` like ?) ' . 'group by `users`.`id`) as `users` where `relevance` >= 2.5';
        $bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];
        $query = $this->query->search(' jarek ', ['last_name' => 10]);
        Stub::on($query->getConnection())->method('select', []);
        expect($query->getConnection())->toReceive('select')->with($sql, $bindings, Arg::toBeA('boolean'));
        $query->getCountForPagination();
    });
    it('moves order clauses after the relevance ordering', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`name` = ? then 15 else 0 end) as relevance ' . 'from `users` where (`users`.`name` like ?) group by `users`.`id`) as `users` ' . 'where `relevance` >= 1 order by `relevance` desc, `first_name` asc';
        $bindings = ['jarek', 'jarek'];
        $query = $this->query->orderBy('first_name')->search('jarek', ['name'], false, 1);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('doesn\'t split quoted string and treats it as a single keyword to search for', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`first_name` = ? then 15 else 0 end ' . '+ case when `users`.`first_name` like ? then 5 else 0 end) as relevance from `users` ' . 'where (`users`.`first_name` like ?) group by `users`.`id`) ' . 'as `users` where `relevance` >= 0.25 order by `relevance` desc';
        $bindings = ['jarek tkaczyk', 'jarek tkaczyk%', 'jarek tkaczyk%'];
        $query = $this->query->search('"jarek tkaczyk*"', ['first_name'], false);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('prefixes tables correctly', function () {
        $sql = 'select * from (select `PREFIX_users`.*, max(case when `PREFIX_users`.`first_name` = ? then 15 else 0 end) ' . 'as relevance from `PREFIX_users` where (`PREFIX_users`.`first_name` like ?) ' . 'group by `PREFIX_users`.`id`) as `PREFIX_users` where `relevance` >= 0.25 order by `relevance` desc';
        $bindings = ['jarek', 'jarek'];
        $query = $this->query;
        $query->getGrammar()->setTablePrefix('PREFIX_');
        $query = $query->search('jarek', ['first_name'], false);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
    it('supports single character wildcards', function () {
        $sql = 'select * from (select `users`.*, max(case when `users`.`last_name` = ? then 150 else 0 end) ' . 'as relevance from `users` where (`users`.`last_name` like ?) ' . 'group by `users`.`id`) as `users` where `relevance` >= 2.5 order by `relevance` desc';
        $bindings = ['jaros_aw', 'jaros_aw'];
        $query = $this->query->search(' jaros?aw ', ['last_name' => 10], false);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
//.........这里部分代码省略.........
开发者ID:jarektkaczyk,项目名称:laravel-searchable,代码行数:101,代码来源:SearchableSpec.php

示例7: describe

describe('SpecReporter', function () {
    $console = null;
    $spec = null;
    before(function () use(&$console, &$spec) {
        $console = new Console(array(), 'php://output');
        $console->parseArguments();
        $suite = new Suite('test', function () {
        });
        $spec = new Spec('testspec', function () {
        }, $suite);
    });
    it('implements the ReporterInterface', function () use(&$console) {
        $reporter = new SpecReporter($console);
        expect($reporter instanceof ReporterInterface)->toBeTrue();
    });
    context('beforeSuite', function () use(&$console) {
        $reporter = null;
        before(function () use(&$console, &$reporter) {
            $reporter = new SpecReporter($console);
        });
        it('prints the suite title', function () use(&$reporter) {
            $beforeSuite = function () use(&$reporter) {
                $suite = new Suite('test suite', function () {
                });
                $reporter->beforeSuite($suite);
            };
            expect($beforeSuite)->toPrint(PHP_EOL . "test suite" . PHP_EOL);
        });
        it('pads nested suites', function () use(&$reporter) {
            $beforeSuite = function () use(&$reporter) {
                $suite = new Suite('test suite', function () {
                });
                $reporter->beforeSuite($suite);
            };
            expect($beforeSuite)->toPrint("    test suite" . PHP_EOL);
        });
    });
    context('beforeSpec', function () use(&$console, &$spec) {
        it('increments the spec count', function () use(&$console, &$spec) {
            $reporter = new SpecReporter($console);
            $countBefore = $reporter->getSpecCount();
            $reporter->beforeSpec($spec);
            $countAfter = $reporter->getSpecCount();
            expect($countAfter)->toEqual($countBefore + 1);
        });
    });
    context('afterSpec', function () use(&$console, &$spec) {
        it('prints the spec title in grey if it passed', function () use(&$console, &$spec) {
            $reporter = new SpecReporter($console);
            $afterSpec = function () use($reporter, $spec) {
                $reporter->afterSpec($spec);
            };
            $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,代码行数:83,代码来源:SpecReporterSpec.php

示例8: 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

示例9: 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

示例10: describe

describe('ConsoleOption', function () {
    $optInfo = array('longName' => 'testLongName', 'shortName' => 'testShortName', 'description' => 'testDescription', 'argumentName' => 'testArgumentName');
    $option = new ConsoleOption($optInfo['longName'], $optInfo['shortName'], $optInfo['description'], $optInfo['argumentName']);
    context('basic getters', function () use($option, $optInfo) {
        it('return longName', function () use($option, $optInfo) {
            expect($option->getLongName())->toBe($optInfo['longName']);
        });
        it('return shortName', function () use($option, $optInfo) {
            expect($option->getShortName())->toBe($optInfo['shortName']);
        });
        it('return description', function () use($option, $optInfo) {
            expect($option->getDescription())->toBe($optInfo['description']);
        });
        it('return argumentName', function () use($option, $optInfo) {
            expect($option->getArgumentName())->toBe($optInfo['argumentName']);
        });
        it('return value', function () use($option, $optInfo) {
            expect($option->getValue())->toBeFalse();
        });
    });
    context('acceptArguments', function () {
        it('returns true if an argument name was defined', function () {
            $option = new ConsoleOption('sname', 'lname', 'desc', 'argname');
            expect($option->acceptsArguments())->toBeTrue();
        });
        it('returns true if an argument name was not defined', function () {
            $option = new ConsoleOption('sname', 'lname', 'desc');
            expect($option->acceptsArguments())->toBeFalse();
        });
    });
    context('setValue', function () {
        it('sets the value if the option accepts arguments', function () {
            $option = new ConsoleOption('sname', 'lname', 'desc', 'argname');
            $value = 'test';
            $option->setValue($value);
            expect($option->getValue())->toBe($value);
        });
        it('casts the value to boolean if the option does not', function () {
            $option = new ConsoleOption('sname', 'lname', 'desc');
            $value = 'test';
            $option->setValue($value);
            expect($option->getValue())->toBeTrue();
        });
    });
});
开发者ID:ciarand,项目名称:pho,代码行数:45,代码来源:ConsoleOptionSpec.php

示例11: expect

            expect($param4->getName())->toBe('d');
            expect($param4->getDefaultValue())->toBe(null);
        });
        it("merges defauts values with populated values when the third argument is not empty", function () {
            $inspector = Inspector::parameters($this->class, 'parametersExample', ['first', 1000, true]);
            expect($inspector)->toBe(['a' => 'first', 'b' => 1000, 'c' => true, 'd' => null]);
        });
    });
    describe("::typehint()", function () {
        it("returns an empty string when no typehint is present", function () {
            $inspector = Inspector::parameters($this->class, 'parametersExample');
            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');
        });
    });
});
开发者ID:nurka1109,项目名称:kahlan,代码行数:31,代码来源:InspectorSpec.php

示例12: expect

                expect(new Collection(['data' => [1, 2, 3]]))->toContain(3);
            });
            it("passes if 'a' is in ['a', 'b', 'c']", function () {
                expect(new Collection(['data' => ['a', 'b', 'c']]))->toContain('a');
            });
            it("passes if 'd' is in ['a', 'b', 'c']", function () {
                expect(new Collection(['data' => ['a', 'b', 'c']]))->not->toContain('d');
            });
        });
        context("with a string", function () {
            it("passes if contained in expected", function () {
                expect('Hello World!')->toContain('World');
                expect('World')->toContain('World');
            });
            it("fails if not contained in expected", function () {
                expect('Hello World!')->not->toContain('world');
            });
        });
        it("fails with non string/array", function () {
            expect(new stdClass())->not->toContain('Hello World!');
            expect(false)->not->toContain('0');
            expect(true)->not->toContain('1');
        });
    });
    describe("::description()", function () {
        it("returns the description message", function () {
            $actual = ToContain::description();
            expect($actual)->toBe('contain expected.');
        });
    });
});
开发者ID:crysalead,项目名称:kahlan,代码行数:31,代码来源:ToContain.spec.php

示例13: describe

<?php

use Vnn\Places\Formatter\CountryStripperFormatter;
describe('Vnn\\Places\\Formatter\\CountryStripperFormatter', function () {
    describe('__invoke()', function () {
        it('should remove the country on a single result', function () {
            $data = ['formatted_address' => '1, 2, 3'];
            $formatter = new CountryStripperFormatter(true);
            $result = $formatter($data);
            expect($result)->to->equal(['formatted_address' => '1, 2']);
        });
        it('should remove the country on multiple results', function () {
            $input = [['formatted_address' => '1, 2, 3'], ['formatted_address' => '5, 6, 2']];
            $expected = [['formatted_address' => '1, 2'], ['formatted_address' => '5, 6']];
            $formatter = new CountryStripperFormatter();
            $result = $formatter($input);
            expect($result)->to->equal($expected);
        });
    });
});
开发者ID:varsitynewsnetwork,项目名称:php-google-places-api,代码行数:20,代码来源:country-stripper.spec.php

示例14: describe

<?php

use spec\mock\MockException;
describe('Exception', function () {
    describe('constructor', function () {
        it('instantiates an object', function () {
            expect(function () {
                throw new MockException('123');
            })->toThrow(new MockException('123'));
        });
    });
});
开发者ID:albertoarena,项目名称:calculator,代码行数:12,代码来源:ExceptionSpec.php

示例15: expect

            }
            expect($exception)->to->be->instanceof('\\InvalidArgumentException');
        });
    });
    // tests set and get password
    describe('->getEmail()', function () {
        it('should return the users email address', function () {
            $faker = \Faker\Factory::create();
            $email = $faker->freeEmail;
            $user = new User();
            $user->setEmail($email);
            // setPassword would likely only be used for empty user objects made by an admin or to reset a password
            expect($user->getEmail())->equal($email);
        });
    });
    // tests email validation
    describe('->setEmail()', function () {
        it('should throw an invalid argument exception', function () {
            $invalidEmail = "IAmNotGivingMyEmailToAMachine";
            $user = new User();
            $exception = null;
            try {
                $user->setEmail($invalidEmail);
            } catch (exception $e) {
                $exception = $e;
            }
            expect($exception)->to->be->instanceof('\\InvalidArgumentException');
        });
    });
    // don't need to test set and get name info. that is already tested with the stringliteral tests
});
开发者ID:Ascheere,项目名称:project-final_deliverable-1,代码行数:31,代码来源:user.spec.php


注:本文中的describe函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。