Example #1
0
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());
    });
}
Example #2
0
 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"]);
     });
 }
Example #3
0
 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);
         });
     }
 }
Example #4
0
            $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);
        });
    });
});
Example #5
0
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');
            }
        });
    });
});
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);
    });
    it('supports custom weight and wildcard', function () {
        (new Searchable(new Parser(10, '%')))->boot();
        $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`.`id`) as `users` where `relevance` >= 2.5 order by `relevance` desc';
        $bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];
        $query = $this->query->search('%jarek%', ['last_name'], false);
        expect($query->toSql())->toBe($sql);
        expect($query->toBase()->getBindings())->toBe($bindings);
    });
});
Example #7
0
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);
        });
    });
});
<?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);
        });
    });
});
 * 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
Example #10
0
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();
        });
    });
});
Example #11
0
            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');
        });
    });
});
Example #12
0
                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.');
        });
    });
});
<?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);
        });
    });
});
Example #14
0
<?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'));
        });
    });
});
            }
            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
});
Example #16
0
                    foreach ($suite->specs as $spec) {
                        $this->spec = $spec;
                        $this->formatter->beforeSpec($spec);
                        $spec->run();
                        $this->formatter->afterSpec($spec);
                    }
                    $this->formatter->afterSuite($suite);
                }
                $this->formatter->after();
            }
            */
        });
    });
    describe("run", function () {
        it("should call run on the current runner object", function ($scope, $spec) {
            $oldRunner = pecs\runner();
            $mockRunner = new MockRunner();
            pecs\runner($mockRunner);
            $spec->expect($mockRunner->runCalls)->to_be_empty();
            $formatter = new pecs\Formatter();
            pecs\run($formatter);
            pecs\run($formatter);
            $spec->expect($mockRunner->runCalls)->to_have_count(2);
            $spec->expect($mockRunner->runCalls[0])->to_have_count(1);
            $spec->expect($mockRunner->runCalls[1])->to_have_count(1);
            $spec->expect($mockRunner->runCalls[0][0])->to_be($formatter);
            $spec->expect($mockRunner->runCalls[1][0])->to_be($formatter);
            pecs\runner($oldRunner);
        });
    });
});
Example #17
0
    });
    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());
        });
    });
});
Example #18
0
            $cursor->rewind();
            expect($cursor->next())->toBe(1);
        });
    });
    describe("->current()", function () {
        it("returns `false` when the `PDOStatement` returns `false`", function () {
            $resource = Double::instance();
            allow($resource)->toReceive('fetch')->andRun(function () {
                return false;
            });
            $cursor = new Cursor(['resource' => $resource]);
            expect($cursor->current())->toBe(false);
        });
        it("returns `false` when the `PDOStatement` throws an exception", function () {
            $resource = Double::instance();
            allow($resource)->toReceive('fetch')->andRun(function () {
                throw new PDOException();
            });
            $cursor = new Cursor(['resource' => $resource]);
            expect($cursor->current())->toBe(false);
        });
        it("sets the resource extracted data on success", function () {
            $resource = Double::instance();
            allow($resource)->toReceive('fetch')->andRun(function () {
                return 'data';
            });
            $cursor = new Cursor(['resource' => $resource]);
            expect($cursor->current())->toBe('data');
        });
    });
});
Example #19
0
     */
    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));
        });
    });
});
Example #20
0
            expect($this->stream->getType())->toBe(T_OPEN_TAG);
        });
    });
    describe("->getValue()", function () {
        it("returns the correct token value", function () {
            expect($this->stream->getValue(0))->toBe("<?php\n");
        });
        it("returns the current token type", function () {
            expect($this->stream->getValue())->toBe("<?php\n");
        });
    });
    describe("->getName()", function () {
        it("returns the correct token name", function () {
            expect($this->stream->getName(0))->toBe("T_OPEN_TAG");
        });
    });
    describe("->is()", function () {
        it("returns true when type is correct", function () {
            expect($this->stream->is(T_OPEN_TAG, 0))->toBe(true);
        });
        it("returns false when type is incorrect", function () {
            expect($this->stream->is(T_OPEN_TAG, 1))->toBe(false);
        });
    });
    describe("->__toString()", function () {
        it("generates a string representation of the stream", function () {
            $actual = (string) $this->stream;
            expect($actual)->toBe($this->code);
        });
    });
});
<?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");
});
Example #22
0
 describe("Spec", function () {
     it("should be a subclass of suite", function () {
         $spec = new pecs\Spec();
         expect($spec)->to_be_an_instance_of('pecs\\Suite');
     });
     it("should have a description", function () {
         $spec = new pecs\Spec('foo');
         expect($spec->description)->to_be('foo');
     });
     it("should not include the suite's description", function () {
         $suite = new pecs\Suite('foo');
         $spec = new pecs\Spec('bar', null, $suite);
         expect($spec->description)->to_be('bar');
     });
     it("should pass by default", function () {
         $spec = new pecs\Spec();
         expect($spec->passed())->to_be_true();
         expect($spec->failed())->to_be_false();
     });
     it("should not pass if fail is called", function () {
         $spec = new pecs\Spec();
         $spec->fail('boat');
         expect($spec->passed())->to_be_false();
         expect($spec->failed())->to_be_true();
     });
     it("should allow fail to be called more than once", function () {
         $spec = new pecs\Spec();
         $spec->fail('boat');
         $spec->fail('whale');
         expect($spec->passed())->to_be_false();
         expect($spec->failed())->to_be_true();
         expect($spec->failures)->to_have_count(2);
     });
     it("should convert failure strings to exceptions", function () {
         $spec = new pecs\Spec();
         $spec->fail('boat');
         expect($spec->failures)->to_have_count(1);
         $failure = $spec->failures[0];
         expect($failure)->to_be_an_instance_of('Exception');
         expect($failure->getMessage())->to_be('boat');
     });
     it("should invoke the function once when run", function () {
         $called = 0;
         $spec = new pecs\Spec(null, function () use(&$called) {
             $called += 1;
         });
         expect($called)->to_be(0);
         $spec->run();
         expect($called)->to_be(1);
         $spec->run();
         expect($called)->to_be(2);
     });
     it("should catch exceptions when invoking the function", function () {
         $exception = new Exception('failsauce');
         $spec = new pecs\Spec(null, function () use($exception) {
             throw $exception;
         });
         expect($spec->failures)->to_be_empty();
         expect(function () use($spec) {
             $spec->run();
         })->not_to_throw();
         expect($spec->failures)->to_have_count(1);
         expect($spec->failures[0])->to_be($exception);
     });
     it("should return a new expect object", function () {
         $spec = new pecs\Spec();
         $expect = $spec->expect('foo');
         expect($expect)->to_be_a('pecs\\Expect');
         expect($expect->actual)->to_be('foo');
         expect($expect->spec)->to_be($spec);
     });
     it('should pass if no assertion is expected', function () {
         $spec = new pecs\Spec(null, function ($s) {
             $s->expectAssertions()->to_be(0);
         });
         $spec->run($spec);
         expect($spec->passed())->to_be_true();
         expect($spec->failed())->to_be_false();
     });
     it('should pass if some assertions are expected', function () {
         $spec = new pecs\Spec(null, function ($s) {
             $s->expect(0)->to_be(0);
             $s->expect(true)->to_be(true);
             $s->expectAssertions()->to_be(2);
         });
         $spec->run($spec);
         expect($spec->passed())->to_be_true();
         expect($spec->failed())->to_be_false();
     });
     it('should fail if assertions expectation is not fulfilled', function () {
         $spec = new pecs\Spec(null, function ($s) {
             $s->expectAssertions()->to_be(1);
         });
         $spec->run($spec);
         expect($spec->passed())->to_be_false();
         expect($spec->failed())->to_be_true();
         expect($spec->failures)->to_have_count(1);
     });
 });
Example #23
0
        });
        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');
        });
    });
});
Example #24
0
    describe('getPrecedence', function () {
        it('gets precedence', function () {
            expect($this->obj->getPrecedence())->toEqual(Operator::PRECEDENCE_LOW);
        });
    });
    describe('execute', function () {
        it('executes operation', function () {
            expect($this->obj->execute(1, 2))->toEqual(1);
        });
    });
    describe('getType', function () {
        it('gets type', function () {
            expect($this->obj->getType())->toEqual('operator');
        });
    });
    describe('getStringOrder', function () {
        it('gets string order', function () {
            expect($this->obj->getStringOrder())->toBe(1);
        });
    });
    describe('getStringBrackets', function () {
        it('gets string brackets', function () {
            expect($this->obj->getStringBrackets())->toBeFalsy();
        });
    });
    describe('__toString', function () {
        it('converts to string', function () {
            expect((string) $this->obj)->toEqual('$');
        });
    });
});
Example #25
0
 describe("->run()", function () {
     beforeEach(function () {
         $this->suite = new Suite("runner test suite", function () {
         });
         $this->passingTest = new Test("passing spec", function () {
         });
         $this->failingTest = new Test("failing spec", function () {
             throw new \Exception("fail");
         });
         $this->suite->addTest($this->passingTest);
         $this->suite->addTest($this->failingTest);
         $this->eventEmitter = new EventEmitter();
         $this->runner = new Runner($this->suite, new Configuration(), $this->eventEmitter);
     });
     it("should emit a start event when the runner starts", function () {
         $emitted = false;
         $this->eventEmitter->on('runner.start', function () use(&$emitted) {
             $emitted = true;
         });
         $this->runner->run(new TestResult($this->eventEmitter));
         assert($emitted, 'start event should have been emitted');
     });
     it("should emit an end event when the runner ends", function () {
         $emitted = false;
         $this->eventEmitter->on('runner.end', function () use(&$emitted) {
             $emitted = true;
         });
         $result = new TestResult(new EventEmitter());
         $this->runner->run($result);
         assert($emitted && $result->getTestCount() > 0, 'end event should have been emitted');
     });
     it("should emit a fail event when a spec fails", function () {
         $emitted = null;
         $exception = null;
         $this->eventEmitter->on('test.failed', function ($test, $e) use(&$emitted, &$exception) {
             $emitted = $test;
             $exception = $e;
         });
         $this->runner->run(new TestResult($this->eventEmitter));
         assert($emitted === $this->failingTest && !is_null($exception), 'fail event should have been emitted with spec and exception');
     });
     it("should emit a pass event when a spec passes", function () {
         $emitted = null;
         $this->eventEmitter->on('test.passed', function ($test) use(&$emitted) {
             $emitted = $test;
         });
         $this->runner->run(new TestResult($this->eventEmitter));
         assert($emitted === $this->passingTest, 'pass event should have been emitted');
     });
     it("should emit a pending event when a spec is pending", function () {
         $emitted = null;
         $this->eventEmitter->on('test.pending', function ($test) use(&$emitted) {
             $emitted = $test;
         });
         $this->passingTest->setPending(true);
         $this->runner->run(new TestResult($this->eventEmitter));
         assert($emitted === $this->passingTest, 'pending event should have been emitted');
     });
     it("should emit a suite:start event every time a suite starts", function () {
         $child = new Suite("child suite", function () {
         });
         $grandchild = new Suite("grandchild suite", function () {
         });
         $child->addTest($grandchild);
         $this->suite->addTest($child);
         $count = 0;
         $this->eventEmitter->on('suite.start', function () use(&$count) {
             $count++;
         });
         $this->runner->run(new TestResult($this->eventEmitter));
         assert(3 == $count, "expected 3 suite:start events to fire");
     });
     it("should emit a suite:end every time a suite ends", function () {
         $child = new Suite("child suite", function () {
         });
         $grandchild = new Suite("grandchild suite", function () {
         });
         $child->addTest($grandchild);
         $this->suite->addTest($child);
         $count = 0;
         $this->eventEmitter->on('suite.end', function () use(&$count) {
             $count++;
         });
         $this->runner->run(new TestResult($this->eventEmitter));
         assert(3 == $count, "expected 3 suite:end events to fire");
     });
     context("when configured to bail on failure", function () {
         it("should stop running on failure", function () {
             $suite = new Suite("suite", function () {
             });
             $passing = new Test("passing spec", function () {
             });
             $suite->addTest($passing);
             $childSuite = new Suite("child suite", function () {
             });
             $passingChild = new Test("passing child", function () {
             });
             $failingChild = new Test("failing child", function () {
                 throw new Exception("booo");
             });
             $passing2Child = new Test("passing2 child", function () {
             });
             $childSuite->addTest($passingChild);
             $childSuite->addTest($failingChild);
             $childSuite->addTest($passing2Child);
             $suite->addTest($childSuite);
             $passing2 = new Test("passing2 spec", function () {
             });
             $suite->addTest($passing2);
             $configuration = new Configuration();
             $configuration->stopOnFailure();
             $suite->setEventEmitter($this->eventEmitter);
             $runner = new Runner($suite, $configuration, $this->eventEmitter);
             $result = new TestResult($this->eventEmitter);
             $runner->run($result);
             assert($result->getTestCount() === 3, "spec count should be 3");
         });
     });
     $behavesLikeErrorEmitter = function () {
         $this->suite->addTest(new Test("my spec", function () {
             trigger_error("This is a user notice", E_USER_NOTICE);
         }));
         $error = [];
         $this->eventEmitter->on('error', function ($errno, $errstr, $errfile, $errline) use(&$error) {
             $error = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline);
         });
         $this->runner->run(new TestResult(new EventEmitter()));
         assert($error['errno'] == E_USER_NOTICE, "error event should have passed error constant");
         assert($error['errstr'] == "This is a user notice");
     };
     it("should emit an error event with error information", $behavesLikeErrorEmitter);
     it("should restore a previous error handler", function () use($behavesLikeErrorEmitter) {
         $handler = function ($errno, $errstr, $errfile, $errline) {
             //such errors handled. wow!
         };
         set_error_handler($handler);
         call_user_func(Closure::bind($behavesLikeErrorEmitter, $this, $this));
         $old = set_error_handler(function ($n, $s, $f, $l) {
         });
         assert($handler === $old, "runner should have restored previous handler");
     });
 });
Example #26
0
<?php

namespace Kahlan\Spec\Suite\Jit\Patcher;

use Kahlan\Jit\Parser;
use Kahlan\Jit\Patcher\Rebase;
describe("Rebase", function () {
    beforeEach(function () {
        $this->path = 'spec/Fixture/Jit/Patcher/Rebase';
        $this->patcher = new Rebase();
    });
    describe("->process()", function () {
        it("patches class's methods", function () {
            $nodes = Parser::parse(file_get_contents($this->path . '/Rebase.php'));
            $expected = file_get_contents($this->path . '/RebaseProcessed.php');
            $actual = Parser::unparse($this->patcher->process($nodes, '/the/original/path/Rebase.php'));
            expect($actual)->toBe($expected);
        });
    });
    describe("->patchable()", function () {
        it("return `true`", function () {
            expect($this->patcher->patchable('SomeClass'))->toBe(true);
        });
    });
});
Example #27
0
describe('Route', function () {
    beforeEach(function () {
        $this->container = new Container();
        $this->container->bind('Rad\\DependencyInterface', 'Rad\\DependencyImpl');
    });
    it('should be able to resolve dependencies of a responder', function () {
        $injected = null;
        $route = new Route('slug', function (DependencyInterface $rad) use(&$injected) {
            $injected = $rad;
        });
        $route->bind($this->container);
        $route->resolve();
        expect($injected)->to->be->instanceof('Rad\\DependencyImpl');
    });
    it('should be able to resolve dependencies of a class responder', function () {
        $route = new Route('slug', 'Rad\\Responder');
        $route->bind($this->container);
        $dep = $route->resolve();
        expect($dep)->to->be->an->instanceof('Rad\\DependencyImpl');
    });
    it('should be able to resolve dependencies registered as a factory', function () {
        $container = new Container();
        $container->bind('Rad\\DependencyInterface', function () {
            return new \Rad\DependencyImpl();
        });
        $route = new Route('slug', 'Rad\\Responder');
        $route->bind($container);
        $dep = $route->resolve();
        expect($dep)->to->be->an->instanceof('Rad\\DependencyImpl');
    });
    it('should be able to resolve a route if container not bound', function () {
        $executed = false;
        $route = new Route('slug', function (DependencyInterface $ignoreMe) use(&$executed) {
            $executed = true;
        });
        $route->resolve();
        expect($executed)->to->be->true;
    });
});
Example #28
0
 */
use Notes\Domain\Entity\User;
use Notes\Domain\ValueObject\StringLiteral;
use Notes\Domain\ValueObject\Uuid;
describe('Notes\\Domain\\Entity\\User', function () {
    describe('->__construct()', function () {
        it('should return a User object', function () {
            $actual = new User(new Uuid());
            expect($actual)->to->be->instanceof('\\Notes\\Domain\\Entity\\User');
        });
    });
    describe('->getId()', function () {
        it('should return the user\'s username', function () {
            $uuid = new Uuid();
            expect($uuid->isValidV4())->to->be->true();
            $user = new User($uuid);
            $actual = $user->getId();
            expect($actual)->to->be->instanceof('\\Notes\\Domain\\ValueObject\\Uuid');
            expect($actual->__toString())->equal($uuid->__toString());
        });
    });
    describe('->get/setUsername', function () {
        it('should get/set the correct the user\'s username', function () {
            $user = new User(new Uuid());
            $user->setUsername(new StringLiteral('Joe'));
            $actual = $user->getUsername();
            expect($actual)->to->be->instanceof('\\Notes\\Domain\\ValueObject\\StringLiteral');
            expect($actual->__toString())->equal('Joe');
        });
    });
});
Example #29
0
 describe("::write()", function () {
     beforeEach(function () {
         $this->output = tempnam("/tmp", "KAHLAN");
     });
     afterEach(function () {
         unlink($this->output);
     });
     it("writes the coverage to a file", function () {
         $path = 'spec' . DS . 'Fixture' . DS . 'Reporter' . DS . 'Coverage' . DS . 'ExtraEmptyLine.php';
         $collector = new Collector(['driver' => $this->driver, 'path' => $path]);
         $code = new ExtraEmptyLine();
         $collector->start();
         $code->shallNotPass();
         $collector->stop();
         $success = Coveralls::write(['collector' => $collector, 'file' => $this->output, 'service_name' => 'kahlan-ci', 'service_job_id' => '123', 'repo_token' => 'ABC']);
         expect($success)->toBe(585);
         $json = file_get_contents($this->output);
         $actual = json_decode($json, true);
         unset($actual['run_at']);
         expect($actual['service_name'])->toBe('kahlan-ci');
         expect($actual['service_job_id'])->toBe('123');
         expect($actual['repo_token'])->toBe('ABC');
         $coverage = $actual['source_files'][0];
         expect($coverage['name'])->toBe($path);
         expect($coverage['source'])->toBe(file_get_contents($path));
         expect($coverage['coverage'])->toHaveLength(16);
     });
     it("throws an exception no file is set", function () {
         expect(function () {
             Coveralls::write([]);
         })->toThrow(new RuntimeException("Missing file name"));
     });
 });
            beforeEach(function () {
                $this->template = new ArrayTemplate([]);
                $this->matcher->setTemplate($this->template);
            });
            it('should return the set template', function () {
                expect($this->matcher->getTemplate())->to->equal($this->template);
            });
        });
    });
    describe('->getArguments()', function () {
        it('should fetch callable arguments', function () {
            $args = [1, 2, 3];
            $this->matcher->setArguments($args);
            expect($this->matcher->getArguments())->to->equal($args);
        });
    });
    describe('->getExpectedMessage()', function () {
        it('should fetch expected message', function () {
            $expected = 'expected';
            $this->matcher->setExpectedMessage($expected);
            expect($this->matcher->getExpectedMessage())->to->equal($expected);
        });
    });
    describe('->getMessage()', function () {
        it('should fetch the actual message', function () {
            $expected = 'expected';
            $this->matcher->setMessage($expected);
            expect($this->matcher->getMessage())->to->equal($expected);
        });
    });
});