Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add a helper to check if the current user is root | <?php
namespace Concrete\Core\Foundation\Environment;
class User
{
/**
* @var FunctionInspector
*/
protected $functionInspector;
/**
* @param FunctionInspector $functionInspector
*/
public function __construct(FunctionInspector $functionInspector)
{
$this->functionInsp... | |
Add concept class of data mapper | <?php
namespace HydrefLab\SWAPI;
use ReflectionClass;
class Mapper
{
/**
* @param object $data
* @param string|object $className
* @return object
*/
public function map($data, $className)
{
if (true === is_object($className)) {
$className = get_class($className);
... | |
Use JSON datatype for news page | <?php
use Illuminate\Database\Migrations\Migration;
class JsonNewsPostPage extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// DBAL (2.10.0) can't migrate to JSON datatype.
// It only creates TEXT with DC2Type:json as comment.
... | |
Sort an array in reverse order |
<?php
$fruits = array("lemon", "orange", "banana", "apple");
rsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
| |
Add Middleware to properly deal with session timeout | <?php
namespace Unicodeveloper\Http\Middleware;
use Closure;
use Illuminate\Session\Store;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
class SessionTimeout {
/**
* [$session description]
* @var [type]
*/
protected $session;
/**
* Time for user to rema... | |
Test asset: class with nullable return types | <?php
namespace ZendTest\Code\TestAsset;
class NullableReturnTypeHintedClass
{
public function arrayReturn() : ?array
{
}
public function callableReturn() : ?callable
{
}
public function intReturn() : ?int
{
}
public function floatReturn() : ?float
{
}
public fu... | |
Add ONGR Admin Extension Test | <?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\UtilsBundle\Tests\Functional\DependencyInjection;
use ONGR\AdminBundle... | |
Add the property filtering attributes controller | <?php
/*
* This file is part of Bens Penhorados, an undergraduate capstone project.
*
* (c) Fábio Santos <ffsantos92@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Http\Controllers\FilteringAttributes;
... | |
Add migration to add trainer role | <?php
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use Illuminate\Database\Migrations\Migration;
class AddTrainerRole extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Reset cached roles and permissions
... | |
Add informe stats under admin utilities | <style>
tr {
}
td {
border: 1px solid orange;
padding: 3px;
}
</style>
<?php
/**
* Elgg Reported content admin page
*
* @package ElggReportedContent
*/
$options = array('type' => 'object', 'subtype' => 'informe',
'limit' => 200
);
$list = elgg_get_entities($options);
$informes =... | |
Add bitmask for room details | <?php
namespace MssPhp\Bitmask;
class RoomDetails
{
const BASIC_INFO = 4;
const TITLE = 8;
const ROOM_IMAGES = 32;
const ROOM_FACILITIES_FILTER = 64;
const ROOM_DESCRIPTION = 256;
const ROOM_FACILITIES_DETAILS = 4096;
const ROOM_FEATURES = 32768;
const ROOM_NUMBERS = 65536;
}
| |
Add silex controller for oauth routes | <?php namespace bmwcarit\oauth;
/*
* Copyright (C) 2015, BMW Car IT GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights... | |
Move default CSRF checking into core. | <?php namespace Illuminate\Foundation\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Session\TokenMismatchException;
class VerifyCsrfToken implements Middleware {
/**
* The encryp... | |
Test page added to make sure PHPStorm is set up | <!Doctype html>
<html>
<head></head>
<title>Humble Beginnings</title>
</head>
<body>
<p>I completed the prework</p>
</body>
</html> | |
Add empty testcase for later .. would work if we could mock applications | <?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either ... | |
Add migrate table role user | <?php
use Phinx\Migration\AbstractMigration;
class CreateRoleUserTable extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.h... | |
Add address resource to the php binding. | <?php
namespace Ubivar;
class Address extends ApiResource
{
/**
* @param string $id The ID of the item to retrieve.
* @param array|string|null $opts
*
* @return Item
*/
public static function retrieve($id, $opts = null)
{
return self::_retrieve($id, $opts);
}
/**
... | |
Add test for the exponential backoff retry strategy. | <?php
declare(strict_types=1);
namespace Keystone\Queue\Retry;
use PHPUnit\Framework\TestCase;
class ExponentialBackoffRetryStrategyTest extends TestCase
{
public function testGetDelay()
{
$strategy = new ExponentialBackoffRetryStrategy();
$delay = 0;
for ($attempts = 1; $attempts <... | |
Add the Google Calendar starter application. | <?php
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiCalendarService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Calendar PHP Starter Application");
// Visit https://code.google.com/apis/console?api=calendar to generate your
// client id, client se... | |
Add tests for sentinel account management | <?php
namespace OpenCFP\Test\Unit\Infrastructure\Auth;
use Cartalyst\Sentinel\Sentinel;
use Mockery;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use OpenCFP\Domain\Services\AccountManagement;
use OpenCFP\Infrastructure\Auth\SentinelAccountManagement;
use OpenCFP\Infrastructure\Auth\SentinelUser;
use OpenCF... | |
Add DataExtension for silverstripe 3 | <?php
/**
* Class CacheIncludeSiteTreeExtension
*/
class CacheIncludeSiteTreeExtension extends DataExtension
{
/**
* @return array
*/
public function extraStatics()
{
return array(
'db' => array(
'FullLink' => 'Varchar(255)'
)
);
}
... | |
Add integration test for thrift client factory | <?php
namespace Elastification\Client\Tests\Fixtures\Unit\Transport\Thrift;
use Elastification\Client\Transport\Thrift\ThriftTransportConnectionFactory;
class ThriftTransportConnectionFactoryTest extends \PHPUnit_Framework_TestCase
{
private function guardExtensionPresent()
{
if (!extension_loaded('t... | |
Add HTTP version of API | <?php
require_once('boston_food_trucks.php');
class Request {
public $parameters;
public function parse_parameters () {
$parameters = array();
if (isset($_SERVER['QUERY_STRING'])) {
parse_str($_SERVER['QUERY_STRING'], $parameters);
}
$this->parameters = $parameters;
}
}
class Filters {
pub... | |
Add database migrations for group username styling and badges. | <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddStylingColumnsToGroupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('groups', function(Blueprint $table) {
... | |
Add book api to get the number of reviews | <?php
require_once '../admin/php/connection.php';
$index = isset($_GET['index'])? $_GET['index'] : 0;
$count = isset($_GET['count'])? $_GET['count'] : 20;
$db = open_connection();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = 'SELECT title, COUNT(reveiw.book_isbn) AS reviews
FROM book
LEF... | |
Refactor email body sync - Fix migrations | <?php
namespace Oro\Bundle\EmailBundle\Migrations\Schema\v1_20;
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\ParametrizedSqlMigrationQuery;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
use Oro\Bundle\MigrationBundle\Migration\SqlM... | <?php
namespace Oro\Bundle\EmailBundle\Migrations\Schema\v1_20;
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\ParametrizedSqlMigrationQuery;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
use Oro\Bundle\MigrationBundle\Migration\SqlM... |
Add unit tests for Pagecontext transformer | <?php
namespace Inanimatt\SiteBuilder\Transformer;
use \Mockery as m;
class PagecontextTransformerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var PagecontextTransformer
*/
protected $object;
public function testTransformRootPage()
{
$event = m::mock('Inanimatt\SiteBuilder\Ev... | |
Add Response methods to interface | <?php
namespace PhpWatson\Sdk\Interfaces;
use GuzzleHttp\Psr7\Response;
interface ResponseInterface
{
/**
* Parse an incoming PSR7 response
*
* @param Response $response
* @return mixed
*/
public function parse(Response $response);
/**
* Return true if the request produces ... | |
Add a sample application for the Google Analytics V3 API. | <?php
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiAnalyticsService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Analytics PHP Starter Application");
// Visit https://code.google.com/apis/console?api=analytics to generate your
// client id, client... | |
Add combined `citi_id`, `updated_at` index to CITI tables | <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCitiIdUpdatedAtIndexes extends Migration
{
private $tableNames = [
'agent_place_qualifiers',
'agent_roles',
'agent_types',
'agents',
... | |
Add a simple wrapper, no subdataobject loading, for SiteBotrMedia objects. | <?php
require_once 'Site/dataobjects/SiteBotrMedia.php';
require_once 'Site/dataobjects/SiteSimpleMediaWrapper.php';
/**
* A simple recordset wrapper class for SiteBotrMedia objects that doesn't
* do any pre-loading of sub-dataobjects.
*
* This is useful for cases where you just want the basic media data
*
* @p... | |
Make function to pull new kills | <?php
/**
* Providence Slack DankFrags Killboard pull
* User: ed
* Date: 08/05/15
* Time: 23:01
*/
namespace JamylBot\Killbot;
use GuzzleHttp\Client;
/**
* Class zkillMonkey
* @package JamylBot\Killbot
*/
class zkillMonkey {
/**
* @var Client
*/
protected $guzzle;
/**
* @param C... | |
Add unit testing for Controller | <?php namespace CodeIgniter;
use CodeIgniter\HTTP;
use Config\App;
/**
* Exercise our core Controller class.
* Not a lot of business logic, so concentrate on making sure
* we can exercise everything without blowing up :-/
*
* @backupGlobals enabled
*/
class ControllerTest extends \CIUnitTestCase
{
/**
* @v... | |
Add designated responder for invocation via middleware | <?php
namespace Fuzz\ApiServer;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Response;
use Fuzz\ApiServer\Exception\HttpException;
use Illuminate\Contracts\Support\Arrayable;
class Responder
{
/**
* Send a response.
*
* @param mixed $data
* @param int $status_code
* @param array... | |
Add test class for main regression class. | <?php
use mcordingley\Regression\Regression;
use mcordingley\Regression\RegressionStrategy\LinearLeastSquares;
class RegressionTest extends PHPUnit_Framework_TestCase
{
protected $regression;
public function __construct($name = null, array $data = array(), $dataName = '')
{
parent::__construc... | |
Add template for static front page | <?php
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<section class="site-hero-section">
<div class="site-title-container p-a-lg">
<h1 class="site-main-title">
Katherine <br />
Anne <br />
Porter<br />
</h1>
... | |
Add test for XHPUnsafeRendable and XHPAlwaysValidChild | <?hh
// Please see MIGRATING.md for information on how these should be used in
// practice; please don't create/use classes as unsafe as these examples.
class ExampleUnsafeRenderable implements XHPUnsafeRenderable {
public function __construct(public string $htmlString) {}
public function toHTMLString() {
re... | |
Add Base (console) Task Test | <?php
use Aedart\Scaffold\Tasks\BaseTask;
use Mockery as m;
/**
* Class BaseTaskTest
*
* @group tasks
* @group baseTask
*
* @coversDefaultClass Aedart\Scaffold\Tasks\BaseTask
* @author Alin Eugen Deac <aedart@gmail.com>
*/
class BaseTaskTest extends ConsoleTest
{
/**
* Returns a new Base Task instan... | |
Add example showing Curl::diagnose() usage | <?php
// keywords: diagnose, troubleshoot, help
require __DIR__ . '/../vendor/autoload.php';
use Curl\Curl;
$curl = new Curl();
$curl->get('https://httpbin.org/status/400');
if ($curl->error) {
echo 'An error occurred:' . "\n";
$curl->diagnose();
} else {
echo 'Response:' . "\n";
var_dump($curl->res... | |
Add a kick command to kick buried job from a tube | <?php
namespace Leezy\PheanstalkBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class KickCommand extends ContainerAwareComman... | |
Add fulltext search plugin for MySQL | <?php
/*
This plugin requires that you are running MySQL/MariaDB 5.6 or better.
Run the following against your MySQL installation in the database that contains TinyTinyRSS:
CREATE FULLTEXT INDEX title_content_search ON ttrss_entries (title, content);
*/
class Search_MySQL_FullText extends Plugin {
function abou... | |
Introduce connection factory Questions: should it have a options argument, so you can override configuration? | <?php
namespace Neos\Flow\Persistence\Doctrine;
/*
* This file is part of the Neos.Flow package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* sourc... | |
Add unit test for Route class | <?php
namespace RAPL\Tests\Unit\Mapping;
use RAPL\RAPL\Mapping\Route;
class RouteTest extends \PHPUnit_Framework_TestCase
{
public function testRoute()
{
$pattern = 'foo/bar/{id}';
$envelopes = array('foo', 'bar');
$route = new Route($pattern, $envelopes);
$this->assertSam... | |
Add tests for scope search | <?php
namespace OpenCFP\Test\Domain\Model;
use OpenCFP\Domain\Model\User;
use OpenCFP\Test\DatabaseTransaction;
/**
* @group db
*/
class UserTest extends \PHPUnit\Framework\TestCase
{
use DatabaseTransaction;
public function setUp()
{
$this->setUpDatabase();
}
public function tearDown... | |
Add logger, using psr/log interface | <?php
namespace TijsVerkoyen\Bpost;
use Psr\Log\LoggerInterface;
class Logger
{
/** @var LoggerInterface */
private $logger;
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
public function debug($message, array $context = array())
{
if (... | |
Add first useful function array_try | <?php
namespace yii\helpers;
/**
* ArrayHelper provides additional array functionality that you can use in your
* application.
*
* @author Maksim Tikhonov aka Maksio <bnr17@yandex.ru>
* @since 2.0
*/
class ArrayHelper extends BaseArrayHelper {
// Return value or empty array
public static function array... | |
Add a class for SAML2 constants. | <?php
/**
* Various SAML 2 constants.
*
* @package simpleSAMLphp
* @version $Id$
*/
class sspmod_saml2_Const {
/**
* Top-level status code indicating successful processing of the request.
*/
const STATUS_SUCCESS = 'urn:oasis:names:tc:SAML:2.0:status:Success';
/**
* Top-level status code indicating tha... | |
Add functional tests for the Archive action. | <?php
namespace Frontend\Modules\Blog\Tests\Action;
use Common\WebTestCase;
class ArchiveTest extends WebTestCase
{
public function testArchiveContainsBlogPosts()
{
$client = static::createClient();
$this->loadFixtures(
$client,
array(
'Backend\Modules... | |
Send Data to a Kinesis Delivery Stream | <?php
/**
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* This file is licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License. A copy of
* the License is located at
*
* http://aws.amazon.com/apache2.0/
... | |
Add flatten single function test suite. | <?php
namespace Mimic\Test;
use PHPUnit_Framework_TestCase;
use Mimic\Functional as F;
use ArrayIterator;
/**
* Unit Test for flattenSingle Mimic library function.
*
* @since 0.1.0
*
* @todo Need to use QuickTest library.
*/
class FlattenSingleFuncTest extends PHPUnit_Framework_TestCase {
public function dat... | |
Fix invalid typehint for subject in is_granted Twig function | <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bridge\Twig\Extension;
use Symfony\Component\Security\Acl\Voter... | <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bridge\Twig\Extension;
use Symfony\Component\Security\Acl\Voter... |
Add unit test for Conversation's form | <?php
namespace FD\PrivateMessageBundle\Tests\Form;
use FD\PrivateMessageBundle\Entity\Conversation;
use FD\PrivateMessageBundle\Entity\PrivateMessage;
use FD\PrivateMessageBundle\Form\ConversationType;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Class... | |
Add runner for specific commits | <?php
namespace Cauditor\Runners;
use Cauditor\Analyzers\AnalyzerInterface;
use Cauditor\Api;
use Cauditor\Config;
/**
* @author Matthias Mullie <cauditor@mullie.eu>
* @copyright Copyright (c) 2016, Matthias Mullie. All rights reserved.
* @license LICENSE MIT
*/
class Commits extends All implements RunnerInterfa... | |
Create a migration which initializes database | <?php
include_once 'migrate.php';
migrate(
array(
'CREATE TABLE IF NOT EXISTS
`users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(200) COLLATE... | |
Add unit test for DatabaseConnectionCheck | <?php
/**
* This file is part of the Gerrie package.
*
* (c) Andreas Grunwald <andygrunwald@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gerrie\Tests\Check;
use Gerrie\Check\DatabaseConnectionCheck;
class... | |
Add command-line script to create a CorA user. | <?php
$CORA_DIR = dirname(__FILE__) . "/../";
require_once( $CORA_DIR . "lib/globals.php" );
require_once( $CORA_DIR . "lib/connect.php" );
$dbi = new DBInterface(DB_SERVER, DB_USER, DB_PASSWORD, MAIN_DB);
$notwin = (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN');
$options = getopt("u:p:ah");
if (array_key_exists("h", $... | |
Add a test that ensures all /src files parse | <?php
class FilesParseTest extends \PHPUnit_Framework_TestCase
{
public function testFilesParse()
{
foreach ($this->getPhpFiles(DIR_BASE_CORE . "/src") as $file) {
$this->loadFile(array_shift($file));
}
}
private function getPhpFiles($path)
{
$directory = new R... | |
Add test case on xmlinflector | <?php
namespace Doctrine\Tests\OXM\Util;
use Doctrine\OXM\Util\Inflector;
class InflectorTest extends \PHPUnit_Framework_TestCase
{
public function testXmlize()
{
$this->assertEquals('xxx-yyy', Inflector::xmlize('XxxYYY'));
$this->assertEquals('with-many-many-words', Inflector::xmlize('withMa... | |
Add command to delete posts by id | <?php
namespace Rogue\Console\Commands;
use Illuminate\Console\Command;
use Rogue\Models\Post;
class DeletePosts extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rogue:deleteposts
{ids* : A space-... | |
Improve unit test about report's field. | <?php
namespace mageekguy\atoum\tests\units\report\fields\runner;
use
\mageekguy\atoum,
\mageekguy\atoum\report\fields\runner
;
require_once(__DIR__ . '/../runner.php');
require_once(__DIR__ . '/../../../../runner.php');
abstract class result extends \mageekguy\atoum\tests\units\report\fields\runner {}
?>
| <?php
namespace mageekguy\atoum\tests\units\report\fields\runner;
use
\mageekguy\atoum,
\mageekguy\atoum\report\fields\runner
;
require_once(__DIR__ . '/../../../../runner.php');
abstract class result extends \mageekguy\atoum\tests\units\report\fields\runner {}
?>
|
Add tests for the currency model | <?php
namespace Symm\BitpayClient\Tests;
use Symm\BitpayClient\Model\Currency;
/**
* CurrencyTest
*/
class CurrencyTest extends \PHPUnit_Framework_TestCase
{
protected $currency = array(
'code' => 'SEK',
'name' => 'Swedish Krona',
'rate' => 4169.1658
);
public function getCurr... | |
Create nested set comments table. | <?php
use yii\db\Schema;
use console\components\Migration;
class m150804_073905_create_nested_set_comment_table extends Migration
{
public function up()
{
$this->createTable('{{%comment_ns}}', [
'id' => Schema::TYPE_PK,
'post_id' => Schema::TYPE_INTEGER . ' NOT NULL',
... | |
Set calculated expiration dates to last day of the month. | <?php
/**
* Forces expiration dates to always be set to the end of the month.
*
* NOTE: Changing the calculated expiration date does not change the renewal date
* with the gateway, so using this alongside automatic renewals is not recommended.
*
* @param string $expiration Calculated expiration date in MySQL ... | |
Add migration for updating xform tables with jr_xform_id field | <?php
/**
* Created by PhpStorm.
* User: Godluck Akyoo
* Date: 27-Jun-16
* Time: 20:12
*/
class Migration_Update_xforms_table extends CI_Migration
{
public function up()
{
$field = array(
'jr_form_id' => array(
'type' => 'VARCHAR',
'constraint' => 255,
),
);
$this->dbforge->add_column... | |
Add tests for composer fallback | <?php
/*
* This file is part of the Foxy package.
*
* (c) François Pluchino <francois.pluchino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Foxy\Tests\Solver;
use Composer\Composer;
use Composer\IO\IOInte... | |
Add skeleton for BFS unit test | <?php
use Fhaculty\Graph\Vertex;
use Fhaculty\Graph\GraphViz;
use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Algorithm\ShortestPath\BreadthFirst;
use Fhaculty\Graph\Loader\CompleteGraph;
class BreadthFirstTest extends PHPUnit_Framework_TestCase
{
public function testOne(){
// TODO: this should ... | |
Modify void transactions to made the body of the request optional in the PHP library | <?php
/**
* Created by PhpStorm.
* User: david
* Date: 3/21/17
* Time: 9:20 PM
*/
namespace kushki\lib;
class KushkiVoidRequest
{
} | |
Clear old css cache on upgrade | <?php
namespace SV\RedisCache;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
/**
* Add-on installation, upgrade, and uninstall routines.
*/
class Setup extends AbstractSetup
{
use StepRunnerInstallTrait;
use Step... | |
Add tests for RequestStack class | <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpFoundation\Tests;
use Symfony\Component\HttpFound... | |
Test cases for the Boolean type. | <?php
// $Id$
require_once '../model/types/Boolean.inc';
require_once '../model/person_object.inc';
require_once '../../config/db_connect.inc';
require_once 'PHPUnit.php';
/**
*
* Test case for the Boolean data type
*
* @package Alpha Core Unit Tests
* @author John Collins <john@design-ireland.ne... | |
Extend size of content field to medium text | <?php
/**
* Database migration class
*
* @author Lionel Laffineur <lionel@tigron.be>
*/
namespace Skeleton\I18n;
use \Skeleton\Database\Database;
class Migration_20200625_112940_Object_text_content_medium_text extends \Skeleton\Database\Migration {
/**
* Migrate up
*
* @access public
*/
public functio... | |
Test Directory::createRecursive on all adapters | <?php
namespace React\Tests\Filesystem\Adapters;
use React\EventLoop\LoopInterface;
use React\Filesystem\ChildProcess;
use React\Filesystem\Eio;
use React\Filesystem\FilesystemInterface;
use React\Filesystem\Pthreads;
class DirectoryTest extends AbstractAdaptersTest
{
/**
* @dataProvider filesystemProvider
... | |
Update core tables to bigint | <?php
namespace OC\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OCP\Migration\ISchemaMigration;
/**
* Updates some fields to bigint if required
*/
class Version20170804201253 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = ... | |
Add unit tests for padStringFilter extension; | <?php
namespace DMS\Bundle\TwigExtensionBundle\Tests\Twig\Text;
use DMS\Bundle\TwigExtensionBundle\Twig\Text\PadStringExtension;
class PadStringExtensionTest extends \PHPUnit_Framework_TestCase
{
/**
* @var PadStringExtension
*/
protected $extension;
public function setUp()
{
$this... | |
Add interface for read model repository | <?php
/**
* @file
*/
namespace CultuurNet\UDB3\SavedSearches\ReadModel;
interface SavedSearchRepositoryInterface
{
/**
* @return SavedSearch[]
*/
public function ownedByCurrentUser();
}
| |
Add new interface for URI parser. | <?php
namespace Risna\OAuth1;
use Psr\Http\Message\UriInterface;
interface UriParserInterface
{
/**
* Check whether the given URI is absolute.
*
* @param \Psr\Http\Message\UriInterface $uri
* @return boolean
*/
public function isAbsolute(UriInterface $uri);
/**
* Check if ... | |
Add fixture for previous commit | <?php
namespace TYPO3\Flow\Tests\Functional\Property\Fixtures;
/*
* This file is part of the TYPO3.Flow package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed wi... | |
Add invalid vhost exception and exception namespace | <?php
namespace Vmwarephp\Exception;
class InvalidVhost extends \Exception {
function __construct($message = null, $code = 0, Exception $previous = null) {
$defaultMessage = 'Invalid vCenter/ESX host provided';
$message ? parent::__construct($message, $code, $previous) : parent::__construct($defaultMessage, $code... | |
Add migration to set a default value for the field 'deleted', and update existing records accordingly. | <?php
/**
* Database migration class
*
* @author Jochen Timmermans <jochen@tigron.be>
*/
namespace Skeleton\File;
use \Skeleton\Database\Database;
class Migration_20200520_162100_update_default_value_for_deleted extends \Skeleton\Database\Migration {
/**
* Migrate up
*
* @access public
*/
public functi... | |
Add test with 100% coverage for new Algorithm\Degree | <?php
use Fhaculty\Graph\Algorithm\Degree as AlgorithmDegree;
use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Vertex;
use Fhaculty\Graph\Graph;
class DegreeTest extends TestCase
{
public function testG... | |
Throw exception if the config.path is not valid | <?php
/*
* This file is part of the Cilex framework.
*
* (c) Mike van Riel <mike.vanriel@naenius.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cilex\Provider;
use Cilex\Application;
use Cilex\ServiceProviderInte... | <?php
/*
* This file is part of the Cilex framework.
*
* (c) Mike van Riel <mike.vanriel@naenius.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cilex\Provider;
use Cilex\Application;
use Cilex\ServiceProviderInte... |
Add translation for Persian language. | <?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
... | |
Add a test case of ViewRenderer | <?php
namespace Core\ControllerDispatcher;
use App\ViewEngine\DummyView;
use App\ViewEngine\JsonView;
use App\ViewEngine\RedirectView;
use App\ViewEngine\TwigView;
use App\ViewResolver\DummyResolver;
use App\ViewResolver\JsonResolver;
use App\ViewResolver\RedirectResolver;
use App\ViewResolver\ResponseResolver;
use A... | |
Add test: Redirect https and http when accessing the site. | <?php
declare(strict_types=1);
namespace Fc2blog\Tests\App\Core\Controller;
use Fc2blog\Tests\Helper\ClientTrait;
use PHPUnit\Framework\TestCase;
class HttpsHttpRedirectTest extends TestCase
{
use ClientTrait;
public static $https_blog_id_path = '/testblog1/';
public static $http_blog_id_path = '/testblog2/';... | |
Create a simple block to link to the library. | <?php
namespace Drupal\happy_alexandrie\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Url;
/**
* Provides a 'LibraryBlock' block.
*
* @Block(
* id = "library_block",
* admin_label = @Translation("Library block"),
* )
*/
class LibraryBlock extends BlockBase {
/**
* {@inheritdoc}
*/
... | |
Add Configuration metadata controller (part 1) | <?php
namespace Embark\CMS\Configuration;
use Embark\CMS\Metadata\MetadataControllerInterface;
use Embark\CMS\Metadata\MetadataControllerTrait;
class Controller implements MetadataControllerInterface
{
use MetadataControllerTrait;
const DIR = '/manifest/config';
const FILE_EXTENSION = '.xml';
}
| |
Add unit tests for ColumnVector. | <?php
namespace Math\LinearAlgebra;
class ColumnVectorTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider dataProviderForConstructor
*/
public function testConstructor(array $M, array $V)
{
$C = new ColumnVector($M);
$V = new Matrix($V);
$this->assertInstanceOf... | |
Add test for Traits listing | <?php
namespace fennecweb\ajax\listing;
use \fennecweb\WebService as WebService;
class TraitsTest extends \PHPUnit_Framework_TestCase
{
public function testExecute()
{
//Test for error returned by user is not logged in
list($service) = WebService::factory('listing/Traits');
$results ... | |
Add positive test for OSR_Validate | <?php
/**
* Tests for successful validation in OSR
*
* @author Edward Nash <e.nash@dvz-mv.de>
*
* @copyright ©2019 DVZ Datenverarbeitungszentrum M-V GmbH
*/
class OSR_2_ValidationTest1 extends PHPUnit_Framework_TestCase
{
/**
* Test OSR_Validate() with success
*
* @depends OSR_1_ImportTest0::... | |
Add test for NCBI taxid mapping | <?php
namespace Tests\AppBundle\API\Mapping;
use Symfony\Component\HttpFoundation\ParameterBag;
use Tests\AppBundle\API\WebserviceTestCase;
class ByNcbiTaxidTest extends WebserviceTestCase
{
public function testExecute()
{
$service = $this->webservice->factory('mapping', 'byNcbiTaxid');
// T... | |
Add first phpunit test case | <?php
namespace MathieuImbert\SlackLogger\Tests;
use PHPUnit\Framework\TestCase;
use MathieuImbert\SlackLogger\SlackLogger;
use Psr\Log\LogLevel;
class SlackLoggerTest extends TestCase
{
public function testLog()
{
$logger = new SlackLogger($_ENV['WEBHOOK_URL']);
$logger->log(LogLevel::INF... | |
Add test for Log component | <?php
namespace PhpTabsTest\Component;
use PHPUnit_Framework_TestCase;
use PhpTabs\Component\Config;
use PhpTabs\Component\Log;
/**
* Tests Log component
*/
class LogTest extends PHPUnit_Framework_TestCase
{
public function testLog()
{
Log::clear();
# Empty log
$this->assertEquals(0, Log::coun... | |
Add user defined config hendler | <?php
namespace Resources;
class Config {
static private $config = array();
static private function _cache($name){
if( ! isset(self::$config[$name]) ) {
$array = require APP . 'config/'.$name.'.php';
self::$config[$name] = $array;
return $array;
... | <?php
namespace Resources;
class Config {
static private $config = array();
static private function _cache($name){
if( ! isset(self::$config[$name]) ) {
$array = require APP . 'config/'.$name.'.php';
self::$config[$name] = $array;
return $array;
... |
Test cases for the symbol manager | <?php
/**
* Contracts libray - a design by contracts library
*
* @author Ntwali Bashige <ntwali.bashige@gmail.com>
* @copyright 2015 Ntwali Bashige
* @link http://www.ntwalibas.me/contracts
* @license http://www.ntwalibas.me/contracts/license
* @version 0.1.0
*
* MIT LICENSE
*/
use Cont... | |
Add advanced autocomplete search example. | <?php
require_once "vendor/autoload.php";
require_once 'example_helpers.php';
/*
The following snippet shows an example of how to search for people using the autocomplete endpoint and ensure these people still have a member
role to a specific organization (eg. branch)
The script is broken down into two separa... | |
Add dynamic option setter for session resource | <?php
/**
* Panada session Handler.
*
* @package Resources
* @link http://panadaframework.com/
* @license http://www.opensource.org/licenses/bsd-license.php
* @author Iskandar Soesman <k4ndar@yahoo.com>
* @since Version 0.1
*/
namespace Resources;
class Session {
private $driver, $config;
pub... | <?php
/**
* Panada session Handler.
*
* @package Resources
* @link http://panadaframework.com/
* @license http://www.opensource.org/licenses/bsd-license.php
* @author Iskandar Soesman <k4ndar@yahoo.com>
* @since Version 0.1
*/
namespace Resources;
class Session {
private $driver, $config;
pub... |
Add start of implementation of Share command | <?php
namespace Commands;
use Telegram\Bot\Commands\Command;
use Base\DB;
use Base\Meetup;
/**
* Class ShareCommand.
*/
class ShareCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'share';
/**
* @var string Command Description
*/
protected $descripti... | |
Test rgb to hex conversions | <?php
namespace Rainbow\Tests\Converter;
use Rainbow\Converter\RgbToHexConverter;
use Rainbow\Hex;
use Rainbow\Rgb;
class RgbToHexConverterTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider colorDataProvider
* @param $expected
* @param $color
*/
public function testConvertShou... | |
Add miscellaneous provider (boolean, md5, sha1,...) | <?php
namespace Faker\Provider;
require_once __DIR__ . '/Base.php';
class Miscellaneous extends \Faker\Provider\Base
{
/**
* @example true
*/
public static function boolean()
{
return mt_rand(0, 1) == 0 ? true: false;
}
/**
* @example 'cfcd208495d565ef66e7dff9f98764da'
*/
public... | |
Add timestamps to giftcard table | <?php
use Phinx\Migration\AbstractMigration;
class AddGiftcardTimes extends AbstractMigration
{
public function change()
{
$table= $this->table('giftcard', [ 'signed' => false ]);
$table
/* Don't use ->addTimestamps() because we use DATETIME */
->addColumn('created_at', 'datetime',... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.