<?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
    $firefox_location = getenv('SELENIUM_FIREFOX_HOST') !== false ? getenv('SELENIUM_FIREFOX_HOST') : 'localhost';
    $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 #3
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 #4
0
                return $chain->next($message);
            });
            expect(Filter::registered('spec.newclosure'))->toBe(true);
        });
        it("registers a closure with no name", function () {
            $name = Filter::register(function ($chain, $message) {
                $message = "My {$message}";
                return $chain->next($message);
            });
            expect(Filter::registered($name))->toBe(true);
        });
    });
    describe("::unregister()", function () {
        it("unregisters a closure", function () {
            Filter::register('spec.newclosure', function ($chain, $message) {
                $message = "My {$message}";
                return $chain->next($message);
            });
            Filter::unregister('spec.newclosure');
            expect(Filter::registered('spec.newclosure'))->toBe(false);
        });
    });
    describe("::resets()", function () {
        it("clears all the filters", function () {
            Filter::reset();
            expect(Filter::registered('spec.my_prefix'))->toBe(false);
            expect(Filter::registered('spec.be_prefix'))->toBe(false);
            expect(Filter::registered('spec.no_chain'))->toBe(false);
        });
    });
});
<?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();
        });
    });
});
Example #7
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::register('mockery.register.close', function ($chain) {
    $this->suite()->afterEach(function () {
        \Mockery::close();
    });
    return $chain->next();
});
Filter::apply($this, 'run', 'mockery.register.close');
Filter::apply($this, 'interceptor', 'doctrine.exclude.annotations');
Filter::apply($this, 'run', 'doctrine.annotations.autoloader');
<?php

use filter\Filter;
use kahlan\reporter\Coverage;
use kahlan\reporter\coverage\driver\Xdebug;
use kahlan\reporter\coverage\exporter\Coveralls;
use kahlan\reporter\coverage\exporter\CodeClimate;
$args = $this->args();
$args->argument('coverage', 'default', 3);
Filter::register('kahlan.coverage', function ($chain) {
    if (!extension_loaded('xdebug')) {
        return;
    }
    $reporters = $this->reporters();
    $coverage = new Coverage(['verbosity' => $this->args()->get('coverage'), 'driver' => new Xdebug(), 'path' => $this->args()->get('src'), 'exclude' => ['src/init.php', 'src/cli/Kahlan.php', 'src/reporter/coverage/driver/Xdebug.php', 'src/reporter/coverage/Collector.php', 'src/reporter/coverage/driver/HHVM.php', 'src/reporter/Dot.php', 'src/reporter/Bar.php', 'src/reporter/Verbose.php', 'src/reporter/Terminal.php', 'src/reporter/Reporter.php', 'src/reporter/Coverage.php', 'src/reporter/Pretty.php'], 'colors' => !$this->args()->get('no-colors')]);
    $reporters->add('coverage', $coverage);
});
Filter::apply($this, 'coverage', 'kahlan.coverage');
Filter::register('kahlan.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]);
    CodeClimate::write(['collector' => $reporter, 'file' => 'codeclimate.json', 'branch' => getenv('TRAVIS_BRANCH') ?: null, 'repo_token' => 'a4b5637db5629f60a5d3fc1a070b2339479ff8989c6491dfc6a19cada5e4ffaa']);
    return $chain->next();
});
Filter::apply($this, 'reporting', 'kahlan.coverage-exporter');