<?php

use filter\Filter;
use kahlan\reporter\Coverage;
use kahlan\reporter\coverage\exporter\CodeClimate;
$args = $this->args();
$args->argument('coverage', 'default', 3);
Filter::register('kahlan.coverage-exporter', function ($chain) {
    $reporter = $this->reporters()->get('coverage');
    if (!$reporter || !getenv('CODECLIMATE_REPO_TOKEN')) {
        return $chain->next();
    }
    CodeClimate::write(['collector' => $reporter, 'file' => 'codeclimate.json', 'branch' => getenv('TRAVIS_BRANCH') ?: null, 'repo_token' => getenv('CODECLIMATE_REPO_TOKEN')]);
    return $chain->next();
});
Filter::apply($this, 'reporting', 'kahlan.coverage-exporter');
require_once __DIR__ . '/spec/init.php';
Example #2
0
<?php

use Doctrine\Common\Annotations\AnnotationRegistry;
use filter\Filter;
use jit\Interceptor;
Filter::register('doctrine.exclude.annotations', function ($chain) {
    $extra = ['Doctrine\\Common\\Annotations\\Annotation'];
    $exclude = $this->args()->get('exclude');
    $exclude = is_array($exclude) ? $exclude + $extra : $extra;
    $this->args()->set('exclude', $exclude);
    return $chain->next();
});
Filter::register('doctrine.annotations.autoloader', function ($chain) {
    AnnotationRegistry::registerLoader(Interceptor::instance()->loader());
    return $chain->next();
});
Filter::apply($this, 'interceptor', 'doctrine.exclude.annotations');
Filter::apply($this, 'run', 'doctrine.annotations.autoloader');
Example #3
0
    $chrome_location = getenv('SELENIUM_CHROME_HOST') !== false ? getenv('SELENIUM_CHROME_HOST') : 'localhost';
    $firefox_selenium_host = "http://{$firefox_location}:4444/wd/hub";
    $chrome_selenium_host = "http://{$chrome_location}:4444/wd/hub";
    $mink = new Mink(['firefox' => new Session(new Selenium2Driver('firefox', ['browserName' => 'firefox'], $firefox_selenium_host)), 'chrome' => new Session(new Selenium2Driver('chrome', ['browserName' => 'chrome'], $chrome_selenium_host))]);
    $mink->setDefaultSessionName($default_browser);
    /** @var Suite $root */
    $root = $this->suite();
    $root->mink = $mink;
    $root->beforeEach(function () use($mink) {
        $mink->resetSessions();
    });
    $root->after(function () use($mink) {
        $mink->stopSessions();
    });
    return $chain->next();
});
Filter::register('specs.prepare', function ($chain) {
    $callback = (require_once __DIR__ . '/prepare.php');
    /** @var Suite $root */
    $root = $this->suite();
    $root->before($callback);
    return $chain->next();
});
Filter::apply($this, 'run', 'mockery.register.close');
Filter::apply($this, 'run', 'mink.register');
Filter::apply($this, 'run', 'symfony.register');
Filter::apply($this, 'interceptor', 'doctrine.exclude.annotations');
Filter::apply($this, 'load', 'specs.default.path');
Filter::apply($this, 'run', 'doctrine.annotations.autoloader');
Filter::apply($this, 'load', 'specs.prepare');
Example #4
0
             $filters = Filter::filters();
             expect($filters)->toHaveLength(1);
             expect(isset($filters[$this->class]))->toBe(true);
         });
         it("imports class based filters", function () {
             Filter::filters([$this->class => [Filter::registered('spec.my_prefix')]]);
             $filters = Filter::filters();
             expect($filters)->toHaveLength(1);
             expect(isset($filters[$this->class]))->toBe(true);
         });
     });
 });
 describe("::apply()", function () {
     it("throws an Exception when trying to apply a filter on an unfilterable context", function () {
         $closure = function () {
             Filter::apply(null, 'filterable', 'spec.my_prefix');
         };
         expect($closure)->toThrow(new Exception("Error this context can't be filtered."));
     });
 });
 describe("::registered()", function () {
     it("exports the `Filter` class data", function () {
         $registered = Filter::registered();
         expect($registered)->toHaveLength(3);
         Filter::reset();
         Filter::register($registered);
         $registered = Filter::registered();
         expect($registered)->toHaveLength(3);
     });
 });
 describe("::register()", function () {
<?php

use filter\Filter;
use kahlan\reporter\coverage\exporter\Coveralls;
$args = $this->args();
$args->argument('coverage', 'default', 3);
Filter::register('phalcon.namespace', function ($chain) {
    $this->_autoloader->addPsr4('Spec\\Models\\', __DIR__ . '/spec/models/');
});
Filter::register('phalcon.coverage-exporter', function ($chain) {
    $reporter = $this->reporters()->get('coverage');
    if (!$reporter) {
        return;
    }
    Coveralls::write(['collector' => $reporter, 'file' => 'coveralls.json', 'service_name' => 'travis-ci', 'service_job_id' => getenv('TRAVIS_JOB_ID') ?: null]);
    return $chain->next();
});
Filter::apply($this, 'namespaces', 'phalcon.namespace');
Filter::apply($this, 'reporting', 'phalcon.coverage-exporter');
$di = new \Phalcon\DI\FactoryDefault();
$di->setShared('db', function () {
    return new \Phalcon\Db\Adapter\Pdo\Sqlite(['dbname' => __DIR__ . '/spec/db.sqlite']);
});
\Phalcon\DI::setDefault($di);
Example #6
0
            Filter::apply($this->specs, 'load', 'spec.load');
            Filter::register('spec.reporters', function ($chain) use(&$order) {
                $order[] = 'reporters';
            });
            Filter::apply($this->specs, 'reporters', 'spec.reporters');
            Filter::register('spec.matchers', function ($chain) use(&$order) {
                $order[] = 'matchers';
            });
            Filter::apply($this->specs, 'matchers', 'spec.matchers');
            Filter::register('spec.run', function ($chain) use(&$order) {
                $order[] = 'run';
            });
            Filter::apply($this->specs, 'run', 'spec.run');
            Filter::register('spec.reporting', function ($chain) use(&$order) {
                $order[] = 'reporting';
            });
            Filter::apply($this->specs, 'reporting', 'spec.reporting');
            Filter::register('spec.stop', function ($chain) use(&$order) {
                $order[] = 'stop';
            });
            Filter::apply($this->specs, 'stop', 'spec.stop');
            Filter::register('spec.quit', function ($chain) use(&$order) {
                $order[] = 'quit';
            });
            Filter::apply($this->specs, 'quit', 'spec.quit');
            $this->specs->run();
            expect($order)->toBe(['bootstrap', 'interceptor', 'namespaces', 'patchers', 'load', 'reporters', 'matchers', 'run', 'reporting', 'stop', 'quit']);
            Interceptor::unpatch();
        });
    });
});