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


PHP afterEach函数代码示例

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


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

示例1: describe

use Ayaml\Ayaml;
use Ayaml\Fixture\YamlData;
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
describe('\\Ayaml\\Fixture\\YamlData', function () {
    context('load', function () {
        beforeEach(function () {
            Ayaml::registerBasePath(__DIR__ . '/../../SampleYaml');
            Ayaml::registerBasePath(__DIR__ . '/../../SampleYaml/AnotherPath');
        });
        it('should load multiple paths', function () {
            expect(Ayaml::file('another_path'))->to->be->instanceof('\\Ayaml\\Container');
        });
        afterEach(function () {
            $reflection = new \ReflectionProperty('\\Ayaml\\Ayaml', 'basePaths');
            $reflection->setAccessible(true);
            $reflection->setValue([]);
        });
    });
    context('getSchema', function () {
        context('normal case', function () {
            beforeEach(function () {
                $data = SymfonyYaml::parse(file_get_contents(__DIR__ . '/../../SampleYaml/user.yml', SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE));
                $this->yamlData = new YamlData($data);
            });
            it('should get schema correctly', function () {
                $validUser = $this->yamlData->getSchema('valid_user');
                $expected = ['id' => 1, 'name' => 'Taro', 'created' => '2014-01-01 00:00:00'];
                expect($validUser)->to->equal($expected);
            });
            it('should get nested data', function () {
开发者ID:gong023,项目名称:ayaml,代码行数:30,代码来源:YamlData.spec.php

示例2: describe

<?php

namespace Kahlan\Spec\Suite\Analysis;

use Exception;
use Kahlan\Analysis\Debugger;
use Kahlan\Plugin\Stub;
describe("Debugger", function () {
    beforeEach(function () {
        $this->loader = Debugger::loader();
    });
    afterEach(function () {
        Debugger::loader($this->loader);
    });
    describe("::trace()", function () {
        it("returns a default backtrace string", function () {
            $backtrace = Debugger::trace();
            expect($backtrace)->toBeA('string');
            $backtrace = explode("\n", $backtrace);
            expect(empty($backtrace))->toBe(false);
        });
        it("returns a custom backtrace string", function () {
            $backtrace = Debugger::trace(['trace' => debug_backtrace()]);
            expect($backtrace)->toBeA('string');
            $backtrace = explode("\n", $backtrace);
            expect(empty($backtrace))->toBe(false);
        });
        it("returns a backtrace of an Exception", function () {
            $backtrace = Debugger::trace(['trace' => new Exception('World Destruction Error!')]);
            expect($backtrace)->toBeA('string');
            $backtrace = explode("\n", $backtrace);
开发者ID:Ilyes512,项目名称:kahlan,代码行数:31,代码来源:DebuggerSpec.php

示例3: expect

            $carry[] = $item['name'];
            return $carry;
        });
        expect($names)->toBe(['gebert', 'marvin.maybelle', 'zabernathy']);
    });
    it("should order", function () {
        $_GET = ['columns' => [['data' => 'name', 'searchable' => "true"]], 'order' => [['column' => 0, 'dir' => 'desc']]];
        $dataTables = new QueryBuilder(20);
        $dataTables->setBuilder($this->builder);
        $dataTables->setColumns(['name', 'email']);
        $dataTables->setParser(new ParamsParser(10));
        $response = $dataTables->getResponse();
        expect(count($response['data']))->toBe(10);
        expect($response['data'][0]['name'])->toBe('zcremin');
    });
    it("should order asc", function () {
        $_GET = ['columns' => [['data' => 'name', 'searchable' => "true"]], 'order' => [['column' => 0, 'dir' => 'asc']]];
        $dataTables = new QueryBuilder(20);
        $dataTables->setBuilder($this->builder);
        $dataTables->setColumns(['name', 'email']);
        $dataTables->setParser(new ParamsParser(10));
        $response = $dataTables->getResponse();
        expect(count($response['data']))->toBe(10);
        expect($response['data'][0]['name'])->toBe('adelia13');
    });
    afterEach(function () {
        unset($_GET);
        unset($_POST);
        unset($_REQUEST);
    });
});
开发者ID:aisuhua,项目名称:phalcon-datatables,代码行数:31,代码来源:QueryBuilderSpec.php

示例4: touch

             touch($this->temp . DS . 'CachedClass.php', $time - 1);
             $this->interceptor->watch([$this->temp . DS . 'watched1.php', $this->temp . DS . 'watched2.php']);
             expect($this->interceptor->cached($this->temp . DS . 'CachedClass.php'))->toBe(false);
         });
     });
 });
 describe("->clearCache()", function () {
     beforeEach(function () {
         $this->customCachePath = Dir::tempnam(null, 'cache');
         $this->interceptor = Interceptor::patch(['cachePath' => $this->customCachePath]);
         $this->temp = Dir::tempnam(null, 'cache');
         $this->interceptor->cache($this->temp . DS . 'CachedClass1.php', '');
         $this->interceptor->cache($this->temp . DS . 'nestedDir/CachedClass2.php', '');
     });
     afterEach(function () {
         Dir::remove($this->temp);
     });
     it("clears the cache", function () {
         $this->interceptor->clearCache();
         expect(file_exists($this->customCachePath))->toBe(false);
     });
     it("bails out if the cache has already been cleared", function () {
         $this->interceptor->clearCache();
         $this->interceptor->clearCache();
         expect(file_exists($this->customCachePath))->toBe(false);
     });
 });
 describe("->watch()/unwatch()", function () {
     it("add some file to be watched", function () {
         $this->temp = Dir::tempnam(null, 'cache');
         touch($this->temp . DS . 'watched1.php');
开发者ID:Ilyes512,项目名称:kahlan,代码行数:31,代码来源:InterceptorSpec.php

示例5: describe

use Exception;
use RuntimeException;
use stdClass;
use DateTime;
use Kahlan\Specification;
use Kahlan\Matcher;
use Kahlan\Expectation;
use Kahlan\Plugin\Stub;
describe("Expectation", function () {
    beforeEach(function () {
        $this->matchers = Matcher::get();
    });
    afterEach(function () {
        Matcher::reset();
        foreach ($this->matchers as $name => $value) {
            foreach ($value as $for => $class) {
                Matcher::register($name, $class, $for);
            }
        }
    });
    describe("->__call()", function () {
        it("throws an exception when using an undefined matcher name", function () {
            $closure = function () {
                $result = Expectation::expect(true)->toHelloWorld(true);
            };
            expect($closure)->toThrow(new Exception("Unexisting matcher attached to `'toHelloWorld'`."));
        });
        it("throws an exception when a specific class matcher doesn't match", function () {
            Matcher::register('toEqualCustom', Stub::classname(['extends' => 'Kahlan\\Matcher\\ToEqual']), 'stdClass');
            $closure = function () {
                $result = Expectation::expect([])->toEqualCustom(new stdClass());
            };
开发者ID:Ilyes512,项目名称:kahlan,代码行数:32,代码来源:ExpectationSpec.php

示例6: describe

<?php

namespace Lead\Net\Spec\Suite\Http;

use Lead\Collection\Collection;
use Lead\Net\Http\Format;
use Lead\Net\Http\Media;
use Lead\Net\Http\Response;
describe("Media", function () {
    afterEach(function () {
        Media::reset();
    });
    describe("::set()", function () {
        it("supports custom handlers", function () {
            Media::set('csv', ['application/csv'], ['encode' => function ($data) {
                ob_start();
                $out = fopen('php://output', 'w');
                foreach ($data as $record) {
                    fputcsv($out, $record);
                }
                fclose($out);
                return ob_get_clean();
            }]);
            $response = new Response();
            $response->format('csv');
            $data = [['John', 'Doe', '123 Main St.', 'Anytown, CA', '91724'], ['Jane', 'Doe', '124 Main St.', 'Anytown, CA', '91724']];
            $response->set($data);
            $expected = 'John,Doe,"123 Main St.","Anytown, CA",91724' . "\n";
            $expected .= 'Jane,Doe,"124 Main St.","Anytown, CA",91724' . "\n";
            expect($response->body())->toBe($expected);
            expect((string) $response->headers['Content-Type'])->toBe('Content-Type: application/csv');
开发者ID:crysalead,项目名称:net,代码行数:31,代码来源:Media.spec.php

示例7: describe

namespace chaos\spec\suite;

use stdClass;
use DateTime;
use InvalidArgumentException;
use chaos\Model;
use chaos\Schema;
use chaos\collection\Collection;
use kahlan\plugin\Stub;
describe("Model", function () {
    before(function () {
        $this->model = Stub::classname(['extends' => Model::class]);
    });
    afterEach(function () {
        $model = $this->model;
        $model::reset();
    });
    describe("::config()", function () {
        it("configures the model", function () {
            $model = $this->model;
            $model::config(['schema' => $schema = Stub::create(), 'validator' => $validator = Stub::create(), 'finders' => $finders = Stub::create(), 'query' => $query = ['option' => 'value'], 'connection' => $connection = Stub::create(), 'conventions' => $conventions = Stub::create()]);
            expect($model::schema())->toBe($schema);
            expect($model::validator())->toBe($validator);
            expect($model::finders())->toBe($finders);
            expect($model::query())->toBe($query);
            expect($model::connection())->toBe($connection);
            expect($model::conventions())->toBe($conventions);
            $model::reset();
            expect($model::schema())->not->toBe($schema);
            expect($model::validator())->not->toBe($validator);
            expect($model::finders())->not->toBe($finders);
开发者ID:ssgonchar,项目名称:chaos,代码行数:31,代码来源:ModelSpec.php

示例8: describe

    $_POST = $config['POST'];
    $_FILES = $config['FILES'];
    return $config;
}
describe("Request", function () {
    beforeAll(function () {
        $this->globalNames = ['_GET', '_POST', '_SERVER'];
        $this->oldEnv = [];
        foreach ($this->globalNames as $varname) {
            $this->oldEnv[$varname] = $GLOBALS[$varname];
            unset($GLOBALS[$varname]);
        }
    });
    afterEach(function () {
        foreach ($this->globalNames as $varname) {
            $GLOBALS[$varname] = $this->oldEnv[$varname];
        }
    });
    describe("__construct", function () {
        it("sets default values", function () {
            $request = new Request();
            expect($request->export())->toEqual(['basePath' => '', 'locale' => null, 'data' => [], 'params' => [], 'env' => $request->env, 'method' => 'GET', 'scheme' => 'http', 'version' => '1.1', 'host' => 'localhost', 'port' => 80, 'path' => '/', 'query' => '', 'fragment' => '', 'username' => null, 'password' => null, 'url' => 'http://localhost/', 'stream' => $request->stream()]);
            $expected = <<<EOD
Host: localhost
Connection: Close
User-Agent: Mozilla/5.0
Content-Type: text/html; charset=utf-8


EOD;
            expect((string) $request->headers)->toBe($expected);
开发者ID:crysalead,项目名称:net,代码行数:31,代码来源:Requests.spec.php

示例9: afterEach

            $this->schema->formatter('cast', 'id', $handlers['integer']);
            $this->schema->formatter('cast', 'serial', $handlers['integer']);
            $this->schema->formatter('cast', 'integer', $handlers['integer']);
            $this->schema->formatter('cast', 'float', $handlers['float']);
            $this->schema->formatter('cast', 'decimal', $handlers['decimal']);
            $this->schema->formatter('cast', 'date', $handlers['date']);
            $this->schema->formatter('cast', 'datetime', $handlers['datetime']);
            $this->schema->formatter('cast', 'boolean', $handlers['boolean']);
            $this->schema->formatter('cast', 'null', $handlers['null']);
            $this->schema->formatter('cast', 'string', $handlers['string']);
            $this->schema->formatter('cast', '_default_', $handlers['string']);
            $this->schema->bind('gallery', ['relation' => 'belongsTo', 'to' => Gallery::class, 'keys' => ['gallery_id' => 'id']]);
            $this->schema->bind('images_tags', ['relation' => 'hasMany', 'to' => ImageTag::class, 'keys' => ['id' => 'image_id']]);
            $this->schema->bind('tags', ['relation' => 'hasManyThrough', 'to' => Tag::class, 'through' => 'images_tags', 'using' => 'tag']);
        });
        afterEach(function () {
            Image::reset();
        });
        it("gets/sets the conventions", function () {
            $image = $this->schema->cast(null, ['id' => '1', 'gallery_id' => '2', 'name' => 'image.jpg', 'title' => 'My Image', 'score' => '8.9', 'tags' => [['id' => '1', 'name' => 'landscape'], ['id' => '2', 'name' => 'mountain']]]);
            expect($image->id)->toBeAn('integer');
            expect($image->gallery_id)->toBeAn('integer');
            expect($image->name)->toBeA('string');
            expect($image->title)->toBeA('string');
            expect($image->score)->toBeA('float');
            expect($image->tags)->toBeAnInstanceOf('chaos\\collection\\Through');
            expect($image->tags[0])->toBeAnInstanceOf('chaos\\spec\\fixture\\model\\Tag');
            expect($image->tags[1])->toBeAnInstanceOf('chaos\\spec\\fixture\\model\\Tag');
        });
    });
});
开发者ID:ssgonchar,项目名称:chaos,代码行数:31,代码来源:SchemaSpec.php

示例10: describe

<?php

use Evenement\EventEmitter;
use Peridot\Concurrency\Environment\Environment;
use Peridot\Configuration;
describe('Environment', function () {
    beforeEach(function () {
        $this->emitter = new EventEmitter();
        $this->readStream = tmpfile();
        $this->writeStream = tmpfile();
        $this->environment = new Environment($this->emitter, $this->readStream, $this->writeStream);
    });
    afterEach(function () {
        fclose($this->readStream);
        fclose($this->writeStream);
    });
    describe('->getEventEmitter()', function () {
        it('should return the event emitter', function () {
            expect($this->environment->getEventEmitter())->to->equal($this->emitter);
        });
    });
    describe('->getReadStream()', function () {
        it('should return the read stream', function () {
            expect($this->environment->getReadStream())->to->equal($this->readStream);
        });
    });
    describe('->getWriteStream()', function () {
        it('should return the write stream', function () {
            expect($this->environment->getWriteStream())->to->equal($this->writeStream);
        });
    });
开发者ID:peridot-php,项目名称:peridot-concurrency,代码行数:31,代码来源:environment.spec.php

示例11: Configuration

     $config = new Configuration();
     $config->setDsl(__DIR__ . '/../../../../fixtures/environment/dsl.php');
     $config->setConfigurationFile(__DIR__ . '/../../../../fixtures/environment/peridot.php');
     $reader = $this->getProphet()->prophesize('Peridot\\Concurrency\\Environment\\ReaderInterface');
     $reader->getConfiguration()->willReturn($config);
     $looper = $this->getProphet()->prophesize('Peridot\\Concurrency\\Runner\\StreamSelect\\Application\\LooperInterface');
     $looper->loop(Argument::type('Peridot\\Runner\\Context'), $environment, $this->message)->shouldBeCalled();
     $this->application = new Application($environment, $reader->reveal(), $looper->reveal());
     /**
      * An application does not listen until run.
      */
     $this->application->run($this->message);
 });
 afterEach(function () {
     fclose($this->readStream);
     fclose($this->writeStream);
     $this->getProphet()->checkPredictions();
 });
 context('when a suite.start event is emitted', function () {
     it('should write a suite.start event to the test message', function () {
         $suite = new Suite('description');
         $suite->setTitle('my title');
         $this->emitter->emit('suite.start', [$suite]);
         $this->expectMessageValues($this->writeStream, ['s', 'suite.start', 'description', 'my title']);
     });
     it('should write nothing if the suite has no description', function () {
         $suite = new Suite('');
         $this->emitter->emit('suite.start', [$suite]);
         $content = $this->readMessage($this->writeStream);
         expect($content)->to->be->empty;
     });
开发者ID:peridot-php,项目名称:peridot-concurrency,代码行数:31,代码来源:application.spec.php

示例12: putenv

                putenv('ANSICON=1');
            });
            afterEach(function () {
                putenv('ANSICON=' . $this->ansicon);
            });
            it('should add escape sequences if ansicon is enabled', function () {
                $colored = $this->reporter->color('success', 'good');
                assert($colored == "[32mgood[39m", "expected color with ansicon enabled");
            });
        });
        context('when in a tty terminal', function () {
            beforeEach(function () {
                $this->reporter = new TtyTestReporter(new Configuration(), new ConsoleOutput(), new EventEmitter());
            });
            afterEach(function () {
                putenv('PERIDOT_TTY=');
            });
            it('should set the PERIDOT_TTY environment variable', function () {
                $this->reporter->color('success', 'text');
                assert(getenv('PERIDOT_TTY') !== false, "peridot tty environment variable should have been set");
            });
            it('should write colors if the PERIDOT_TTY environment variable is present', function () {
                putenv('PERIDOT_TTY=1');
                $text = $this->reporter->color('success', 'text');
                assert("[32mtext[39m" == $text, "colored text should have been written");
            });
        });
    });
});
class WindowsTestReporter extends AbstractBaseReporter
{
开发者ID:brianium,项目名称:peridot,代码行数:31,代码来源:abstract-base-reporter.spec.php

示例13: call_user_func

            $this->context->addSetupFunction($before);
            $result = call_user_func($this->context->getCurrentSuite()->getSetupFunctions()[0]);
            assert("result" === $result, "expected addSetupFunction to register setup function");
        });
    });
    describe('->addTearDownFunction()', function () {
        it('should register an afterEach callback on the current suite', function () {
            $after = function () {
                return "result";
            };
            $this->context->addTearDownFunction($after);
            $result = call_user_func($this->context->getCurrentSuite()->getTearDownFunctions()[0]);
            assert("result" === $result, "expected addSetupFunction to register tear down function");
        });
    });
    describe('::getInstance()', function () {
        beforeEach(function () {
            $this->property = $this->reflection->getProperty('instance');
            $this->property->setAccessible(true);
            $this->previous = $this->property->getValue();
            $this->property->setValue(null);
        });
        afterEach(function () {
            $this->property->setValue($this->previous);
        });
        it("should return a singleton instance of Context", function () {
            $context = Context::getInstance();
            assert($context instanceof Context, "getInstance should return a Context");
        });
    });
});
开发者ID:brianium,项目名称:peridot,代码行数:31,代码来源:context.spec.php

示例14: describe

<?php

namespace Lead\Validator\Spec\Suite;

use InvalidArgumentException;
use stdClass;
use DateTime;
use Lead\Validator\Checker;
use Kahlan\Plugin\Monkey;
describe("Checker", function () {
    afterEach(function () {
        Checker::reset();
    });
    describe("::set()", function () {
        it("adds some local handlers", function () {
            Checker::set('zeroToNine', '/^[0-9]$/');
            Checker::set('tenToNineteen', '/^1[0-9]$/');
            expect(Checker::handlers())->toContainKeys('zeroToNine', 'tenToNineteen');
        });
        it("sets validation handlers", function () {
            Checker::set('zeroToNine', '/^[0-9]$/');
            Checker::set('tenToNineteen', '/^1[0-9]$/');
            expect(Checker::has('zeroToNine'))->toBe(true);
            expect(Checker::has('tenToNineteen'))->toBe(true);
            expect(Checker::get('zeroToNine'))->toBe('/^[0-9]$/');
            expect(Checker::get('tenToNineteen'))->toBe('/^1[0-9]$/');
        });
    });
    describe("::get()", function () {
        it("throws an exceptions for unexisting validation handler", function () {
            $closure = function () {
开发者ID:crysalead,项目名称:validator,代码行数:31,代码来源:Checker.spec.php

示例15: expect

         expect($items[1]->getId())->should('be', $fixtureIds[1]);
         expect($items[2]->getId())->should('be', $fixtureIds[2]);
         expect($items[3]->getId())->should('be', $item->getId());
     });
 });
 describe('getPrevious() and getNext()', function () {
     $fixtureIds = null;
     beforeEach(function () use(&$fixtureIds) {
         Project::sc()->createService('EntityManager');
         $em = Project::sc()->em();
         $em->beginTransaction();
         $repository = $em->getRepository('Gradua\\DoctrineExtensions\\OrderedItem\\ExampleEntities\\OrderedItem');
         $fixtureIds = OrderedItemFixtures::threeNonSequencialItems($em);
     });
     afterEach(function () {
         Project::sc()->em()->rollback();
     });
     it('should get the previous item', function () use(&$fixtureIds) {
         $em = Project::sc()->em();
         $repository = $em->getRepository('Gradua\\DoctrineExtensions\\OrderedItem\\ExampleEntities\\OrderedItem');
         $items = $repository->findAll();
         expect($repository->getPrevious($items[1])->getId())->should('be', $items[0]->getId());
     });
     it('should get the previous item when there are more than one result on the database', function () use(&$fixtureIds, &$parentId) {
         $em = Project::sc()->em();
         $repository = $em->getRepository('Gradua\\DoctrineExtensions\\OrderedItem\\ExampleEntities\\OrderedItem');
         $items = $repository->findAll();
         expect($repository->getPrevious($items[2])->getId())->should('be', $items[1]->getId());
     });
     it('should get null when there is no previous item', function () use(&$fixtureIds) {
         $em = Project::sc()->em();
开发者ID:brunoreis,项目名称:DoctrineLearning,代码行数:31,代码来源:OrderedItem.spec.php


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