repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Grid/SqlGrid.php | tests/src/Fixtures/Grid/SqlGrid.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Grid;
use Bluz\Grid\Grid;
use Bluz\Grid\Source\SqlSource;
/**
* Test Grid based on SQL
*
* @category Application
* @package Test
*/
class SqlGrid extends Grid
{
/**
* @var string
*/
protected $uid = 'sql';
/**
* Init SqlSource
*
* @return void
* @throws \Bluz\Grid\GridException
*/
public function init(): void
{
// Array
$adapter = new SqlSource();
$adapter->setSource('SELECT * FROM test');
$this->setAdapter($adapter);
$this->setDefaultLimit(10);
$this->setAllowOrders(['name', 'id', 'status']);
$this->setAllowFilters(['status', 'id', 'email']);
$this->setDefaultOrder('name', Grid::ORDER_DESC);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Grid/SelectGrid.php | tests/src/Fixtures/Grid/SelectGrid.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Grid;
use Bluz\Db\Query\Select;
use Bluz\Grid\Grid;
use Bluz\Grid\Source\SelectSource;
/**
* Test Grid based on SQL
*
* @category Application
* @package Test
*/
class SelectGrid extends Grid
{
/**
* @var string
*/
protected $uid = 'sql';
/**
* Init SelectSource
*
* @return void
* @throws \Bluz\Grid\GridException
*/
public function init(): void
{
// Array
$adapter = new SelectSource();
$select = new Select();
$select->select('*')->from('test', 't');
$adapter->setSource($select);
$this->setAdapter($adapter);
$this->setDefaultLimit(10);
$this->setAllowOrders(['name', 'id', 'status']);
$this->setAllowFilters(['status', 'id', 'email']);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Common/ConcreteOptions.php | tests/src/Fixtures/Common/ConcreteOptions.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Common;
use Bluz\Common\Options;
/**
* Concrete class with Options trait
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 14.01.14 11:48
*/
class ConcreteOptions
{
use Options;
/**
* @var mixed
*/
public $foo;
/**
* @var string
*/
public $moo;
/**
* @var mixed
*/
public $fooBar;
/**
* setFoo
*
* @param string $foo
*
* @return self
*/
public function setFoo($foo)
{
$this->foo = $foo;
return $this;
}
/**
* setMoo
*
* @param string $moo
*
* @return self
*/
public function setMoo($moo)
{
$this->moo = $moo;
return $this;
}
/**
* getMoo
*
* @return string
*/
public function getMoo()
{
return $this->moo . '-Moo';
}
/**
* setFooBar
*
* @param string $fooBar
*
* @return self
*/
public function setFooBar($fooBar)
{
$this->fooBar = $fooBar;
return $this;
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Common/ConcreteSingleton.php | tests/src/Fixtures/Common/ConcreteSingleton.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Common;
use Bluz\Common\Singleton;
/**
* Concrete class with Singleton trait
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 12.08.2014 13:24
*/
class ConcreteSingleton
{
use Singleton;
/**
* @var string
*/
public $foo;
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Common/ConcreteContainer.php | tests/src/Fixtures/Common/ConcreteContainer.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Common;
use Bluz\Common\Container\ArrayAccess;
use Bluz\Common\Container\Container;
use Bluz\Common\Container\JsonSerialize;
use Bluz\Common\Container\MagicAccess;
use Bluz\Common\Container\RegularAccess;
/**
* Concrete class with Container trait
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 27.10.14 12:27
*/
class ConcreteContainer implements \ArrayAccess, \JsonSerializable
{
use Container;
use ArrayAccess;
use MagicAccess;
use RegularAccess;
use JsonSerialize;
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Common/ConcreteHelpers.php | tests/src/Fixtures/Common/ConcreteHelpers.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Common;
use Bluz\Common\Helper;
/**
* Concrete class with Helpers trait
*
* @package Bluz\Tests\Common
*
* @method integer HelperFunction($argument)
* @method integer Helper2Function($argument)
* @method bool helperClass($argument)
*
* @author Anton Shevchuk
* @created 14.01.14 11:48
*/
class ConcreteHelpers
{
use Helper;
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/UserAdmin.php | tests/src/Fixtures/Models/UserAdmin.php | <?php
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models;
use Bluz\Auth\AbstractIdentity;
use Bluz\Proxy\Auth;
/**
* Row
*
* @package Bluz\Tests\Fixtures\Models
*
* @author Anton Shevchuk
* @created 28.03.14 18:25
*/
class UserAdmin extends AbstractIdentity
{
/**
* Can entity login
*
* @return void
*/
public function tryLogin()
{
Auth::setIdentity($this);
}
/**
* Get user privileges
*
* @return array
*/
public function getPrivileges(): array
{
return [];
}
/**
* Check user role
*
* @param integer $roleId
*
* @return boolean
*/
public function hasRole($roleId)
{
return true;
}
/**
* Has role a privilege
*
* @param string $module
* @param string $privilege
*
* @return boolean
*/
public function hasPrivilege($module, $privilege): bool
{
return true;
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/UserGuest.php | tests/src/Fixtures/Models/UserGuest.php | <?php
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models;
use Bluz\Application\Exception\ApplicationException;
use Bluz\Auth\AbstractIdentity;
/**
* Row
*
* @package Bluz\Tests\Fixtures\Models
*
* @author Anton Shevchuk
* @created 28.03.14 18:25
*/
class UserGuest extends AbstractIdentity
{
/**
* Can entity login
*
* @throws ApplicationException
*/
public function tryLogin()
{
throw new ApplicationException("User status is undefined in system");
}
/**
* Get user privileges
*
* @return array
*/
public function getPrivileges(): array
{
return [];
}
/**
* Check user role
*
* @param integer $roleId
*
* @return boolean
*/
public function hasRole($roleId)
{
return false;
}
/**
* Has role a privilege
*
* @param string $module
* @param string $privilege
*
* @return boolean
*/
public function hasPrivilege($module, $privilege): bool
{
return false;
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/Test/Crud.php | tests/src/Fixtures/Models/Test/Crud.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models\Test;
use Bluz\Http\StatusCode;
use Bluz\Proxy\Db;
use Bluz\Proxy\Response;
/**
* Crud based on Db\Table
*
* @package Bluz\Tests\Fixtures
*
* @author Anton Shevchuk
* @created 03.09.12 13:11
*/
class Crud extends \Bluz\Crud\Table
{
/**
* Return table instance for manipulation
*
* @return \Bluz\Db\Table
*/
public function getTable()
{
if (!$this->table) {
/**
* @var Table $tableClass
*/
$table = Table::getInstance();
$this->setTable($table);
}
return $this->table;
}
/**
* {@inheritdoc}
*
* @param int $offset
* @param int $limit
* @param array $params
*
* @return array|int|mixed
*/
public function readSet(int $offset = 0, int $limit = 10, array $params = [])
{
$select = Db::select('*')
->from('test', 't');
if ($limit) {
$selectPart = $select->getQueryPart('select');
$selectPart = 'SQL_CALC_FOUND_ROWS ' . current($selectPart);
$select->select($selectPart);
$select->setLimit($limit);
$select->setOffset($offset);
}
$result = $select->execute(Row::class);
if ($limit) {
$total = (int) Db::fetchOne('SELECT FOUND_ROWS()');
} else {
$total = count($result);
}
if (count($result) < $total) {
Response::setStatusCode(StatusCode::PARTIAL_CONTENT);
Response::setHeader(
'Content-Range',
'items ' . $offset . '-' . ($offset + count($result)) . '/' . $total
);
}
return [$result, $total];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/Test/Table.php | tests/src/Fixtures/Models/Test/Table.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models\Test;
/**
* Table
*
* @package Bluz\Tests\Fixtures
*
* @author Anton Shevchuk
* @created 08.07.11 17:36
*/
class Table extends \Bluz\Db\Table
{
/**
* Table
*
* @var string
*/
protected $name = 'test';
/**
* Primary key(s)
*
* @var array
*/
protected $primary = ['id'];
/**
* Class name
*
* @var string
*/
protected $rowClass = Row::class;
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/Test/Row.php | tests/src/Fixtures/Models/Test/Row.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models\Test;
use Bluz\Db\TableInterface;
use Bluz\Validator\Traits\Validator;
/**
* Test Row
*
* @property integer $id
* @property string $name
* @property string $email
* @property string $status enum('active','disable','delete')
*
* @package Bluz\Tests\Fixtures
*/
class Row extends \Bluz\Db\Row
{
use Validator;
/**
* Return table instance for manipulation
*
* @return TableInterface
*/
public function getTable(): TableInterface
{
return Table::getInstance();
}
/**
* beforeInsert
*
* @return void
*/
public function beforeSave(): void
{
$this->addValidator('name')
->required()
->notEmpty()
->latin();
$this->addValidator('email')
->required()
->notEmpty()
->email();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/Auth/Table.php | tests/src/Fixtures/Models/Auth/Table.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models\Auth;
use Bluz\Auth\Model\AbstractTable;
/**
* Auth Table
*
* @package Bluz\Tests\Fixtures\Models\Auth
*
* @method static ?Row findRow($primaryKey)
* @method static ?Row findRowWhere($whereList)
*/
class Table extends AbstractTable
{
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Models/Auth/Row.php | tests/src/Fixtures/Models/Auth/Row.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Models\Auth;
use Bluz\Auth\Model\AbstractRow;
/**
* Auth Row
*
* @package Bluz\Tests\Fixtures\Models\Auth
*
* @property string $created
* @property string $updated
*/
class Row extends AbstractRow
{
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Crud/TableCrud.php | tests/src/Fixtures/Crud/TableCrud.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Crud;
use Bluz\Crud\Table;
/**
* Crud based on Db\Table
*
* @package Bluz\Tests\Fixtures
*
* @author Anton Shevchuk
* @created 03.09.12 13:11
*/
class TableCrud extends Table
{
/**
* Reset Table
*
* @return void
*/
public function resetTable()
{
$this->table = null;
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Crud/EmptyCrud.php | tests/src/Fixtures/Crud/EmptyCrud.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Crud;
use Bluz\Common\Singleton;
use Bluz\Crud\AbstractCrud;
/**
* Crud based on Db\Table
*
* @package Bluz\Tests\Fixtures
*
* @author Anton Shevchuk
* @created 03.09.12 13:11
*/
class EmptyCrud extends AbstractCrud
{
/**
* @return array
*/
public function getPrimaryKey(): array
{
return [];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/src/Fixtures/Validator/Rule/CustomRule.php | tests/src/Fixtures/Validator/Rule/CustomRule.php | <?php
/**
* Bluz Framework Component
*
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
declare(strict_types=1);
namespace Bluz\Tests\Fixtures\Validator\Rule;
use Bluz\Validator\Rule\AbstractRule;
/**
* Check for iInteger
*
* @package Bluz\Validator\Rule
*/
class CustomRule extends AbstractRule
{
/**
* @var string error template
*/
protected $description = 'must be a not empty custom string';
/**
* Check input data
*
* @param mixed $input
*
* @return bool
*/
public function validate($input): bool
{
return is_string($input) && strlen($input) > 0;
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/acceptance/_bootstrap.php | tests/acceptance/_bootstrap.php | <?php
// Here you can initialize variables that will be available to your tests
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/index/controllers/index.php | tests/modules/index/controllers/index.php | <?php
/**
* Default module/controller
*
* @author Anton Shevchuk
* @created 06.07.11 18:39
* @return \Closure
*/
/**
* @namespace
*/
namespace Application;
/**
* @return void
*/
return function () {
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/error/controllers/index.php | tests/modules/error/controllers/index.php | <?php
/**
* Error controller
* Send error headers and show simple page
*
* @author Anton Shevchuk
* @created 11.07.11 15:32
*/
/**
* @namespace
*/
namespace Application;
use Bluz\Controller\Controller;
use Bluz\Http\StatusCode;
use Bluz\Proxy\Layout;
use Bluz\Proxy\Logger;
use Bluz\Proxy\Messages;
use Bluz\Proxy\Response;
use Bluz\Proxy\Request;
/**
* @route /error/{$code}
*
* @param int $code
* @param \Exception $exception
*
* @return array|null
*/
return function ($code, $exception = null) {
/**
* @var Controller $this
*/
// cast to valid HTTP error code
// 500 - Internal Server Error
$code = (StatusCode::CONTINUE <= $code && $code < 600) ? $code : StatusCode::INTERNAL_SERVER_ERROR;
// use exception
$message = $exception ? $exception->getMessage() : '';
Response::setStatusCode($code);
Logger::error($message);
switch ($code) {
case 400:
$error = __('Bad Request');
$description = __('The server didn\'t understand the syntax of the request');
break;
case 401:
$error = __('Unauthorized');
$description = __('You are not authorized to view this page, please sign in');
break;
case 403:
$error = __('Forbidden');
$description = __('You don\'t have permissions to access this page');
break;
case 404:
$error = __('Not Found');
$description = __('The page you requested was not found');
break;
case 405:
$error = __('Method Not Allowed');
$description = __('The server is not support method `%s`', Request::getMethod());
Response::setHeader('Allow', $message);
break;
case 406:
$error = __('Not Acceptable');
$description = __('The server is not acceptable generating content type described at `Accept` header');
break;
case 500:
$error = __('Internal Server Error');
$description = __('The server encountered an unexpected condition');
break;
case 501:
$error = __('Not Implemented');
$description = __('The server does not understand or does not support the HTTP method');
break;
case 503:
$error = __('Service Unavailable');
$description = __('The server is currently unable to handle the request due to a temporary overloading');
Response::setHeader('Retry-After', '600');
break;
default:
$error = __('Internal Server Error');
$description = __('An unexpected error occurred with your request. Please try again later');
break;
}
// check CLI or HTTP request
if (Request::isHttp()) {
// simple AJAX call, accept JSON
if (Request::checkAccept(['application/json'])) {
$this->useJson();
Messages::addError($description);
return [
'code' => $code,
'error' => !empty($message) ? $message : $error
];
}
// dialog AJAX call, accept HTML
if (!Request::isXmlHttpRequest()) {
$this->useLayout('small.phtml');
}
}
Layout::title($error);
return [
'code' => $code,
'error' => $error,
'description' => $description,
'message' => $message
];
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/route-with-param.php | tests/modules/test/controllers/route-with-param.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of route with one param
*
* @author Anton Shevchuk
* @created 12.06.12 13:08
*/
namespace Application;
/**
* @route /test/param/$
* @route /test/param/{$a}/
*
* @param integer $a
*
* @return bool
*/
return function ($a = 42) {
return false;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/throw-exception.php | tests/modules/test/controllers/throw-exception.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Controllers;
/**
* @throws \Exception
* @return void
*/
return function () {
$this->disableLayout();
throw new \Exception('Message', 1024);
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/route-static.php | tests/modules/test/controllers/route-static.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of static route
*
* @author Anton Shevchuk
* @created 12.06.12 13:08
*/
namespace Application;
/**
* @route /static-route/
* @route /another-route.html
* @return bool
*/
return function () {
return false;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/index.php | tests/modules/test/controllers/index.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of empty test controller
*
* @author Anton Shevchuk
*/
namespace Application;
/**
* @return bool
*/
return function () {
return false;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/throw-forbidden.php | tests/modules/test/controllers/throw-forbidden.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Controllers;
use Bluz\Http\Exception\ForbiddenException;
/**
* @throws ForbiddenException
* @return void
*/
return function () {
$this->disableLayout();
throw new ForbiddenException('Forbidden');
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/route-with-params.php | tests/modules/test/controllers/route-with-params.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of route with params
*
* @author Anton Shevchuk
* @created 12.06.12 13:08
*/
namespace Application;
/**
* @route /{$a}-{$b}-{$c}/
*
* @param int $a
* @param float $b
* @param string $c
*
* @return bool
*/
return function ($a, $b, $c) {
return false;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/route-with-other-params.php | tests/modules/test/controllers/route-with-other-params.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example route with params
*
* @category Application
*
* @author dark
* @created 18.12.13 18:39
*/
namespace Application;
/**
* @route /test/route-with-other-params/{$alias}(.*)
*
* @param $alias
*
* @return bool
*/
return function ($alias) {
return false;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/mapper.php | tests/modules/test/controllers/mapper.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example controller for test mapper
*
* @author Anton Shevchuk
*/
namespace Application;
/**
* @return array
*/
return function ($crud, $primary, $data, $relation = null, $relationId = null) {
return [
'crud' => $crud,
'primary' => $primary,
'data' => $data,
'relation' => $relation,
'relationId' => $relationId,
];
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/modules/test/controllers/throw-redirect.php | tests/modules/test/controllers/throw-redirect.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\Tests\Fixtures\Controllers;
use Bluz\Proxy\Response;
/**
* @return void
*/
return function () {
Response::redirectTo('index');
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/registry.php | tests/configs/default/registry.php | <?php
/**
* Registry data
*
* @link https://github.com/bluzphp/framework/wiki/Registry
* @return array
*/
return [];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/layout.php | tests/configs/default/layout.php | <?php
/**
* Layout configuration
*
* @link https://github.com/bluzphp/framework/wiki/Layout
* @return array
*/
return [
'path' => PATH_APPLICATION . '/layouts',
'template' => 'index.phtml',
'helpersPath' => [PATH_APPLICATION . '/layouts/helpers']
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/translator.php | tests/configs/default/translator.php | <?php
/**
* Translator configuration
*
* @link https://github.com/bluzphp/framework/wiki/Session
* @return array
*/
return [
'domain' => 'messages',
'locale' => 'en_US',
'path' => PATH_ROOT . '/tests/locale'
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/session.php | tests/configs/default/session.php | <?php
/**
* Session configuration
*
* @link https://github.com/bluzphp/framework/wiki/Session
* @return array
*/
return [
'adapter' => 'files',
'settings' => [
'cache' => [],
'files' => [
'save_path' => PATH_ROOT . '/tests/sessions'
],
'redis' => [
'host' => 'localhost'
]
]
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/logger.php | tests/configs/default/logger.php | <?php
/**
* Logger
*
* @link https://github.com/bluzphp/framework/wiki/Logger
* @return bool
*/
return getenv('BLUZ_LOG');
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/cache.php | tests/configs/default/cache.php | <?php
/**
* Cache configuration
*
* @link https://github.com/bluzphp/framework/wiki/Cache
* @return array
*/
return [
'enabled' => false,
'adapter' => 'memcached',
'pools' => [
/**
* @link https://symfony.com/doc/current/components/cache/adapters/apcu_adapter.html
*/
'apcu' => function () {
return new Symfony\Component\Cache\Adapter\ApcuAdapter('bluz');
},
/**
* @link https://symfony.com/doc/current/components/cache/adapters/filesystem_adapter.html
*/
'filesystem' => function () {
return new Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter('bluz', 0, PATH_DATA . '/cache');
},
/**
* @link https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html
* @link https://github.com/nrk/predis/wiki/Connection-Parameters
* @link https://github.com/nrk/predis/wiki/Client-Options
*/
'predis' => function () {
$client = new \Predis\Client('tcp:/127.0.0.1:6379');
return new Symfony\Component\Cache\Adapter\RedisTagAwareAdapter($client, 'bluz');
}
]
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/request.php | tests/configs/default/request.php | <?php
/**
* Request configuration
*
* @link https://github.com/bluzphp/framework/wiki/Request
* @return array
*/
return [];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/debug.php | tests/configs/default/debug.php | <?php
/**
* Debug mode
*
* @link https://github.com/bluzphp/framework/wiki/Debug
* @return bool
*/
return getenv('BLUZ_DEBUG');
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/mailer.php | tests/configs/default/mailer.php | <?php
/**
* Mailer configuration for PHPMailer
*
* @link https://github.com/bluzphp/framework/wiki/Mailer
* @link https://github.com/Synchro/PHPMailer
* @return array
*/
return [
'subjectTemplate' => 'Bluz - %s',
'from' => [
'email' => 'no-reply@example.com',
'name' => 'Bluz'
],
'settings' => [
'CharSet' => 'UTF-8'
],
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/router.php | tests/configs/default/router.php | <?php
/**
* Request configuration
*
* @link https://github.com/bluzphp/framework/wiki/Request
* @return array
*/
return [
'baseUrl' => '/',
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/db.php | tests/configs/default/db.php | <?php
/**
* Database configuration
*
* @link https://github.com/bluzphp/framework/wiki/Db
* @return array
*/
return [
'connect' => [
'type' => 'mysql',
'host' => 'localhost',
'name' => 'bluz',
'user' => 'root',
'pass' => '',
'options' => [
\PDO::ATTR_PERSISTENT => true,
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET CHARACTER SET utf8'
]
]
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/default/auth.php | tests/configs/default/auth.php | <?php
/**
* Auth configuration
*
* @link https://github.com/bluzphp/framework/wiki/Auth
* @return array
*/
return [
'equals' => [
'encryptFunction' => function ($password, $salt) {
return md5(md5($password) . $salt);
}
],
'facebook' => [
'appId' => '%%appId%%',
'secret' => '%%secret%%',
],
'twitter' => [
'consumerKey' => '%%consumerKey%%',
'consumerSecret' => '%%consumerSecret%%'
],
'cookie' => [
'ttl' => 86400
],
'token' => [
'ttl' => 3600
]
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/testing/registry.php | tests/configs/testing/registry.php | <?php
/**
* Registry data
*
* @link https://github.com/bluzphp/framework/wiki/Registry
* @return array
*/
return [
'moo' => 'baz'
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/testing/temp.php | tests/configs/testing/temp.php | <?php
/**
* Temporary files for tests
*
* @return array
*/
return [
'image1' => PATH_ROOT . '/tests/src/Fixtures/Http/test.jpg',
'image2' => PATH_ROOT . '/tests/src/Fixtures/Http/test1.jpg'
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/testing/logger.php | tests/configs/testing/logger.php | <?php
/**
* Logger
*
* @link https://github.com/bluzphp/framework/wiki/Logger
* @return bool
*/
return true;
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/testing/cache.php | tests/configs/testing/cache.php | <?php
/**
* Cache configuration
*
* @link https://github.com/bluzphp/framework/wiki/Cache
* @return array
*/
return [
'enabled' => false
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/configs/testing/test.php | tests/configs/testing/test.php | <?php
/**
* Test
*
* @return array
*/
return [
'foo' => 'bar'
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/FunctionsTest.php | tests/unit/FunctionsTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests;
/**
* FunctionsTest
*
* @package Bluz\Tests
* @author Anton Shevchuk
*/
class FunctionsTest extends FrameworkTestCase
{
/**
* @dataProvider dataForClassNamespace
*/
public function testClassNamespaceFunction($input, $output)
{
self::assertEquals($output, class_namespace($input));
}
/**
* @dataProvider dataForStrTrimEnd
*/
public function testStrTrimEndFunction($input, $symbol, $output)
{
self::assertEquals($output, str_trim_end($input, $symbol));
}
public function dataForStrTrimEnd(): array
{
return [
['foo/bar', '/', 'foo/bar/'],
['foo/bar', '/bar/', 'foo/bar/'],
['foobar/bar', '/bar/', 'foo/bar/'],
['faabar/bar', '/bar/', 'f/bar/'],
['foo/bar/', '/1', 'foo/bar/1'],
['foo/bar/1/1/1/1/', '/1', 'foo/bar/1'],
];
}
public function dataForClassNamespace(): array
{
return [
['Application\\Library\\Some\\Class\\Interface', 'Application\\Library\\Some\\Class'],
['Application\\Pages\\Crud', 'Application\\Pages'],
['Application\\Pages\\Row', 'Application\\Pages'],
['Application\\Pages\\Table', 'Application\\Pages'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/_bootstrap.php | tests/unit/_bootstrap.php | <?php
// Here you can initialize variables that will be available to your tests
// Emulate session
$_SESSION = [];
$_COOKIE[session_name()] = uniqid('bluz-framework-test', false);
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Registry/RegistryTest.php | tests/unit/Registry/RegistryTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Registry;
use Bluz;
use Bluz\Registry\Registry;
use Bluz\Tests\FrameworkTestCase;
/**
* RegistryTest
*
* @package Bluz\Tests
*
* @author Anton Shevchuk
* @created 14.05.2014 11:09
*/
class RegistryTest extends FrameworkTestCase
{
/**
* @var Registry
*/
protected $registry;
/**
* setUp
*/
public function setUp(): void
{
parent::setUp();
$this->registry = new Registry();
}
/**
* Setup Data Test
*/
public function testSetFromArray()
{
$data = ['foo' => 'bar'];
$this->registry->setFromArray($data);
self::assertEquals('bar', $this->registry->get('foo'));
}
/**
* Complex test for setter/getter
*/
public function testSetGet()
{
self::assertNull($this->registry->get('foo'));
$this->registry->set('foo', 'baz');
self::assertEquals('baz', $this->registry->get('foo'));
}
/**
* Complex test for contains registry key
*/
public function testContains()
{
$this->registry->set('moo', 'maz');
self::assertTrue($this->registry->contains('moo'));
self::assertFalse($this->registry->contains('boo'));
}
/**
* Complex test for delete registry key
*/
public function testRemove()
{
$this->registry->set('moo', 'maz');
$this->registry->delete('moo');
self::assertNull($this->registry->get('moo'));
self::assertFalse($this->registry->contains('moo'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Application/ApplicationTest.php | tests/unit/Application/ApplicationTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Application;
use Bluz\Http\RequestMethod;
use Bluz\Http\StatusCode;
use Bluz\Proxy;
use Bluz\Proxy\Response;
use Bluz\Proxy\Router;
use Bluz\Tests\FrameworkTestCase;
use Laminas\Diactoros\ServerRequest;
/**
* ApplicationTest
*
* @author Anton Shevchuk
* @created 21.05.13 10:24
*/
class ApplicationTest extends FrameworkTestCase
{
public function testFullApplicationCircle()
{
self::getApp();
self::setRequestParams('', [], [], RequestMethod::GET, ['Accept' => Proxy\Request::TYPE_HTML]);
self::getApp()->run();
self::assertEquals(StatusCode::OK, Response::getStatusCode());
self::assertEquals('HTML', Response::getType());
}
public function testGetApplicationPath()
{
self::assertEquals(dirname(__DIR__, 2), self::getApp()->getPath());
}
public function testGetRequestPackage()
{
self::assertInstanceOf(ServerRequest::class, self::getApp()->getRequest());
}
public function testGetResponsePackage()
{
self::assertInstanceOf(\Bluz\Response\Response::class, self::getApp()->getResponse());
}
public function testPreProcessShouldDisableLayoutForAjaxRequests()
{
// setup Request
self::setRequestParams('', [], [], RequestMethod::GET, ['X-Requested-With' => 'XMLHttpRequest']);
// run Application
self::getApp()->process();
self::assertFalse(self::getApp()->useLayout());
}
public function testPreProcessShouldSwitchToJsonResponseForAcceptJsonHeader()
{
// setup Request
self::setRequestParams('', [], [], RequestMethod::GET, ['Accept' => Proxy\Request::TYPE_JSON]);
// run Application
self::getApp()->process();
self::assertFalse(self::getApp()->useLayout());
self::assertEquals('JSON', self::getApp()->getResponse()->getType());
}
/**
* Test run Index Controller if Index Module
*/
public function testIndexController()
{
// setup Request
self::setRequestParams('', [], [], RequestMethod::GET, ['Accept' => Proxy\Request::TYPE_HTML]);
// run Application
self::getApp()->process();
self::assertEquals(Router::getDefaultModule(), self::getApp()->getModule());
self::assertEquals(Router::getDefaultController(), self::getApp()->getController());
}
/**
* Test run Error Controller
*/
public function testErrorController()
{
// setup Request
self::setRequestParams(uniqid('module', false) . '/' . uniqid('controller', false));
// run Application
self::getApp()->process();
self::assertEquals(Router::getErrorModule(), self::getApp()->getModule());
self::assertEquals(Router::getErrorController(), self::getApp()->getController());
}
/**
* Test call Error helper
*/
public function testHelperError()
{
// setup Request
self::setRequestParams('test/throw-exception');
// run Application
self::getApp()->process();
self::assertEquals(Router::getErrorModule(), self::getApp()->getModule());
self::assertEquals(Router::getErrorController(), self::getApp()->getController());
self::assertEquals(Response::getStatusCode(), StatusCode::INTERNAL_SERVER_ERROR);
self::assertEquals(Response::getBody()->getData()->get('code'), 500);
self::assertEquals(Response::getBody()->getData()->get('message'), 'Message');
}
/**
* Test call Forbidden helper
*/
public function testHelperForbidden()
{
// setup Request
self::setRequestParams('test/throw-forbidden');
// run Application
self::getApp()->process();
self::assertEquals(Router::getErrorModule(), self::getApp()->getModule());
self::assertEquals(Router::getErrorController(), self::getApp()->getController());
self::assertEquals(Response::getStatusCode(), StatusCode::FORBIDDEN);
self::assertEquals(Response::getBody()->getData()->get('code'), StatusCode::FORBIDDEN);
self::assertEquals(Response::getBody()->getData()->get('message'), 'Forbidden');
}
/**
* Test call Redirect helper
*/
public function testHelperRedirect()
{
// setup Request
self::setRequestParams('test/throw-redirect');
// run Application
self::getApp()->process();
self::assertEquals(Response::getStatusCode(), StatusCode::FOUND);
self::assertEquals(Response::getHeader('Location'), Router::getFullUrl());
}
/**
* Test call Redirect helper
*/
public function testHelperRedirectAjaxCall()
{
// setup Request
self::setRequestParams(
'test/throw-redirect',
[],
[],
RequestMethod::POST,
['X-Requested-With' => 'XMLHttpRequest']
);
// run Application
self::getApp()->process();
self::assertEquals(Response::getStatusCode(), StatusCode::NO_CONTENT);
self::assertEquals(Response::getHeader('Bluz-Redirect'), Router::getFullUrl());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Messages/MessagesTest.php | tests/unit/Messages/MessagesTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Messages;
use Bluz\Messages\Messages;
use Bluz\Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* MessagesTest
*
* @package Bluz\Tests\Messages
*
* @author Anton Shevchuk
* @created 08.08.2014 14:23
*/
class MessagesTest extends FrameworkTestCase
{
/**
* setUp
*
* @return void
* @throws \Bluz\Application\Exception\ApplicationException
*/
public function setUp(): void
{
// initialize application
self::getApp();
}
/**
* Test Messages container
*/
public function testMessages()
{
Proxy\Messages::addError('error');
Proxy\Messages::addNotice('notice');
Proxy\Messages::addSuccess('success');
self::assertEquals(3, Proxy\Messages::count());
self::assertInstanceOf(\stdClass::class, Proxy\Messages::pop('error'));
self::assertInstanceOf(\stdClass::class, Proxy\Messages::pop('notice'));
self::assertInstanceOf(\stdClass::class, Proxy\Messages::pop('success'));
}
/**
* Test Messages container
*/
public function testMessagesWithDirectives()
{
Proxy\Messages::addError('error %d %d %d', 1, 2, 3);
Proxy\Messages::addNotice('notice %1$s %2$s %1$s', 'a', 'b');
Proxy\Messages::addSuccess('success %01.2f', 1.020304);
$error = Proxy\Messages::pop('error');
self::assertEquals('error 1 2 3', $error->text);
$notice = Proxy\Messages::pop('notice');
self::assertEquals('notice a b a', $notice->text);
$success = Proxy\Messages::pop('success');
self::assertEquals('success 1.02', $success->text);
}
/**
* Test Messages with empty container
*/
public function testMessagesEmpty()
{
self::assertEquals(0, Proxy\Messages::count());
self::assertNull(Proxy\Messages::pop('error'));
self::assertNull(Proxy\Messages::pop('notice'));
self::assertNull(Proxy\Messages::pop('success'));
}
/**
* Test Messages container
*/
public function testMessagesPop()
{
Proxy\Messages::addError('error');
Proxy\Messages::addNotice('notice');
Proxy\Messages::addSuccess('success');
self::assertNotEmpty(Proxy\Messages::pop('error'));
self::assertNotEmpty(Proxy\Messages::pop('notice'));
self::assertNotEmpty(Proxy\Messages::pop('success'));
}
/**
* Test Messages container
*/
public function testMessagesPopAll()
{
Proxy\Messages::addError('error');
Proxy\Messages::addNotice('notice');
Proxy\Messages::addSuccess('success');
$messages = Proxy\Messages::popAll();
self::assertArrayHasKeyAndSize($messages, 'error', 1);
self::assertArrayHasKeyAndSize($messages, 'notice', 1);
self::assertArrayHasKeyAndSize($messages, 'success', 1);
}
/**
* Test Messages container
*/
public function testMessagesPopAllForEmpty()
{
$messages = Proxy\Messages::popAll();
self::assertArrayHasKey('error', $messages);
self::assertArrayHasKey('notice', $messages);
self::assertArrayHasKey('success', $messages);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Layout/LayoutTest.php | tests/unit/Layout/LayoutTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Layout;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Layout\Layout;
/**
* LayoutTest
*
* @package Bluz\Tests\View
*
* @author Anton Shevchuk
* @created 22.08.2014 17:09
*/
class LayoutTest extends FrameworkTestCase
{
/**
* Test Content
*/
public function testSetContent()
{
$layout = new Layout();
$layout->setContent('foo');
self::assertEquals('foo', $layout->getContent());
}
/**
* Test Callable Content
*/
public function testSetCallableContent()
{
$layout = new Layout();
$layout->setContent(
function () {
return 'foo';
}
);
self::assertEquals('foo', $layout->getContent());
}
/**
* Test Callable Content throw any Exception
*/
public function testSetInvalidCallableContent()
{
$layout = new Layout();
$layout->setContent(
function () {
throw new \Exception('foo');
}
);
self::assertEquals('foo', $layout->getContent());
}
/**
* Helper Breadcrumbs
*/
public function testHelperBreadcrumbs()
{
$layout = new Layout();
$layout->breadCrumbs(['foo' => 'bar']);
self::assertEqualsArray(['foo' => 'bar'], $layout->breadCrumbs());
}
/**
* Helper Link
*/
public function testHelperLink()
{
$layout = new Layout();
$layout->link(['href' => 'foo.css', 'rel' => "stylesheet", 'media' => "all"]);
$layout->link(['href' => 'favicon.ico', 'rel' => 'shortcut icon']);
$result = $layout->link();
self::assertEquals(
'<link href="foo.css" rel="stylesheet" media="all"/>' .
'<link href="favicon.ico" rel="shortcut icon"/>',
str_replace(["\t", "\n", "\r"], '', $result)
);
}
/**
* Helper Meta
*/
public function testHelperMeta()
{
$layout = new Layout();
$layout->meta('keywords', 'foo, bar, baz, qux');
$layout->meta('description', 'foo bar baz qux');
$result = $layout->meta();
self::assertEquals(
'<meta name="keywords" content="foo, bar, baz, qux"/>' .
'<meta name="description" content="foo bar baz qux"/>',
str_replace(["\t", "\n", "\r"], '', $result)
);
}
/**
* Helper Meta
*/
public function testHelperMetaIsInvalid()
{
$layout = new Layout();
self::assertNull($layout->meta(null, 'content'));
}
/**
* Helper Meta
*/
public function testHelperMetaIsEmpty()
{
$layout = new Layout();
self::assertEmpty($layout->meta());
}
/**
* Helper Title
*/
public function testHelperTitle()
{
$layout = new Layout();
$layout->title('foo');
self::assertEquals('foo', $layout->title());
}
/**
* Helper TitleAppend
*/
public function testHelperTitleAppend()
{
$layout = new Layout();
$layout->title('foo');
$layout->titleAppend('bar');
self::assertEquals('foo :: bar :: baz', $layout->titleAppend('baz'));
}
/**
* Helper TitleAppend
*/
public function testHelperTitlePrepend()
{
$layout = new Layout();
$layout->title('foo');
$layout->titlePrepend('bar');
self::assertEquals('baz :: bar :: foo', $layout->titlePrepend('baz'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Http/CacheControlTest.php | tests/unit/Http/CacheControlTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Crud;
use Bluz\Http\CacheControl;
use Bluz\Response\Response;
use Bluz\Tests\FrameworkTestCase;
/**
* Crud TableTest
*
* @package Bluz\Tests\Crud
*
* @author Anton Shevchuk
* @created 22.08.2014 16:13
*/
class CacheControlTest extends FrameworkTestCase
{
/**
* @var Response
*/
protected $response;
/**
* @var CacheControl
*/
protected $cacheControl;
/**
* setUp
*/
public function setUp(): void
{
$this->response = new Response();
$this->cacheControl = new CacheControl($this->response);
}
/**
* @param string $header
*/
public function assertHeader($header)
{
$cache = $this->response->getHeader('Cache-Control');
self::assertEquals($header, $cache);
}
public function testSetPrivateHeader()
{
$this->cacheControl->setPrivate();
$this->assertHeader('private');
}
public function testSetPublicHeader()
{
$this->cacheControl->setPublic();
$this->assertHeader('public');
}
public function testSetMaxAge()
{
$this->cacheControl->setMaxAge(60);
$this->assertHeader('max-age=60');
self::assertEquals('60', $this->cacheControl->getMaxAge());
}
public function testGetNullTtl()
{
self::assertNull($this->cacheControl->getTtl());
}
public function testGetTtl()
{
$this->cacheControl->setMaxAge(60);
self::assertEquals(60, $this->cacheControl->getTtl());
}
public function testSetTtl()
{
$this->cacheControl->setTtl(60);
$this->assertHeader('public, s-maxage=60');
}
public function testSetClientTtl()
{
$this->cacheControl->setClientTtl(60);
$this->assertHeader('max-age=60');
}
public function testSetEtag()
{
$this->cacheControl->setEtag('some-etag');
self::assertEquals(
$this->cacheControl->getEtag(),
$this->response->getHeader('ETag')
);
}
public function testSetSharedMaxAge()
{
$this->cacheControl->setSharedMaxAge(60);
$this->assertHeader('public, s-maxage=60');
self::assertEquals('60', $this->cacheControl->getMaxAge());
}
public function testSetExpires()
{
$this->cacheControl->setExpires('2001-01-01 01:01:01');
self::assertEquals(
$this->cacheControl->getExpires(),
$this->response->getHeader('Expires')
);
self::assertLessThan(-500000000, $this->cacheControl->getMaxAge());
}
public function testSetLastModified()
{
$this->cacheControl->setLastModified('2001-01-01 01:01:01');
self::assertEquals(
$this->cacheControl->getLastModified(),
$this->response->getHeader('Last-Modified')
);
self::assertLessThan(-500000000, $this->cacheControl->getMaxAge());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/ControllerTest.php | tests/unit/Controller/ControllerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Controller;
use Bluz\Controller;
use Bluz\Http\Exception\ForbiddenException;
use Bluz\Proxy\Layout;
use Bluz\Tests\FrameworkTestCase;
/**
* @package Bluz\Tests
* @author Anton Shevchuk
* @created 19.05.16 12:28
*/
class ControllerTest extends FrameworkTestCase
{
/**
* @var Controller\Controller
*/
protected $controller;
/**
* Create `index/index` controller
*/
public function setUp(): void
{
$this->controller = self::getApp()->dispatch('index', 'index');
}
public function testHelperAttachment()
{
$this->controller->attachment('some.jpg');
self::assertNull($this->controller->getTemplate());
self::assertEquals('FILE', self::getApp()->getResponse()->getType());
self::assertFalse(self::getApp()->useLayout());
}
/**
* @todo Implement testHelperCheckHttpAccept().
*/
public function testHelperCheckHttpAccept()
{
// 12 tests:
// -/- -> ANY,JSON,HTML
// */* -> ANY,JSON,HTML
// html/text -> ANY,JSON,HTML
// application/json -> ANY,JSON,HTML
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
/**
* @todo Implement testHelperCheckMethod().
*/
public function testHelperCheckMethod()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
/**
* @todo Implement testHelperCheckPrivilege().
*/
public function testHelperCheckPrivilege()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
public function testHelperDenied()
{
$this->expectException(ForbiddenException::class);
$this->controller->denied();
}
public function testHelperDisableLayout()
{
self::assertTrue(self::getApp()->useLayout());
$this->controller->disableLayout();
self::assertFalse(self::getApp()->useLayout());
}
public function testHelperDisableView()
{
$this->controller->disableView();
self::assertNull($this->controller->getTemplate());
}
public function testHelperDispatch()
{
self::assertInstanceOf(Controller\Controller::class, $this->controller->dispatch('test', 'index'));
}
public function testHelperIsAllowed()
{
self::assertFalse($this->controller->isAllowed('not-exists'));
}
public function testHelperUseJson()
{
$this->controller->useJson();
self::assertFalse(self::getApp()->useLayout());
}
public function testHelperUseLayout()
{
$this->controller->useLayout('small.phtml');
self::assertTrue(self::getApp()->useLayout());
self::assertEquals(Layout::getTemplate(), 'small.phtml');
}
public function testHelperUser()
{
self::assertNull($this->controller->user());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/MetaTest.php | tests/unit/Controller/MetaTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Controller;
use Bluz\Common\Exception\ComponentException;
use Bluz\Controller\Meta;
use Bluz\Tests\FrameworkTestCase;
/**
* ApplicationTest
*
* @author Anton Shevchuk
* @created 21.05.13 10:24
*/
class MetaTest extends FrameworkTestCase
{
/**
* Test all reflection options
* - methods
* - cache
* - cache to html
* - params with type cast
* - privilege
* - routes
*/
public function testReflectionWithData()
{
$controllerFile = __DIR__ . '/Fixtures/ConcreteWithData.php';
$meta = new Meta($controllerFile);
$meta->process();
self::assertEqualsArray(['CLI', 'GET'], $meta->getMethod());
self::assertEquals(300, $meta->getCache());
self::assertEqualsArray(['a' => 'int', 'b' => 'float', 'c' => 'string'], $meta->getParams());
self::assertEquals('Test', $meta->getPrivilege());
self::assertEqualsArray(['Read', 'Write'], $meta->getAcl());
self::assertArrayHasSize($meta->getRoute(), 2);
}
/**
* Test all reflection options and export it
*/
public function testExportReflectionWithData()
{
$controllerFile = __DIR__ . '/Fixtures/ConcreteWithData.php';
$meta = new Meta($controllerFile);
$meta->process();
$data = var_export($meta, true);
self::assertStringStartsWith('Bluz\Controller\Meta::__set_state', $data);
}
/**
* Test reflection:
* - get params without description
*/
public function testReflectionWithoutData()
{
$controllerFile = __DIR__ . '/Fixtures/ConcreteWithoutData.php';
$meta = new Meta($controllerFile);
$meta->process();
self::assertEqualsArray(['a' => null, 'b' => null, 'c' => null], $meta->getParams());
}
/**
* Test reflection without return structure
*/
public function testReflectionWithoutReturn()
{
$this->expectException(ComponentException::class);
$controllerFile = __DIR__ . '/Fixtures/ConcreteWithoutReturn.php';
$meta = new Meta($controllerFile);
$meta->process();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/Fixtures/ConcreteWithoutData.php | tests/unit/Controller/Fixtures/ConcreteWithoutData.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Fixtures\Controllers;
use Bluz\Controller\Controller;
/**
* @return array
*/
return function ($a, $b, $c = null) {
/**
* @var Controller $this
*/
return [];
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/Fixtures/ConcreteWithData.php | tests/unit/Controller/Fixtures/ConcreteWithData.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Fixtures\Controllers;
use Bluz\Controller\Controller;
/**
* @privilege Test
* @acl Read
* @acl Write
* @cache 5 min
* @method CLI
* @method GET
* @route /example/
* @route /example/{$a}/{$b}/{$c}
*
* @param int $a
* @param float $b
* @param string $c
*
* @return array
*/
return function ($a, $b, $c = null) {
/**
* @var Controller $this
*/
return [];
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/Fixtures/ConcreteWithoutReturn.php | tests/unit/Controller/Fixtures/ConcreteWithoutReturn.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Fixtures\Controllers;
use Bluz\Controller\Controller;
/**
* @return array
*/
function ($a, $b, $c = null) {
/**
* @var Controller $this
*/
return [];
}
;
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/Mapper/RestTest.php | tests/unit/Controller/Mapper/RestTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Controller\Mapper;
use Bluz\Controller\Controller;
use Bluz\Controller\Mapper\Rest;
use Bluz\Http\Exception\NotImplementedException;
use Bluz\Http\Exception\ForbiddenException;
use Bluz\Http\RequestMethod;
use Bluz\Tests\Fixtures\Crud\TableCrud;
use Bluz\Tests\Fixtures\Models\Test\Table;
use Bluz\Tests\FrameworkTestCase;
/**
* Test for Controller Rest Mapper
*
* @package Bluz\Tests
* @author Anton Shevchuk
*/
class RestTest extends FrameworkTestCase
{
/**
* @var Rest
*/
protected $mapper;
public function setUp(): void
{
parent::setUp();
$crudTable = TableCrud::getInstance();
$crudTable->setTable(Table::getInstance());
$this->mapper = new Rest($crudTable);
}
public function tearDown(): void
{
parent::tearDown();
TableCrud::getInstance()->resetTable();
}
public function testCheckGetRequestWithPrimary()
{
self::setRequestParams('test/mapper/42', [], [], RequestMethod::GET);
$this->mapper->addMap(RequestMethod::GET, 'test', 'mapper');
$controller = $this->mapper->run();
$data = $controller->getData();
self::assertArrayHasKey('primary', $data);
self::assertArrayHasKey('id', $data['primary']);
self::assertEquals(42, $data['primary']['id']);
}
public function testCheckGetRequestWithPrimaryAndRelation()
{
self::setRequestParams('test/mapper/42/relation/6', [], [], RequestMethod::GET);
$this->mapper->addMap(RequestMethod::GET, 'test', 'mapper');
$controller = $this->mapper->run();
$data = $controller->getData();
self::assertEquals('relation', $data['relation']);
self::assertEquals(6, $data['relationId']);
}
/**
* @dataProvider dataMethods
*
* @param string $method
*/
public function testMethod($method)
{
self::setRequestParams('test/index', [], [], $method);
$this->mapper->addMap($method, 'test', 'index');
$controller = $this->mapper->run();
self::assertInstanceOf(Controller::class, $controller);
}
public function testNotImplementedMethod()
{
$this->expectException(NotImplementedException::class);
$this->mapper->run();
}
public function testForbiddenMethod()
{
$this->expectException(ForbiddenException::class);
self::setRequestParams('test/index', [], [], RequestMethod::GET);
$this->mapper->addMap(RequestMethod::GET, 'test', 'index')->acl('Deny');
$this->mapper->run();
}
/**
* @return array
*/
public function dataMethods(): array
{
return [
RequestMethod::GET => [RequestMethod::GET],
RequestMethod::POST => [RequestMethod::POST],
RequestMethod::PATCH => [RequestMethod::PATCH],
RequestMethod::PUT => [RequestMethod::PUT],
RequestMethod::DELETE => [RequestMethod::DELETE],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Controller/Mapper/CrudTest.php | tests/unit/Controller/Mapper/CrudTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Controller\Mapper;
use Bluz\Controller\Controller;
use Bluz\Controller\Mapper\Crud;
use Bluz\Http\Exception\ForbiddenException;
use Bluz\Http\RequestMethod;
use Bluz\Tests\Fixtures\Crud\TableCrud;
use Bluz\Tests\Fixtures\Models\Test\Table;
use Bluz\Tests\FrameworkTestCase;
/**
* Test for Controller Crud Mapper
*
* @package Bluz\Tests
* @author Anton Shevchuk
*/
class CrudTest extends FrameworkTestCase
{
/**
* @var Crud
*/
protected $mapper;
public function setUp(): void
{
parent::setUp();
$crudTable = TableCrud::getInstance();
$crudTable->setTable(Table::getInstance());
$this->mapper = new Crud($crudTable);
}
public function tearDown(): void
{
parent::tearDown();
TableCrud::getInstance()->resetTable();
}
public function testCheckGetRequestWithPrimary()
{
self::setRequestParams('test/mapper', ['id' => 42], [], RequestMethod::GET);
$this->mapper->addMap(RequestMethod::GET, 'test', 'mapper');
$controller = $this->mapper->run();
$data = $controller->getData();
self::assertArrayHasKey('primary', $data);
self::assertArrayHasKey('id', $data['primary']);
self::assertEquals(42, $data['primary']['id']);
}
/**
* @dataProvider dataMethods
*
* @param string $method
*/
public function testMethods($method)
{
self::setRequestParams('test/index', [], [], $method);
$this->mapper->addMap($method, 'test', 'index');
$controller = $this->mapper->run();
self::assertInstanceOf(Controller::class, $controller);
}
/**
* @dataProvider dataMethods
*
* @param string $method
*/
public function testMethodsAliases($method)
{
self::setRequestParams('test/index', [], [], $method);
$alias = strtolower($method);
$this->mapper->$alias('test', 'index');
$controller = $this->mapper->run();
self::assertInstanceOf(Controller::class, $controller);
}
public function testForbiddenMethod()
{
$this->expectException(ForbiddenException::class);
self::setRequestParams('test/index', [], [], RequestMethod::GET);
$this->mapper->addMap(RequestMethod::GET, 'test', 'index')->acl('Deny');
$this->mapper->run();
}
/**
* @return array
*/
public function dataMethods(): array
{
return [
RequestMethod::HEAD => [RequestMethod::HEAD],
RequestMethod::GET => [RequestMethod::GET],
RequestMethod::POST => [RequestMethod::POST],
RequestMethod::PATCH => [RequestMethod::PATCH],
RequestMethod::PUT => [RequestMethod::PUT],
RequestMethod::DELETE => [RequestMethod::DELETE],
RequestMethod::OPTIONS => [RequestMethod::OPTIONS],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Db/RelationTest.php | tests/unit/Db/RelationTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Db;
use Bluz\Tests\FrameworkTestCase;
/**
* Test class for Db\Relations
*/
class RelationTest extends FrameworkTestCase
{
/**
* setUp
*/
public function setUp(): void
{
}
/**
* tearDown
*/
public function tearDown(): void
{
}
/**
* testRelationOneToOne
*/
public function testRelationOneToOne()
{
self::markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* testRelationManyToMany
*/
public function testRelationManyToMany()
{
self::markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Db/TableTest.php | tests/unit/Db/TableTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Db;
use Bluz\Db\Exception\InvalidPrimaryKeyException;
use Bluz\Db\Table;
use Bluz\Tests\Fixtures\Db;
use Bluz\Tests\Fixtures\Models\Test\Table as TestTable;
use Bluz\Tests\FrameworkTestCase;
/**
* Test class for Table.
* Generated by PHPUnit on 2011-07-27 at 13:52:47.
*/
class TableTest extends FrameworkTestCase
{
/**
* @var Table
*/
protected $table;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
self::getApp();
$this->table = Db\ConcreteTable::getInstance();
}
/**
* testGetInstance
*
* @covers \Bluz\Db\Table::getInstance
*/
public function testGetInstance()
{
// test that the method doesn't create new objects
self::assertSame($this->table, Db\ConcreteTable::getInstance());
// tests that instances are creating separately for each table class
self::assertEquals(
Db\ConcreteTable::class,
get_class(Db\ConcreteTable::getInstance())
);
self::assertEquals(
Db\WrongKeysTable::class,
get_class(Db\WrongKeysTable::getInstance())
);
}
public function testGetPrimaryKeyException()
{
$this->expectException(InvalidPrimaryKeyException::class);
$table = Db\WrongKeysTable::getInstance();
$table->getPrimaryKey();
}
/**
* Get Primary Key
*/
public function testGetPrimaryKey()
{
$table = Db\ConcreteTable::getInstance();
self::assertEquals(['bar', 'baz'], $table->getPrimaryKey());
}
/**
* Get Model name
*/
public function testGetModel()
{
$table = Db\ConcreteTable::getInstance();
self::assertEquals('Db', $table->getModel());
}
/**
* @dataProvider getFindWrongData
*
* @param $keyValues
*/
public function testFindException($keyValues)
{
$this->expectException(InvalidPrimaryKeyException::class);
$this->table::find(...$keyValues);
}
/**
* Get Meta Information
*/
public function testGetMetaInformation()
{
$meta = TestTable::getMeta();
self::assertArrayHasSize($meta, 6);
self::assertArrayHasKey('id', $meta);
self::assertArrayHasKey('name', $meta);
self::assertEqualsArray(['type' => 'int', 'default' => '', 'key' => 'PRI'], $meta['id']);
}
/**
* Get Meta Information
*/
public function testGetColumns()
{
$columns = TestTable::getColumns();
self::assertArrayHasSize($columns, 6);
self::assertEqualsArray(['id', 'name', 'email', 'status', 'created', 'updated'], $columns);
}
/**
* @return array
*/
public function getFindWrongData()
{
return [
[[1]],
[[1, 2, 3]]
];
}
public function testInsert()
{
$result = TestTable::getInstance()::insert(['name' => 'Tester', 'email' => 'Very.Strong.Unique@mail.us']);
self::assertTrue($result > 0);
}
public function testFindRowWhere()
{
$result = TestTable::findRowWhere(['email' => 'Very.Strong.Unique@mail.us']);
self::assertEquals('Tester', $result->name);
}
public function testNotFoundRowWhere()
{
$result = TestTable::findRowWhere(['email' => 'Not.Found@mail.us']);
self::assertNull($result);
}
public function testUpdate()
{
$result = TestTable::getInstance()::update(['name' => 'Selfer'], ['email' => 'Very.Strong.Unique@mail.us']);
self::assertTrue(is_int($result));
self::assertEquals(1, $result);
}
public function testDelete()
{
$result = TestTable::getInstance()::delete(['email' => 'Very.Strong.Unique@mail.us']);
self::assertTrue(is_int($result));
self::assertEquals(1, $result);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Db/DbTest.php | tests/unit/Db/DbTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Db;
use Bluz;
use Bluz\Common\Exception\ConfigurationException;
use Bluz\Db;
use Bluz\Proxy;
use Bluz\Db\Query\Select;
use Bluz\Db\Query\Insert;
use Bluz\Db\Query\Update;
use Bluz\Db\Query\Delete;
/**
* Test class for Db.
* Generated by PHPUnit on 2011-07-27 at 13:52:01.
*/
class DbTest extends Bluz\Tests\FrameworkTestCase
{
/**
* @var Db\Db
*/
protected $db;
/**
* setUp
*/
public function setUp(): void
{
parent::setUp();
$this->db = new Db\Db();
$this->db->setOptions(Proxy\Config::get('db'));
}
/**
* tearDown
*/
public function tearDown(): void
{
parent::tearDown();
$this->db->disconnect();
}
/**
* Initial Db with configuration
*/
public function testCheckConnect()
{
$this->db->connect();
self::assertInstanceOf('\Pdo', $this->db->handler());
}
/**
* Initial Db with empty configuration
*/
public function testCheckConnectException()
{
$this->expectException(ConfigurationException::class);
$db = new Db\Db();
$db->setConnect([]);
}
/**
* fetchOne
*/
public function testFetchOne()
{
$result = $this->db->fetchOne('SELECT id FROM test LIMIT 1');
self::assertTrue((bool)$result);
}
/**
* fetchRow
*/
public function testFetchRow()
{
$result = $this->db->fetchRow('SELECT * FROM test LIMIT 1');
self::assertCount(6, $result);
}
/**
* fetchAll
*/
public function testFetchAll()
{
$result = $this->db->fetchAll('SELECT * FROM test LIMIT 10');
self::assertCount(10, $result);
}
/**
* fetchColumn
*/
public function testFetchColumn()
{
$result = $this->db->fetchColumn('SELECT id FROM test LIMIT 10');
self::assertCount(10, $result);
}
/**
* fetchGroup
*/
public function testFetchGroup()
{
$result = $this->db->fetchGroup('SELECT status, id, name FROM test');
self::assertArrayHasKey('active', $result);
self::assertArrayHasKey('disable', $result);
self::assertArrayHasKey('delete', $result);
}
/**
* fetchColumnGroup
*/
public function testFetchColumnGroup()
{
$result = $this->db->fetchColumnGroup('SELECT status, COUNT(id) FROM test GROUP BY status');
self::assertArrayHasKey('active', $result);
self::assertArrayHasKey('disable', $result);
self::assertArrayHasKey('delete', $result);
}
/**
* fetchUniqueGroup
*/
public function testFetchUniqueGroup()
{
$result = $this->db->fetchUniqueGroup('SELECT id, name, status FROM test');
self::assertArrayHasSize($result, 42);
self::assertArrayHasKey('1', $result);
self::assertArrayHasKey('name', $result[1]);
self::assertArrayHasKey('status', $result[1]);
}
/**
* fetchPairs
*/
public function testFetchPairs()
{
$result = $this->db->fetchPairs('SELECT email, name FROM test LIMIT 10');
self::assertCount(10, $result);
}
/**
* fetchObject to default class
*/
public function testFetchObjectToStdClass()
{
$result = $this->db->fetchObject('SELECT * FROM test LIMIT 1');
self::assertInstanceOf(\stdClass::class, $result);
}
/**
* fetchObjects to declared class
*/
public function testFetchObjectToDeclaredClass()
{
$result = $this->db->fetchObject('SELECT * FROM test LIMIT 10', [], 'stdClass');
self::assertInstanceOf(\stdClass::class, $result);
}
/**
* fetchObject to instance
*/
public function testFetchObjectToInstance()
{
$result = $this->db->fetchObject('SELECT * FROM test LIMIT 1', [], new \stdClass());
self::assertInstanceOf(\stdClass::class, $result);
}
/**
* fetchObjects to default class
*/
public function testFetchObjectsToStdClass()
{
$result = $this->db->fetchObjects('SELECT * FROM test LIMIT 10');
self::assertCount(10, $result);
self::assertInstanceOf(\stdClass::class, current($result));
}
/**
* fetchObjects to declared class
*/
public function testFetchObjectsToDeclaredClass()
{
$result = $this->db->fetchObjects('SELECT * FROM test LIMIT 10', [], 'stdClass');
self::assertCount(10, $result);
self::assertInstanceOf(\stdClass::class, current($result));
}
/**
* Transaction
*/
public function testTransactionTrue()
{
$result = $this->db->transaction(
function () {
$this->db->query('SELECT * FROM test LIMIT 10');
}
);
self::assertTrue($result);
}
/**
* Transaction Fail
*/
public function testTransactionFalse()
{
$result = $this->db->transaction(
function () {
$this->db->query('DELETE FROM test LIMIT 1');
$this->db->query('DELETE FROM test LIMIT 1');
$this->db->query('DELETE FROM test LIMIT 1');
$this->db->query('DELETE FROM notexiststable LIMIT 1');
}
);
self::assertFalse($result);
}
/**
* Transaction fail
*/
public function testTransactionInvalidCallbackThrowException()
{
$this->expectException(\TypeError::class);
$this->db->transaction('foo');
}
/**
* Select Query Builder
*/
public function testSelect()
{
$query = $this->db->select('test');
self::assertInstanceOf(Select::class, $query);
}
/**
* Insert Query Builder
*/
public function testInsert()
{
$query = $this->db->insert('test');
self::assertInstanceOf(Insert::class, $query);
}
/**
* Update Query Builder
*/
public function testUpdate()
{
$query = $this->db->update('test');
self::assertInstanceOf(Update::class, $query);
}
/**
* Delete Query Builder
*/
public function testDelete()
{
$query = $this->db->delete('test');
self::assertInstanceOf(Delete::class, $query);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Db/QueryTest.php | tests/unit/Db/QueryTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Db;
use Bluz\Db\Query\Select;
use Bluz\Db\Query\Insert;
use Bluz\Db\Query\Update;
use Bluz\Db\Query\Delete;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Proxy;
/**
* Test class for Query Builder.
* Generated by PHPUnit on 2013-06-17 at 13:52:01.
*
* @todo Separate to 4 tests for every builder
* @todo Write tests for different DB type
*/
class QueryTest extends FrameworkTestCase
{
/**
* tearDown
*/
public function tearDown(): void
{
Proxy\Db::delete('test')->where('email = ?', 'example@domain.com')->execute();
parent::tearDown();
}
/**
* Complex test of select builder
*/
public function testSelect()
{
$builder = new Select();
$builder = $builder
->select('u.*')
->addSelect('ua.*')
->from('users', 'u')
->leftJoin('u', 'users_actions', 'ua', 'ua.userId = u.id')
->where('u.id = ? OR u.id = ?', 4, 5)
->orWhere('u.id IN (?)', [4, 5])
->andWhere('u.status = ? OR u.status = ?', 'active', 'pending')
->orWhere('u.login LIKE (?)', 'A%')
->orderBy('u.id')
->addOrderBy('u.login')
->limit(5);
$check = 'SELECT u.*, ua.*'
. ' FROM `users` AS `u` LEFT JOIN `users_actions` AS `ua` ON ua.userId = u.id'
. ' WHERE (((u.id = "4" OR u.id = "5") OR (u.id IN ("4","5")))'
. ' AND (u.status = "active" OR u.status = "pending")) OR (u.login LIKE ("A%"))'
. ' ORDER BY u.id ASC, u.login ASC'
. ' LIMIT 5 OFFSET 0';
self::assertEquals($builder->getQuery(), $check);
}
/**
* Complex test of select builder
*/
public function testSelectWithGroupAndHaving()
{
$builder = new Select();
$builder = $builder
->select('p.*')
->from('pages', 'p')
->groupBy('p.userId')
->addGroupBy('MONTH(p.created)')
->having('MONTH(p.created) = :month1')
->orHaving('MONTH(p.created) = :month2')
->andHaving('p.userId <> 0')
->setParams([':month1' => 2, ':month2' => 4]);
$check = 'SELECT p.*'
. ' FROM `pages` AS `p`'
. ' GROUP BY p.userId, MONTH(p.created)'
. ' HAVING ((MONTH(p.created) = :month1) OR (MONTH(p.created) = :month2)) AND (p.userId <> 0)';
self::assertEquals(2, $builder->getParam(':month1'));
self::assertEquals(4, $builder->getParam(':month2'));
self::assertEquals($builder->getQuery(), $check);
}
/**
* Complex test of select builder
*/
public function testSelectWithInnerJoin()
{
$builder = new Select();
$builder = $builder
->select('u.*', 'p.*')
->from('users', 'u')
->join('u', 'pages', 'p', 'p.userId = u.id');
$check = 'SELECT u.*, p.*'
. ' FROM `users` AS `u` INNER JOIN `pages` AS `p` ON p.userId = u.id';
self::assertEquals($builder->getQuery(), $check);
}
/**
* Complex test of select builder
*/
public function testSelectWithRightJoin()
{
$builder = new Select();
$builder = $builder
->select('u.*', 'p.*')
->from('users', 'u')
->rightJoin('u', 'pages', 'p', 'p.userId = u.id');
$check = 'SELECT u.*, p.*'
. ' FROM `users` AS `u` RIGHT JOIN `pages` AS `p` ON p.userId = u.id';
self::assertEquals($builder->getQuery(), $check);
}
/**
* Complex test of select builder
*/
public function testSelectToStringConversion()
{
$builder = new Select();
$builder = $builder
->select('u.*', 'p.*')
->from('users', 'u')
->join('u', 'pages', 'p', 'p.userId = u.id')
->where('u.id = ? OR u.id = ?', 4, 5);
$check = 'SELECT u.*, p.*'
. ' FROM `users` AS `u` INNER JOIN `pages` AS `p` ON p.userId = u.id'
. ' WHERE u.id = ? OR u.id = ?';
self::assertEquals($check, (string)$builder);
}
/**
* Complex test of insert builder
*/
public function testInsert()
{
$builder = new Insert();
$builder = $builder
->insert('test')
->set('name', 'example')
->set('email', 'example@domain.com');
$check = 'INSERT INTO `test` SET `name` = "example", `email` = "example@domain.com"';
self::assertEquals($builder->getQuery(), $check);
self::assertGreaterThan(0, $builder->execute());
}
/**
* Complex test of update builder
*/
public function testUpdate()
{
$builder = new Update();
$builder = $builder
->update('test')
->setArray(
[
'status' => 'disable'
]
)
->where('`email` = ?', 'example@domain.com');
$check = 'UPDATE `test` SET `status` = "disable" WHERE `email` = "example@domain.com"';
self::assertEquals($builder->getQuery(), $check);
self::assertEquals(0, $builder->execute());
}
/**
* Complex test of delete builder
*/
public function testDelete()
{
$builder = new Delete();
$builder = $builder
->delete('test')
->where('`email` = ?', 'example@domain.com')
->limit(1);
$check = 'DELETE FROM `test` WHERE `email` = "example@domain.com" LIMIT 1';
self::assertEquals($check, $builder->getQuery());
self::assertEquals(0, $builder->execute());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Db/RowTest.php | tests/unit/Db/RowTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Db;
use Bluz;
use Bluz\Db\Exception\RelationNotFoundException;
use Bluz\Db\Exception\TableNotFoundException;
use Bluz\Db\Row;
use Bluz\Db\Table;
use Bluz\Tests\Fixtures\Db;
use Bluz\Tests\FrameworkTestCase;
/**
* Test class for Row.
* Generated by PHPUnit on 2011-07-27 at 13:52:01.
*/
class RowTest extends FrameworkTestCase
{
/**
* @var Db\ConcreteRow
*/
protected $row;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
self::getApp();
$this->row = new Db\ConcreteRow();
}
/**
* @covers \Bluz\Db\Row::__get
*/
public function testGet()
{
self::assertNull($this->row->someValue);
}
/**
* @covers \Bluz\Db\Row::__set
*/
public function testSet()
{
$this->row->someValue = 'foo';
self::assertEquals('foo', $this->row->someValue);
}
/**
* @covers \Bluz\Db\Row::__isset
*/
public function testIsset()
{
$this->row->someValue = 'foo';
self::assertTrue(isset($this->row->someValue));
self::assertFalse(isset($this->row->anotherValue));
}
/**
* @todo Implement testSave().
*/
public function testSave()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
/**
* @todo Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
/**
* @todo Implement testRefresh().
*/
public function testRefresh()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
/**
* @covers \Bluz\Db\Row::getTable
*/
public function testGetTable()
{
$table = $this->row->getTable();
self::assertInstanceOf(Table::class, $table);
}
/**
* @covers \Bluz\Db\Row::getTable
*/
public function testGetTableException()
{
$this->expectException(TableNotFoundException::class);
$this->row = new Db\ConcreteRowWithInvalidTable();
$this->row->getTable();
}
/**
* @todo Implement testGetRelation().
*/
public function testGetRelation()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
public function testGetRelationException()
{
$this->expectException(RelationNotFoundException::class);
$this->row->getRelation('wrongRelation');
}
/**
* @todo Implement testSetRelation().
*/
public function testSetRelation()
{
// Remove the following lines when you implement this test.
self::markTestIncomplete('This test has not been implemented yet.');
}
/**
* Test export to array
*/
public function testToArray()
{
$this->row->someValue = 'foo';
self::assertEqualsArray(['someValue' => 'foo'], $this->row->toArray());
}
/**
* Test import from array
*/
public function testSetFromArray()
{
$this->row->setFromArray(['someValue' => 'foo']);
self::assertEquals('foo', $this->row->someValue);
}
/**
* Test ArrayAccess interface
* - offsetSet
*/
public function testOffsetSet()
{
$this->row['someValue'] = 'foo';
self::assertEquals('foo', $this->row->someValue);
}
/**
* Test ArrayAccess interface
* - offsetExists
*/
public function testOffsetExists()
{
$this->row->someValue = 'foo';
self::assertTrue(isset($this->row['someValue']));
}
/**
* Test ArrayAccess interface
* - offsetUnset
*/
public function testOffsetUnset()
{
$this->row->someValue = 'foo';
unset($this->row['someValue']);
self::assertFalse(isset($this->row['someValue']));
}
/**
* Test ArrayAccess interface
* - offsetGet
*/
public function testOffsetGet()
{
$this->row->someValue = 'foo';
self::assertEquals('foo', $this->row['someValue']);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Mailer/MailerTest.php | tests/unit/Mailer/MailerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Mailer;
use Bluz\Common\Exception\ComponentException;
use Bluz\Common\Exception\ConfigurationException;
use Bluz\Mailer\Mailer;
use Bluz\Tests\FrameworkTestCase;
/**
* MailerTest
*
* @package Bluz\Tests\Mailer
*
* @author Anton Shevcuk
* @created 19.08.2014 13:03
*/
class MailerTest extends FrameworkTestCase
{
public function testWrongConfigurationThrowException()
{
$this->expectException(ConfigurationException::class);
$mailer = new Mailer();
$mailer->setOptions(null);
$mailer->init();
}
public function testWithoutPHPMailerThrowException()
{
$this->expectException(ComponentException::class);
$mailer = new Mailer();
$mailer->create();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Grid/GridTest.php | tests/unit/Grid/GridTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Grid;
use Bluz\Grid\Grid;
use Bluz\Grid\GridException;
use Bluz\Proxy\Request;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Grid\ArrayGrid;
/**
* @package Bluz\Tests
* @author Anton Shevchuk
* @created 07.08.14 14:37
*/
class GridTest extends FrameworkTestCase
{
/**
* Reset application
*/
public function tearDown(): void
{
self::resetApp();
}
/**
* Process Request
*/
public function testProcessRequest()
{
$request = Request::getInstance();
$request = $request->withQueryParams(
[
'arr-page' => 2, // 2 page
'arr-limit' => 2, // 2 rows per page
'arr-order-id' => 'desc',
'arr-filter-name' => 'ne-Smith',
'arr-filter-status' => 'disable',
]
);
Request::setInstance($request);
$grid = new ArrayGrid();
self::assertEquals(8, $grid->total());
self::assertEquals(4, $grid->pages());
}
/**
* Process Request
*/
public function testRequestWithAliases()
{
$request = Request::getInstance();
$request = $request->withQueryParams(
[
'arr-order-index' => 'desc',
]
);
Request::setInstance($request);
$grid = new ArrayGrid();
self::assertEquals(
'/index/index/arr-order-index/desc/arr-filter-index/1',
$grid->filter('id', Grid::FILTER_EQ, 1)
);
}
/**
* Custom Module and Controller
*/
public function testCustomControllerAndModule()
{
$grid = new ArrayGrid();
$grid->setModule('module');
$grid->setController('controller');
self::assertEquals('/module/controller', $grid->reset());
}
/**
* @covers \Bluz\Grid\Grid::addOrder
* @covers \Bluz\Grid\Grid::addOrders
* @covers \Bluz\Grid\Grid::setOrders
* @covers \Bluz\Grid\Grid::getOrders
*/
public function testOrders()
{
$orders = [
'name' => Grid::ORDER_ASC,
'email' => Grid::ORDER_DESC
];
$grid = new ArrayGrid();
$grid->setOrders($orders);
self::assertEqualsArray($orders, $grid->getOrders());
}
/**
* @covers \Bluz\Grid\Grid::getPrefix
*/
public function testGetPrefix()
{
$grid = new ArrayGrid();
self::assertEquals('arr-', $grid->getPrefix());
}
public function testWrongPageThrowException()
{
$this->expectException(GridException::class);
$grid = new ArrayGrid();
$grid->setPage(0);
}
public function testWrongLimitThrowException()
{
$this->expectException(GridException::class);
$grid = new ArrayGrid();
$grid->setLimit(0);
}
/**
* @covers \Bluz\Grid\Grid::getDefaultLimit
*/
public function testGetDefaultLimit()
{
$grid = new ArrayGrid();
self::assertEquals(4, $grid->getDefaultLimit());
}
public function testWrongDefaultLimitThrowException()
{
$this->expectException(GridException::class);
$grid = new ArrayGrid();
$grid->setDefaultLimit(0);
}
public function testWrongColumnFilterThrowException()
{
$this->expectException(GridException::class);
$grid = new ArrayGrid();
$grid->addFilter('not exist', Grid::FILTER_EQ, 'not found');
}
public function testWrongFilterNameThrowException()
{
$this->expectException(GridException::class);
$grid = new ArrayGrid();
$grid->addFilter('id', 'not exist', 'not found');
}
/**
* Helper Filter
*/
public function testHelperFilter()
{
$grid = new ArrayGrid();
$grid->addFilter('name', Grid::FILTER_NE, 'Smith');
self::assertEquals(
'/index/index/arr-filter-index/ne-1',
$grid->filter('id', Grid::FILTER_NE, 1)
);
self::assertEquals(
'/index/index/arr-filter-name/ne-Smith/arr-filter-index/1',
$grid->filter('id', Grid::FILTER_EQ, 1, false)
);
self::assertEquals(
'/index/index/arr-filter-name/ne-Smith/arr-filter-index/ne-1',
$grid->filter('id', Grid::FILTER_NE, 1, false)
);
}
/**
* Helper Filter
*/
public function testHelperWrongFilterColumnReturnNull()
{
$grid = new ArrayGrid();
self::assertNull($grid->filter('not exist', Grid::FILTER_NE, 1));
}
/**
* Helper Filter
*/
public function testHelperWrongFilterNameReturnNull()
{
$grid = new ArrayGrid();
self::assertNull($grid->filter('id', 'not exist', 1));
}
/**
* Helper First
*/
public function testHelperFirst()
{
$grid = new ArrayGrid();
self::assertEquals('/', $grid->first());
}
/**
* Helper Last
*/
public function testHelperLast()
{
$grid = new ArrayGrid();
self::assertEquals('/index/index/arr-page/3', $grid->last());
}
/**
* Helper Limit
*/
public function testHelperLimit()
{
$grid = new ArrayGrid();
self::assertEquals('/index/index/arr-limit/25', $grid->limit());
}
/**
* Helper Next
*/
public function testHelperNext()
{
$grid = new ArrayGrid();
self::assertEquals('/index/index/arr-page/2', $grid->next());
}
/**
* Helper Next
*/
public function testHelperNextReturnNull()
{
$grid = new ArrayGrid();
$grid->setPage(3);
self::assertNull($grid->next());
}
/**
* Helper Order
*/
public function testHelperOrder()
{
$grid = new ArrayGrid();
self::assertNull($grid->order('not exists'));
self::assertEquals('/index/index/arr-order-name/asc', $grid->order('name'));
self::assertEquals('/index/index/arr-order-name/asc', $grid->order('name', 'asc', 'asc', false));
}
/**
* Helper Order
*/
public function testHelperOrderReverseCurrentOrder()
{
$grid = new ArrayGrid();
$grid->setOrder('name');
self::assertEquals('/index/index/arr-order-name/desc', $grid->order('name'));
}
/**
* Helper Page
*/
public function testHelperPage()
{
$grid = new ArrayGrid();
self::assertEquals('/index/index/arr-page/2', $grid->page(2));
self::assertNull($grid->page(42));
}
/**
* Helper Pages
*/
public function testHelperPages()
{
$grid = new ArrayGrid();
self::assertEquals(3, $grid->pages());
}
/**
* Helper Prev
*/
public function testHelperPrev()
{
$grid = new ArrayGrid();
$grid->setPage(3);
self::assertEquals('/index/index/arr-page/2', $grid->prev());
}
/**
* Helper Prev
*/
public function testHelperPrevReturnNull()
{
$grid = new ArrayGrid();
self::assertNull($grid->prev());
}
/**
* Helper Reset
*/
public function testHelperReset()
{
$grid = new ArrayGrid();
self::assertEquals('/', $grid->reset());
}
/**
* Helper Total
*/
public function testHelperTotal()
{
$grid = new ArrayGrid();
self::assertEquals(10, $grid->total());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Grid/Source/ArraySourceTest.php | tests/unit/Grid/Source/ArraySourceTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Grid\Source;
use Bluz\Grid\Grid;
use Bluz\Grid\GridException;
use Bluz\Grid\Source\ArraySource;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Grid\ArrayGrid;
/**
* @package Bluz\Tests
* @author Anton Shevchuk
* @created 07.08.14 14:37
*/
class ArraySourceTest extends FrameworkTestCase
{
/**
* Array Source
*/
public function testArrayGrid()
{
$grid = new ArrayGrid();
self::assertEquals(3, $grid->pages());
self::assertEquals(10, $grid->total());
}
/**
* Array Source Exception
*/
public function testArraySourceThrowsGridException()
{
$this->expectException(GridException::class);
$adapter = new ArraySource();
$adapter->setSource('wrong source type');
}
/**
* Array Source Orders
*/
public function testOrders()
{
$grid = new ArrayGrid();
$grid->setDefaultOrder('id', Grid::ORDER_DESC);
$grid->getData();
self::assertEquals(3, $grid->pages());
self::assertEquals(10, $grid->total());
}
/**
* Array Source Filters
*/
public function testFilters()
{
$grid = new ArrayGrid();
$grid->addFilter('id', Grid::FILTER_GT, 1); // id > 1
$grid->addFilter('id', Grid::FILTER_GE, 2); // id >= 2
$grid->addFilter('id', Grid::FILTER_LT, 10); // id < 10
$grid->addFilter('id', Grid::FILTER_LE, 9); // id <= 9
self::assertEquals(8, $grid->total());
self::assertEquals(2, $grid->pages());
self::assertEquals('/index/index/arr-filter-index/gt-1_ge-2_lt-10_le-9', $grid->first());
}
/**
* Array Source Filters
*/
public function testFilterEqual()
{
$grid = new ArrayGrid();
$grid->addFilter('id', Grid::FILTER_EQ, 1); // id = 1
self::assertEquals(1, $grid->pages());
self::assertEquals(1, $grid->total());
}
/**
* Array Source Filters
*/
public function testFilterNotEqual()
{
$grid = new ArrayGrid();
$grid->addFilter('id', Grid::FILTER_NE, 1); // id != 1
self::assertEquals(3, $grid->pages());
self::assertEquals(9, $grid->total());
}
/**
* Array Source Filters
*/
public function testFilterLike()
{
$grid = new ArrayGrid();
$grid->addFilter('email', Grid::FILTER_LIKE, '^m@'); // preg_match('/^m@/', email)
self::assertEquals(1, $grid->pages());
self::assertEquals(2, $grid->total());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Grid/Source/SqlSourceTest.php | tests/unit/Grid/Source/SqlSourceTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Grid\Source;
use Bluz\Grid\Grid;
use Bluz\Grid\GridException;
use Bluz\Grid\Source\SqlSource;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Grid\SqlGrid;
/**
* @package Bluz\Tests
* @author Anton Shevchuk
* @created 07.08.14 14:37
*/
class SqlSourceTest extends FrameworkTestCase
{
/**
* SQL Source
*/
public function testSqlGrid()
{
$grid = new SqlGrid();
$grid->setDefaultOrder('id', Grid::ORDER_DESC);
$grid->addFilter('id', Grid::FILTER_GT, 1); // id > 1
$grid->addFilter('email', Grid::FILTER_LIKE, '@');
self::assertEquals(5, $grid->pages());
self::assertEquals(41, $grid->total());
}
/**
* SQL Source Exception
*/
public function testSqlSourceThrowsGridException()
{
$this->expectException(GridException::class);
$adapter = new SqlSource();
$adapter->setSource(['wrong source type']);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Grid/Source/SelectSourceTest.php | tests/unit/Grid/Source/SelectSourceTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Grid\Source;
use Bluz\Grid\Grid;
use Bluz\Grid\GridException;
use Bluz\Grid\Source\SelectSource;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Grid\SelectGrid;
/**
* @package Bluz\Tests
* @author Anton Shevchuk
* @created 07.08.14 14:37
*/
class SelectSourceTest extends FrameworkTestCase
{
/**
* Select Source
*/
public function testSelectGrid()
{
$grid = new SelectGrid();
$grid->setDefaultOrder('id', Grid::ORDER_DESC);
$grid->addFilter('id', Grid::FILTER_GT, 1); // id > 1
$grid->addFilter('email', Grid::FILTER_LIKE, '@');
self::assertEquals(5, $grid->pages());
self::assertEquals(41, $grid->total());
}
/**
* Select Source Exception
*/
public function testSelectSourceThrowsGridException()
{
$this->expectException(GridException::class);
$adapter = new SelectSource();
$adapter->setSource('wrong source type');
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/EventManager/EventTest.php | tests/unit/EventManager/EventTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests;
use Bluz;
use Bluz\EventManager\Event;
use Bluz\EventManager\EventException;
/**
* EventTest
*
* @package Bluz\Tests
*
* @author Anton Shevchuk
* @created 14.05.2014 11:57
*/
class EventTest extends Bluz\Tests\FrameworkTestCase
{
/**
* Complex test of event getters
*/
public function testEventMethods()
{
$event = new Event('test', 'target', ['foo' => 'bar']);
self::assertEquals('test', $event->getName());
self::assertEquals('target', $event->getTarget());
self::assertEquals(['foo' => 'bar'], $event->getParams());
self::assertEquals('bar', $event->getParam('foo'));
self::assertNull($event->getParam('baz'));
self::assertEquals('qux', $event->getParam('baz', 'qux'));
$event->setParam('baz', 'qux');
self::assertEquals('qux', $event->getParam('baz'));
}
/**
* Complex test of event getters with object
*/
public function testEventMethodsWithObject()
{
$params = new \stdClass();
$params->foo = 'bar';
$event = new Event('test', 'target', $params);
self::assertEquals($params, $event->getParams());
self::assertEquals('bar', $event->getParam('foo'));
self::assertNull($event->getParam('baz'));
self::assertEquals('qux', $event->getParam('baz', 'qux'));
$event->setParam('baz', 'qux');
self::assertEquals('qux', $event->getParam('baz'));
}
/**
* Test trigger with wong params
*/
public function testEventSetParamsException()
{
$this->expectException(EventException::class);
new Event('test', null, 'wrong type');
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/EventManager/EventManagerTest.php | tests/unit/EventManager/EventManagerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests;
use Bluz;
use Bluz\EventManager\Event;
use Bluz\EventManager\EventException;
use Bluz\EventManager\EventManager;
/**
* EventManagerTest
*
* @package Bluz\Tests
*
* @author Anton Shevchuk
* @created 14.05.2014 11:57
*/
class EventManagerTest extends Bluz\Tests\FrameworkTestCase
{
/**
* @var EventManager
*/
protected $eventManager;
/**
* setUp
*/
public function setUp(): void
{
$this->eventManager = new EventManager();
}
/**
* Test one event
*/
public function testTriggerSimpleEvent()
{
$counter = 0;
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter++;
}
);
$this->eventManager->trigger('test');
self::assertEquals(1, $counter);
}
/**
* Test three events
*/
public function testTriggerThreeEvents()
{
$counter = 0;
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter++;
}
);
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter++;
}
);
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter++;
}
);
$this->eventManager->trigger('test');
self::assertEquals(3, $counter);
}
/**
* Test events with priority
*/
public function testTriggerTwoEventsWithPriority()
{
$counter = 0;
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter *= 2;
},
2
);
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter++;
}
);
$this->eventManager->trigger('test');
self::assertEquals(2, $counter);
}
/**
* Test events with abort chain call
*/
public function testTriggerTwoEventsWithAbort()
{
$counter = 0;
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter++;
return false;
}
);
$this->eventManager->attach(
'test',
function () use (&$counter) {
$counter *= 2;
}
);
$this->eventManager->trigger('test');
self::assertEquals(1, $counter);
}
/**
* Test usage of namespaces
*/
public function testTriggerWithNamespace()
{
$counter = 0;
// namespace is first
$this->eventManager->attach(
'some',
function () use (&$counter) {
$counter++;
}
);
// event is secondary
$this->eventManager->attach(
'some:test',
function () use (&$counter) {
$counter *= 2;
}
);
$this->eventManager->trigger('some:test');
self::assertEquals(2, $counter);
}
/**
* Test target usage
*/
public function testTriggerWithTarget()
{
// first
$this->eventManager->attach(
'test',
function ($event) {
/* @var Event */
return $event->getTarget() + 1;
}
);
// second
$this->eventManager->attach(
'test',
function ($event) {
/* @var Event */
return $event->getTarget() + 1;
}
);
$counter = 0;
$result = $this->eventManager->trigger('test', $counter);
self::assertEquals(2, $result);
}
/**
* Test params
*/
public function testTriggerWithParams()
{
$this->eventManager->attach(
'test',
function ($event) {
/* @var Event */
return $event->getTarget() + $event->getParam('plus');
}
);
$result = $this->eventManager->trigger('test', 10, ['plus' => 10]);
self::assertEquals(20, $result);
}
/**
* Test wrong params
*/
public function testEventSetParamsException()
{
$this->expectException(EventException::class);
$this->eventManager->trigger('test', null, 'wrong type params');
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Translator/TranslatorTest.php | tests/unit/Translator/TranslatorTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Translator;
use Bluz\Common\Exception\ConfigurationException;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Translator\Translator;
/**
* TranslatorTest
*
* @package Bluz\Tests\Translator
*
* @author Anton Shevchuk
* @created 22.08.2014 16:37
*/
class TranslatorTest extends FrameworkTestCase
{
/**
* Test Translator initialization
*/
public function testInvalidConfigurationThrowException()
{
$this->expectException(ConfigurationException::class);
$translator = new Translator();
$translator->addTextDomain('any', '/this/directory/is/not/exists');
}
/**
* Test Translate
*/
public function testTranslate()
{
$translator = new Translator();
$translator->setDomain('messages');
$translator->setLocale('uk_UA');
$translator->setPath(PATH_APPLICATION . '/locale');
self::assertEquals('', $translator->translate(''));
self::assertEquals('message', $translator->translate('message'));
}
/**
* Test Plural Translate
*/
public function testPluralTranslate()
{
$translator = new Translator();
$translator->setDomain('messages');
$translator->setLocale('uk_UA');
$translator->setPath(PATH_APPLICATION . '/locale');
self::assertEquals('', $translator->translatePlural('', '', 2));
if (function_exists('ngettext')) {
self::assertEquals('messages', $translator->translatePlural('message', 'messages', 2));
} else {
self::assertEquals('message', $translator->translatePlural('message', 'messages', 2));
}
}
/**
* Test Plural Translate
*/
public function testPluralTranslateWithAdditionalParams()
{
$translator = new Translator();
$translator->setDomain('messages');
$translator->setLocale('uk_UA');
$translator->setPath(PATH_APPLICATION . '/locale');
if (function_exists('ngettext')) {
self::assertEquals(
'2 messages',
$translator->translatePlural('%d message', '%d messages', 2, 2)
);
} else {
self::assertEquals(
'2 message',
$translator->translatePlural('%d message', '%d messages', 2, 2)
);
}
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/NilTest.php | tests/unit/Common/NilTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Common;
use Bluz\Common\Nil;
use Bluz\Tests\FrameworkTestCase;
/**
* Tests for Nil
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 23.05.14 11:47
*/
class NilTest extends FrameworkTestCase
{
/**
* @var Nil
*/
protected $nil;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
$this->nil = new Nil();
}
/**
* Test setup options
*/
public function testComplexNill()
{
// methods
self::assertNull(Nil::call());
self::assertNull($this->nil->call());
// properties
$this->nil->foo = 'bar';
self::assertNull($this->nil->foo);
self::assertFalse(isset($this->nil->foo));
// magic __toString
self::assertEmpty('' . $this->nil);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/SingletonTest.php | tests/unit/Common/SingletonTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Common;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Common\ConcreteSingleton;
/**
* SingletonTest
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 12.08.2014 13:24
*/
class SingletonTest extends FrameworkTestCase
{
/**
* Test GetInstance
*/
public function testGetInstance()
{
$result = ConcreteSingleton::getInstance();
$result->foo = 'bar';
self::assertInstanceOf(ConcreteSingleton::class, $result);
self::assertEquals(ConcreteSingleton::getInstance(), $result);
self::assertEquals('bar', ConcreteSingleton::getInstance()->foo);
}
/**
* Test Clone
*/
public function testPrivateMethods()
{
$result = ConcreteSingleton::getInstance();
$reflection = new \ReflectionObject($result);
self::assertTrue($reflection->getMethod('__construct')->isPrivate());
self::assertTrue($reflection->getMethod('__clone')->isPrivate());
}
/**
* Test Construct Throw Error
*/
public function testConstructThrowError()
{
$this->expectException(\Error::class);
new ConcreteSingleton();
}
/**
* Test Clone Throw Error
*/
public function testCloneThrowError()
{
$this->expectException(\Error::class);
clone ConcreteSingleton::getInstance();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/ContainerTest.php | tests/unit/Common/ContainerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Common;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Common\ConcreteContainer;
/**
* Tests for Container traits
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 27.10.14 12:31
*/
class ContainerTest extends FrameworkTestCase
{
/**
* @var ConcreteContainer
*/
protected $class;
protected $example = [
'foo' => 'bar',
'quz' => 'qux'
];
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
$this->class = new ConcreteContainer();
}
/**
* Test setup Container from array and get as array
*/
public function testContainerSetterAndGetter()
{
$this->class->setFromArray($this->example);
self::assertEqualsArray($this->example, $this->class->toArray());
}
/**
* Test Reset Container data to null
*/
public function testResetContainer()
{
$this->class->setFromArray($this->example);
$this->class->resetArray();
$result = $this->class->toArray();
self::assertArrayHasKey('foo', $result);
self::assertArrayHasKey('quz', $result);
self::assertNull($result['foo']);
self::assertNull($result['quz']);
}
/**
* Test RegularAccess trait
*/
public function testRegularAccess()
{
$this->class->set('foo', 'bar');
$this->class->set('quz', 'qux');
$this->class->delete('quz');
self::assertEquals('bar', $this->class->get('foo'));
self::assertFalse($this->class->contains('quz'));
self::assertFalse($this->class->contains('some other'));
self::assertNull($this->class->get('quz'));
}
/**
* Test MagicAccess trait
*/
public function testMagicAccess()
{
$this->class->foo = 'bar';
$this->class->quz = 'qux';
unset($this->class->quz);
self::assertEquals('bar', $this->class->foo);
self::assertFalse(isset($this->class->quz));
self::assertFalse(isset($this->class->some));
self::assertTrue(empty($this->class->quz));
self::assertTrue(empty($this->class->some));
self::assertNull($this->class->quz);
}
/**
* Test ArrayAccess trait
*/
public function testArrayAccess()
{
$this->class['foo'] = 'bar';
$this->class['quz'] = 'qux';
unset($this->class['quz']);
self::assertEquals('bar', $this->class['foo']);
self::assertFalse(isset($this->class['quz']));
self::assertFalse(isset($this->class['some']));
self::assertTrue(empty($this->class['quz']));
self::assertTrue(empty($this->class['some']));
self::assertNull($this->class['quz']);
}
/**
* Test JsonSerialize implementation
*/
public function testJsonSerialize()
{
$this->class->setFromArray($this->example);
self::assertJsonStringEqualsJsonString(json_encode($this->example), json_encode($this->class));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/HelperTest.php | tests/unit/Common/HelperTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Common;
use Bluz\Common\Exception\CommonException;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Common\ConcreteHelpers;
/**
* Tests for Helper trait
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 14.01.14 11:47
*/
class HelperTest extends FrameworkTestCase
{
protected const MAGIC_NUMBER = 42;
/**
* @var ConcreteHelpers
*/
protected $class;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
$this->class = new ConcreteHelpers();
}
/**
* Helper paths is not initialized, and helper file not found
*/
public function testInvalidHelperCall()
{
$this->expectException(CommonException::class);
$this->class->helperFunction(self::MAGIC_NUMBER);
}
/**
* Helper path initialized, but file consists some stuff, it's not callable
*/
public function testInvalidHelperCall2()
{
$this->expectException(CommonException::class);
$this->class->addHelperPath(__DIR__ . '/Fixtures/Helper');
$this->class->helperInvalidFunction(self::MAGIC_NUMBER);
}
/**
* complex test
* test Add Helper Path
* test call Function helper
* test call Class helper
*/
public function testAddHelperPath()
{
$this->class->addHelperPath(__DIR__ . '/Fixtures/Helper');
$this->class->addHelperPath(__DIR__ . '/Fixtures/Helper2');
self::assertEquals(
$this->class->helperFunction(self::MAGIC_NUMBER),
self::MAGIC_NUMBER
);
self::assertEquals(
$this->class->helper2Function(self::MAGIC_NUMBER),
self::MAGIC_NUMBER
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/LineTest.php | tests/unit/Common/LineTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Common;
use Bluz\Common\Str;
use Bluz\Tests\FrameworkTestCase;
/**
* Tests for Line helpers
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 21.04.17 12:36
*/
class LineTest extends FrameworkTestCase
{
/**
* @dataProvider dataForStrTrimEnd
*
* @param string $input
* @param string $output
*/
public function testToCamelCase($input, $output)
{
self::assertEquals($output, to_camel_case($input));
self::assertEquals($output, Str::toCamelCase($input));
}
public function dataForStrTrimEnd(): array
{
return [
['foo bar', 'FooBar'],
['some-unique-id', 'SomeUniqueId'],
['another_unique_id', 'AnotherUniqueId'],
['Another mixed_unique-ID', 'AnotherMixedUniqueId'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/OptionsTest.php | tests/unit/Common/OptionsTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Common;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Common\ConcreteOptions;
/**
* Tests for Options trait
*
* @package Bluz\Tests\Common
*
* @author Anton Shevchuk
* @created 23.05.14 11:32
*/
class OptionsTest extends FrameworkTestCase
{
/**
* @var ConcreteOptions
*/
protected $class;
/**
* @var array
*/
protected $options;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
$this->class = new ConcreteOptions();
$this->options = ['foo' => 'bar', 'foo bar' => 'qux', 'baz' => ['foo' => 'bar'], 'moo' => 'Moo'];
}
/**
* Test setup options
*/
public function testSetOptions()
{
$this->class->setOptions($this->options);
self::assertEquals('bar', $this->class->foo);
self::assertEquals('qux', $this->class->fooBar);
}
/**
* Test get options
*/
public function testGetOptions()
{
$this->class->setOptions($this->options);
self::assertEquals($this->options, $this->class->getOptions());
self::assertEquals('bar', $this->class->getOption('foo'));
self::assertEquals('bar', $this->class->getOption('baz', 'foo'));
self::assertEquals('Moo-Moo', $this->class->getOption('moo'));
}
/**
* Test get options
*/
public function testGetFalseOption()
{
$this->class->setOptions($this->options);
self::assertNull($this->class->getOption('bar'));
self::assertNull($this->class->getOption('baz', 'bar'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/Fixtures/Helper2/Helper2Function.php | tests/unit/Common/Fixtures/Helper2/Helper2Function.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of helpers
*
* @author Anton Shevchuk
* @created 14.01.14 11:39
*
* @param $argument
*
* @return mixed
*/
return function ($argument) {
return $argument;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/Fixtures/Helper/HelperInvalidFunction.php | tests/unit/Common/Fixtures/Helper/HelperInvalidFunction.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of invalid helper
*
* @author Anton Shevchuk
* @created 14.01.14 11:39
*/
return rand(1, 42);
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Common/Fixtures/Helper/HelperFunction.php | tests/unit/Common/Fixtures/Helper/HelperFunction.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* Example of helpers
*
* @author Anton Shevchuk
* @created 14.01.14 11:39
*
* @param $argument
*
* @return mixed
*/
return function ($argument) {
return $argument;
};
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Acl/AclTest.php | tests/unit/Acl/AclTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Acl;
use Bluz\Proxy;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Tests\Fixtures\Models\UserAdmin;
use Bluz\Tests\Fixtures\Models\UserGuest;
/**
* RegistryTest
*
* @package Bluz\Tests
*
* @author Anton Shevchuk
* @created 14.05.2014 11:09
*/
class AclTest extends FrameworkTestCase
{
/**
* Test allow access
*/
public function testAllow()
{
Proxy\Auth::setIdentity(new UserAdmin());
self::assertTrue(Proxy\Acl::isAllowed('any', 'any'));
}
/**
* Test deny access
*/
public function testDeny()
{
Proxy\Auth::setIdentity(new UserGuest());
self::assertFalse(Proxy\Acl::isAllowed('any', 'any'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Auth/AuthTest.php | tests/unit/Auth/AuthTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Auth;
use Bluz\Proxy\Auth;
use Bluz\Proxy\Session;
use Bluz\Tests\Fixtures\Models\Auth\Table;
use Bluz\Tests\Fixtures\Models\UserAdmin;
use Bluz\Tests\FrameworkTestCase;
use Bluz\Auth\Model\AbstractRow;
/**
* AuthTest
*
* @package Bluz\Tests\Auth
*
* @author Anton Shevchuk
* @created 12.08.2014 11:12
*/
class AuthTest extends FrameworkTestCase
{
/**
* Test Auth works with Identity
*
* @covers \Bluz\Auth\Auth::setIdentity
* @covers \Bluz\Auth\Auth::getIdentity
*/
public function testAuthIdentity()
{
$adminIdentity = new UserAdmin();
Auth::setIdentity($adminIdentity);
self::assertEquals($adminIdentity, Auth::getIdentity());
}
/**
* Test Auth Identity clear
*
* @covers \Bluz\Auth\Auth::clearIdentity
*/
public function testAuthClearIdentity()
{
$adminIdentity = new UserAdmin();
Auth::setIdentity($adminIdentity);
Auth::clearIdentity();
self::assertNull(Auth::getIdentity());
}
/**
* Test Auth Identity clear
*
* @covers \Bluz\Auth\Auth::getIdentity
* @covers \Bluz\Auth\Auth::clearIdentity
*/
public function testAuthClearIdentityWithWrongUserAgent()
{
$adminIdentity = new UserAdmin();
Session::set('auth:agent', 'agent:php');
Session::set('auth:identity', $adminIdentity);
$_SERVER['HTTP_USER_AGENT'] = 'agent:cli';
self::assertNull(Auth::getIdentity());
}
/**
* Test get Auth\Row
*/
public function testGetAuthRow()
{
$authRow = Table::getInstance()::getAuthRow(Table::PROVIDER_EQUALS, 'admin');
self::assertInstanceOf(AbstractRow::class, $authRow);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Router/RouterTest.php | tests/unit/Router/RouterTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Router;
use Bluz\Http\RequestMethod;
use Bluz\Proxy\Router;
use Bluz\Tests\FrameworkTestCase;
/**
* RouterTest
*
* @package Bluz\Tests\Router
*
* @author Anton Shevchuk
* @created 12.08.2014 14:24
*/
class RouterTest extends FrameworkTestCase
{
/**
* testRouterUrl
*
* @dataProvider providerForDefaultRoutes
*
* @param string $url
* @param string $module
* @param string $controller
* @param array $params
*/
public function testRouterUrl($url, $module, $controller, $params = [])
{
self::assertEquals($url, Router::getUrl($module, $controller, $params));
}
/**
* Test Router Url for custom controller route
*
* @dataProvider providerForCustomRoutes
*
* @param string $url
* @param string $module
* @param string $controller
* @param array $params
*/
public function testRouterUrlWithCustomControllerRoute($url, $module, $controller, $params = [])
{
self::assertEquals($url, Router::getUrl($module, $controller, $params));
}
/**
* Test Router Url
*/
public function testRouterFullUrl()
{
self::setRequestParams('/', [], [], RequestMethod::GET);
self::assertEquals('http://127.0.0.1/', Router::getFullUrl());
}
/**
* @return array
*/
public function providerForDefaultRoutes()
{
return [
['/test/test', 'test', 'test', []],
['/test/test/foo/bar', 'test', 'test', ['foo' => 'bar']],
['/test/test?foo%5B0%5D=bar&foo%5B1%5D=baz', 'test', 'test', ['foo' => ['bar', 'baz']]],
['/test', 'test', null, []],
['/test', 'test', 'index', []],
['/test/index/foo/bar', 'test', 'index', ['foo' => 'bar']],
['/index/test', null, 'test', []],
['/index/test', 'index', 'test', []],
['/index/test/foo/bar', 'index', 'test', ['foo' => 'bar']],
];
}
/**
* @return array
*/
public function providerForCustomRoutes()
{
return [
['/another-route.html', 'test', 'route-static'],
['/another-route.html?foo%5B0%5D=bar&foo%5B1%5D=baz', 'test', 'route-static', ['foo' => ['bar', 'baz']]],
['/test/param/42/', 'test', 'route-with-param', ['a' => 42]],
['/foo-bar-baz/', 'test', 'route-with-params', ['a' => 'foo', 'b' => 'bar', 'c' => 'baz']],
['/test/route-with-other-params/about', 'test', 'route-with-other-params', ['alias' => 'about']],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Response/ResponseTest.php | tests/unit/Response/ResponseTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Response;
use Bluz\Response\Response;
use Bluz\Tests\FrameworkTestCase;
/**
* @package Bluz\Tests\Http
*
* @author Anton Shevchuk
* @created 22.08.2014 11:18
*/
class ResponseTest extends FrameworkTestCase
{
/**
* @var Response
*/
protected $response;
/**
* SetUp
*/
public function setUp(): void
{
$this->response = new Response();
}
/**
* Test initial values of Response properties
*/
public function testGetters()
{
self::assertNotEmpty($this->response->getProtocolVersion());
self::assertNull($this->response->getReasonPhrase());
}
/**
* Test initial values of Response properties
*/
public function testSetGetReasonPhrase()
{
$this->response->setReasonPhrase('OK');
self::assertEquals('OK', $this->response->getReasonPhrase());
}
/**
* @covers \Bluz\Response\Response::setHeader
* @covers \Bluz\Response\Response::getHeader
* @covers \Bluz\Response\Response::hasHeader
*/
public function testSetGetHasHeader()
{
$this->response->setHeader('foo', 'bar');
self::assertTrue($this->response->hasHeader('foo'));
self::assertEquals('bar', $this->response->getHeader('foo'));
self::assertEmpty($this->response->getHeader('baz'));
}
/**
* @covers \Bluz\Response\Response::addHeader
* @covers \Bluz\Response\Response::getHeader
* @covers \Bluz\Response\Response::getHeaderAsArray
*/
public function testAddHeader()
{
$this->response->addHeader('foo', 'bar');
$this->response->addHeader('foo', 'baz');
self::assertTrue($this->response->hasHeader('foo'));
self::assertEquals('bar, baz', $this->response->getHeader('foo'));
self::assertEqualsArray(['bar', 'baz'], $this->response->getHeaderAsArray('foo'));
self::assertEqualsArray([], $this->response->getHeaderAsArray('baz'));
}
/**
* @covers \Bluz\Response\Response::removeHeader
*/
public function testRemoveHeader()
{
$this->response->addHeader('foo', 'bar');
$this->response->removeHeader('foo');
self::assertFalse($this->response->hasHeader('foo'));
}
/**
* @covers \Bluz\Response\Response::setHeaders
* @covers \Bluz\Response\Response::addHeaders
* @covers \Bluz\Response\Response::getHeaders
*/
public function testAddHeaders()
{
$this->response->setHeaders(['foo' => ['bar']]);
$this->response->addHeaders(['foo' => ['baz'], 'baz' => ['qux']]);
self::assertCount(2, $this->response->getHeaders());
self::assertArrayHasKeyAndSize($this->response->getHeaders(), 'foo', 2);
}
/**
* @covers \Bluz\Response\Response::removeHeaders
*/
public function testRemoveHeaders()
{
$this->response->addHeader('foo', 'bar');
$this->response->addHeader('baz', 'qux');
$this->response->removeHeaders();
self::assertFalse($this->response->hasHeader('foo'));
self::assertFalse($this->response->hasHeader('baz'));
}
/**
* @covers \Bluz\Response\Response::setCookie
* @covers \Bluz\Response\Response::getCookie
*/
public function testSetGetCookies()
{
$this->response->setCookie('foo', 'bar');
self::assertEqualsArray(['foo', 'bar', 0, '/', null, false, false], $this->response->getCookie('foo'));
}
/**
* Set cookie expire time as DateTime object
*/
public function testSetCookiesWithDatetime()
{
$dateTime = new \DateTime('now');
$this->response->setCookie('foo', 'bar', $dateTime);
self::assertEqualsArray(
['foo', 'bar', $dateTime->format('U'), '/', null, false, false],
$this->response->getCookie('foo')
);
}
public function testSetCookieWithWrongCookieNameThrowException()
{
$this->expectException(\InvalidArgumentException::class);
$this->response->setCookie('foo=', 'bar');
}
public function testSetCookieWithEmptyCookieNameThrowException()
{
$this->expectException(\InvalidArgumentException::class);
$this->response->setCookie('', 'bar');
}
public function testSetCookieWithWrongDateNameThrowException()
{
$this->expectException(\InvalidArgumentException::class);
$this->response->setCookie('foo', 'bar', 'the day before sunday');
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Config/ConfigLoaderTest.php | tests/unit/Config/ConfigLoaderTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Config;
use Bluz;
use Bluz\Config;
use Bluz\Config\ConfigException;
use Bluz\Tests\FrameworkTestCase;
class ConfigLoaderTest extends FrameworkTestCase
{
/**
* @var string Path to config dir
*/
protected $path;
/**
* @var string Path to empty config dir
*/
protected $emptyConfigsDir;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
$this->path = __DIR__ . '/Fixtures/';
$this->emptyConfigsDir = __DIR__ . '/Fixtures/emptyConfigsDir';
}
/**
* @covers \Bluz\Config\ConfigLoader::setPath
*/
public function testSetPathExeption(): void
{
$this->expectException(ConfigException::class);
$loader = new Config\ConfigLoader();
$loader->setPath('invalid/path');
}
/**
* @covers \Bluz\Config\ConfigLoader::setPath
*/
public function testSetPath(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
}
/**
* @covers \Bluz\Config\ConfigLoader::load
*/
public function testLoadConfigPathIsNotSetup(): void
{
$this->expectException(ConfigException::class);
$loader = new Config\ConfigLoader();
$loader->load();
}
/**
* @covers \Bluz\Config\ConfigLoader::load
*/
public function testLoadConfigFileNotFound(): void
{
$this->expectException(ConfigException::class);
$loader = new Config\ConfigLoader();
$loader->setPath($this->emptyConfigsDir);
$loader->load();
}
/**
* @covers \Bluz\Config\ConfigLoader::load
*/
public function testLoad(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->load();
}
/**
* @covers \Bluz\Config\ConfigLoader::load
*/
public function testLoadConfigWithEnvironment(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->load();
$configWithoutEnvironment = $loader->getConfig();
$loader2 = new Config\ConfigLoader();
$loader2->setPath($this->path);
$loader2->setEnvironment('testing');
$loader2->load();
$configWithEnvironment = $loader2->getConfig();
self::assertNotEquals($configWithoutEnvironment, $configWithEnvironment);
}
/**
* @covers \Bluz\Config\ConfigLoader::load
*/
public function testLoadConfigWithWrongEnvironment(): void
{
$this->expectException(ConfigException::class);
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->setEnvironment('not_existed_environment');
$loader->load();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Config/ConfigTest.php | tests/unit/Config/ConfigTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Config;
use Bluz;
use Bluz\Config;
use Bluz\Tests\FrameworkTestCase;
class ConfigTest extends FrameworkTestCase
{
/**
* @var string Path to config dir
*/
protected $path;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp(): void
{
$this->path = __DIR__ . '/Fixtures/';
}
/**
* @covers \Bluz\Config\Config::get
*/
public function testGetData(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->load();
$config = new Config\Config();
$config->setFromArray($loader->getConfig());
self::assertEquals(
['application' => ['section1' => 'default', 'section2' => [], 'section3' => []]],
$config->get()
);
}
/**
* @covers \Bluz\Config\Config::get
*/
public function testGetDataByNotExistedSection(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->load();
$config = new Config\Config();
$config->setFromArray($loader->getConfig());
self::assertNull($config->get('section_doesnt_exist'));
}
/**
* @covers \Bluz\Config\Config::get
*/
public function testGetDataBySection(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->load();
$config = new Config\Config();
$config->setFromArray($loader->getConfig());
self::assertEquals(
['section1' => 'default', 'section2' => [], 'section3' => []],
$config->get('application')
);
}
/**
* @covers \Bluz\Config\Config::get
*/
public function testGetDataBySubSection(): void
{
$loader = new Config\ConfigLoader();
$loader->setPath($this->path);
$loader->setEnvironment('testing');
$loader->load();
$config = new Config\Config();
$config->setFromArray($loader->getConfig());
self::assertEquals(1, $config->get('application', 'section1'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Config/Fixtures/modules/index/config.php | tests/unit/Config/Fixtures/modules/index/config.php | <?php
/**
* Index configuration for default environment
*
* @author Anton Shevchuk
* @created 19.09.2014 15:09
*/
return [
'foo' => 'bar',
'qux' => 'bar'
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Config/Fixtures/configs/default/application.php | tests/unit/Config/Fixtures/configs/default/application.php | <?php
return [
'section1' => 'default',
'section2' => [],
'section3' => [],
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Config/Fixtures/configs/testing/module.index.php | tests/unit/Config/Fixtures/configs/testing/module.index.php | <?php
/**
* Index configuration for testing environment
*
* @author Anton Shevchuk
* @created 19.09.2014 15:10
*/
return [
'foo' => 'baz'
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Config/Fixtures/configs/testing/application.php | tests/unit/Config/Fixtures/configs/testing/application.php | <?php
return [
'section1' => 1,
'section2' => [
'subsection21' => 21,
'subsection22' => 22
],
'section3' => [
'subsection31' => 31,
'subsection32' => 32
],
];
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Crud/TableTest.php | tests/unit/Crud/TableTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Crud;
use Bluz\Http\Exception\NotFoundException;
use Bluz\Proxy\Db;
use Bluz\Tests\Fixtures\Crud\TableCrud;
use Bluz\Tests\Fixtures\Models\Test\Row;
use Bluz\Tests\Fixtures\Models\Test\Table;
use Bluz\Tests\FrameworkTestCase;
/**
* Crud TableTest
*
* @package Bluz\Tests\Crud
*
* @author Anton Shevchuk
* @created 22.08.2014 16:13
*/
class TableTest extends FrameworkTestCase
{
/**
* @var TableCrud
*/
protected $crudTable;
/**
* setUp
*/
public function setUp(): void
{
parent::setUp();
$this->crudTable = TableCrud::getInstance();
$this->crudTable->setTable(Table::getInstance());
Db::query(
'INSERT INTO `test`(`id`, `name`, `email`, `status`) ' .
'VALUES (100, "CrudTestTable", "table@test.com", "disable")'
);
}
/**
* tearDown
*/
public function tearDown(): void
{
Db::query(
'DELETE FROM `test` WHERE `name` = "CrudTestTable"'
);
parent::tearDown();
}
/**
* getPrimaryKey Test
*/
public function testGetPrimaryKey()
{
self::assertTrue(array_search('id', $this->crudTable->getPrimaryKey()) !== false);
}
/**
* Method readOne with empty $primary should return new instance of row
*/
public function testReadOneCreate()
{
$row = $this->crudTable->readOne(null);
self::assertInstanceOf(Row::class, $row);
}
/**
* Method readOne with $primary should return instance of row
*/
public function testReadOneWithCorrectPrimary()
{
$row = $this->crudTable->readOne(100);
self::assertInstanceOf(Row::class, $row);
self::assertEquals(100, $row->id);
}
/**
* Method readOne with $primary should return instance of row
* Data should filtered by fields
*/
public function testReadOneWithFilter()
{
$this->crudTable->setFields(['name', 'email']);
$row = $this->crudTable->readOne(100);
self::assertInstanceOf(Row::class, $row);
self::assertEqualsArray(['name' => 'CrudTestTable', 'email' => 'table@test.com'], $row->toArray());
}
/**
* Method readOne with invalid $primary should throw exception
*/
public function testReadOneWithInvalidPrimary()
{
$this->expectException(NotFoundException::class);
$this->crudTable->readOne(10000);
}
/**
* Method readSet should return array of rows
*/
public function testReadSet()
{
list($rows, $total) = $this->crudTable->readSet(0, 10, []);
self::assertCount(10, $rows);
self::assertTrue($total > 0);
}
/**
* Method readSet should return array of rows
*/
public function testReadSetWithFilters()
{
$this->crudTable->setFields(['name', 'email']);
list($rows) = $this->crudTable->readSet();
self::assertCount(10, $rows);
self::assertCount(2, $rows[0]->toArray());
}
/**
* Method CreateOne should return primary key
*/
public function testCreateOne()
{
$result = $this->crudTable->createOne(
[
'name' => 'CrudTestTable',
'email' => 'table@test.com',
'status' => 'disabled'
]
);
self::assertArrayHasKey('id', $result);
}
/**
* Method UpdateOne should return number of affected rows
*/
public function testUpdateOne()
{
$result = $this->crudTable->updateOne(
100,
[
'name' => 'CrudTestTable',
'email' => uniqid('tableTest.', true) . '.' . date('His') . '@test.com',
'status' => 'active'
]
);
self::assertEquals(1, $result);
}
/**
* Method UpdateOne with invalid primary should throw exception
*/
public function testUpdateOneWithInvalidPrimary()
{
$this->expectException(NotFoundException::class);
$this->crudTable->updateOne(
10000,
[
'name' => 'CrudTestTable',
'email' => 'table@test.com',
'status' => 'active'
]
);
}
/**
* Method DeleteOne with primary should delete one
*/
public function testDeleteOneWithValidPrimary()
{
$result = $this->crudTable->deleteOne(100);
self::assertEquals(1, $result);
}
/**
* Method DeleteOne with invalid primary should throw exception
*/
public function testDeleteOneWithInvalidPrimary()
{
$this->expectException(NotFoundException::class);
$this->crudTable->deleteOne(10000);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Crud/CrudTest.php | tests/unit/Crud/CrudTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Crud;
use Bluz\Http\Exception\NotImplementedException;
use Bluz\Tests\Fixtures\Crud\EmptyCrud;
use Bluz\Tests\FrameworkTestCase;
/**
* CrudTest
*
* @package Bluz\Tests\Crud
*
* @author Anton Shevchuk
* @created 22.08.2014 16:13
*/
class CrudTest extends FrameworkTestCase
{
/**
* @covers \Bluz\Crud\AbstractCrud::readOne()
*/
public function testNotImplementedReadOneMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->readOne('any');
}
/**
* @covers \Bluz\Crud\AbstractCrud::readSet()
*/
public function testNotImplementedReadSetMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->readSet();
}
/**
* @covers \Bluz\Crud\AbstractCrud::createOne()
*/
public function testNotImplementedCreateOneMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->createOne([]);
}
/**
* @covers \Bluz\Crud\AbstractCrud::createSet()
*/
public function testNotImplementedCreateSetMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->createSet([]);
}
/**
* @covers \Bluz\Crud\AbstractCrud::updateOne()
*/
public function testNotImplementedUpdateOneMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->updateOne('any', []);
}
/**
* @covers \Bluz\Crud\AbstractCrud::updateSet()
*/
public function testNotImplementedUpdateSetMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->updateSet([]);
}
/**
* @covers \Bluz\Crud\AbstractCrud::deleteOne()
*/
public function testNotImplementedDeleteOneMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->deleteOne('any');
}
/**
* @covers \Bluz\Crud\AbstractCrud::deleteSet()
*/
public function testNotImplementedDeleteSetMethodThrowException()
{
$this->expectException(NotImplementedException::class);
EmptyCrud::getInstance()->deleteSet([]);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/ValidatorFormTest.php | tests/unit/Validator/ValidatorFormTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator;
use Bluz\Tests;
use Bluz\Validator\Exception\ValidatorException;
use Bluz\Validator\ValidatorForm;
/**
* Class ValidatorBuilderTest
*
* @package Bluz\Tests\Validator
*/
class ValidatorFormTest extends Tests\FrameworkTestCase
{
public function testSetCustomDescriptionOfValidatorChainShouldBeInValidatorException()
{
$validator = new ValidatorForm();
try {
$validator->add('some')
->callback('is_int')
->setDescription('is not numeric');
$validator->assert(['some' => 'something']);
} catch (ValidatorException $e) {
self::assertEquals('Invalid Arguments', $e->getMessage());
self::assertArrayHasKey('some', $e->getErrors());
self::assertEquals('is not numeric', $e->getErrors()['some']);
}
}
public function testAssertOptionalAndRequiredFields()
{
$validator = new ValidatorForm();
try {
$validator->add('foo')->callback('is_int');
$validator->add('bar')->required()->callback('is_int');
$validator->assert([]);
} catch (ValidatorException $e) {
self::assertEquals('Invalid Arguments', $e->getMessage());
$errors = $validator->getErrors();
self::assertEqualsArray($errors, $e->getErrors());
self::assertArrayNotHasKey('foo', $errors);
self::assertArrayHasKey('bar', $errors);
}
}
public function testAssertInvalidDataShouldRaiseExceptionWithErrorsMessages()
{
$validator = new ValidatorForm();
try {
$validator->add('foo')->required()->callback('is_int');
$validator->add('bar')->required()->callback('is_int');
$validator->add('quz')->required()->callback('is_int');
$validator->assert(['foo' => 42, 'bar' => 'something']);
} catch (ValidatorException $e) {
self::assertEquals('Invalid Arguments', $e->getMessage());
$errors = $validator->getErrors();
self::assertEqualsArray($errors, $e->getErrors());
self::assertArrayNotHasKey('foo', $errors);
self::assertArrayHasKey('bar', $errors);
self::assertArrayHasKey('quz', $errors);
}
}
public function testAssertEmptyDataShouldRaiseException()
{
$this->expectException(ValidatorException::class);
$validator = new ValidatorForm();
$validator->add('foo')->required();
$validator->add('bar')->numeric();
$validator->assert([]);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/ValidatorTest.php | tests/unit/Validator/ValidatorTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Exception\ValidatorException;
use Bluz\Validator\Rule\RuleInterface;
use Bluz\Validator\Validator;
use Bluz\Validator\ValidatorChain;
/**
* Class ValidatorTest
*
* @package Bluz\Tests\Validator
*/
class ValidatorTest extends Tests\FrameworkTestCase
{
/**
* Create new instance of validator
*/
public function testStaticCreateShouldReturnNewValidatorChain()
{
self::assertInstanceOf(ValidatorChain::class, Validator::create());
}
/**
* Every static call of exist Rule should be return a new instance of Rule
*/
public function testStaticCallsShouldReturnNewValidatorChain()
{
self::assertInstanceOf(
ValidatorChain::class,
Validator::array(
function () {
return true;
}
)
);
self::assertInstanceOf(ValidatorChain::class, Validator::string());
self::assertInstanceOf(ValidatorChain::class, Validator::notEmpty());
}
public function testStaticCallShouldCreateValidRule()
{
$validator = Validator::callback('is_int');
self::assertTrue($validator->validate(42));
}
public function testStaticCallShouldAllowInvokeIt()
{
self::assertTrue(Validator::callback('is_int')(42));
}
public function testStaticAddRuleNamespace()
{
Validator::addRuleNamespace('\\Bluz\\Tests\\Fixtures\\Validator\\Rule\\');
self::assertInstanceOf(ValidatorChain::class, Validator::custom());
}
public function testInvalidRuleClassShouldRaiseComponentException()
{
$this->expectException(ComponentException::class);
Validator::iDoNotExistSoIShouldThrowException();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/ValidatorChainTest.php | tests/unit/Validator/ValidatorChainTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator;
use Bluz\Tests;
use Bluz\Validator\Exception\ValidatorException;
use Bluz\Validator\Rule\RuleInterface;
use Bluz\Validator\Validator;
use Bluz\Validator\ValidatorChain;
/**
* Class ValidatorChainTest
*
* @package Bluz\Tests\Validator
*/
class ValidatorChainTest extends Tests\FrameworkTestCase
{
public function testRunValidationWithValidDataShouldPass()
{
$validatorChain = Validator::alphaNumeric('_')->length(1, 15)->noWhitespace();
self::assertTrue($validatorChain->validate('username'));
}
public function testEvalValidationWithValidDataShouldPass()
{
$validatorChain = Validator::alphaNumeric('_')->length(1, 15)->noWhitespace();
self::assertTrue($validatorChain('username'));
self::assertTrue($validatorChain('user_name'));
}
public function testRunValidationWithInvalidDataShouldFail()
{
$validatorChain = Validator::alphaNumeric('_')->length(1, 15)->noWhitespace();
self::assertFalse($validatorChain->validate('invalid username'));
}
/**
* Complex test with exception
*/
public function testAssertInvalidDataShouldRaiseException()
{
$this->expectException(ValidatorException::class);
Validator::alphaNumeric('_')->length(1, 15)->noWhitespace()->assert('invalid username');
}
public function testSetCustomDescriptionForCallbackRuleShouldUseItInChainDescription()
{
$chain = Validator::create()
->callback('is_int', 'it should be custom one')
->callback('is_numeric', 'it should be custom two')
;
self::assertEqualsArray(
['it should be custom one', 'it should be custom two'],
$chain->getDescription()
);
}
public function testSetCustomDescriptionForRegexpRuleShouldUseItInChainDescription()
{
$chain = Validator::create()
->regexp('[0-9]+', 'it should be custom one')
->regexp('[a-z]+', 'it should be custom two')
;
self::assertEqualsArray(
['it should be custom one', 'it should be custom two'],
$chain->getDescription()
);
}
public function testSetCustomDescriptionForRuleShouldUseItInChainDescription()
{
$chain = Validator::callback('is_int', 'it should be custom one')
->callback('is_numeric', 'it should be custom two');
self::assertEqualsArray(
['it should be custom one', 'it should be custom two'],
$chain->getDescription()
);
}
public function testSetCustomDescriptionForSingleRuleShouldUseItAsErrorMessage()
{
try {
Validator::callback('is_int', 'it should be custom')
->callback('is_numeric', 'it should be custom')
->assert('something');
} catch (\Exception $e) {
self::assertEquals('it should be custom', $e->getMessage());
}
}
public function testSetCustomDescriptionForValidatorChainShouldUseItInChainDescription()
{
$chain = Validator::create()
->callback('is_int')
->callback('is_numeric')
->setDescription('it should be custom');
self::assertEqualsArray(
['it should be custom'],
$chain->getDescription()
);
}
public function testSetCustomDescriptionForValidatorChainShouldUseItAsErrorMessage()
{
try {
Validator::create()
->callback('is_int')
->callback('is_numeric')
->setDescription('it should be custom')
->assert('something');
} catch (\Exception $e) {
self::assertEquals('it should be custom', $e->getMessage());
}
}
public function testSetCustomDescriptionForValidatorChain()
{
$validator = Validator::create()
->alphaNumeric('_')
->length(1, 15)
->noWhitespace();
$ruleText = "must contain only Latin letters, digits and \"_\"\n"
. "must have a length between \"1\" and \"15\"\n"
. "must not contain whitespace";
self::assertEquals($validator->__toString(), $ruleText);
$customRuleText = "Username must contain only letters, digits and underscore, \n"
. "must have a length between 1 and 15";
$validator->setDescription($customRuleText);
self::assertEquals($validator->__toString(), $customRuleText);
self::assertFalse($validator->validate('user#name'));
self::assertNotEmpty($validator->getError());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/MoreOrEqualTest.php | tests/unit/Validator/Rule/MoreOrEqualTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\MoreOrEqualRule as Rule;
/**
* Class MinTest
*
* @package Bluz\Tests\Validator\Rule
*/
class MoreOrEqualTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $minValue
* @param $input
*/
public function testValidMoreShouldPass($minValue, $input)
{
$rule = new Rule($minValue);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $minValue
* @param $input
*/
public function testInvalidMoreShouldFail($minValue, $input)
{
$rule = new Rule($minValue);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[1, true],
[0, false],
[0, null],
[0, 0],
[0, '0'],
[0, '1'],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[2, false],
[2, null],
[2, ''],
[2, 0],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/SlugTest.php | tests/unit/Validator/Rule/SlugTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\SlugRule as Rule;
/**
* Class SlugTest
*
* @package Bluz\Tests\Validator\Rule
*/
class SlugTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidSlugShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidSlugShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
['o-rato-roeu-o-rei-de-roma'],
['o-alganet-e-um-feio'],
['a-e-i-o-u'],
['anticonstitucionalissimamente']
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[''],
['o-alganet-é-um-feio'],
['á-é-í-ó-ú'],
['-assim-nao-pode'],
['assim-tambem-nao-'],
['nem--assim'],
['--nem-assim'],
['Nem mesmo Assim'],
['Ou-ate-assim'],
['-Se juntar-tudo-Então-']
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/LessTest.php | tests/unit/Validator/Rule/LessTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\LessRule as Rule;
/**
* Class MaxTest
*
* @package Bluz\Tests\Validator\Rule
*/
class LessTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $maxValue
* @param $input
*/
public function testValidLessInputShouldPass($maxValue, $input)
{
$rule = new Rule($maxValue);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $maxValue
* @param $input
*/
public function testInvalidLessValueShouldFail($maxValue, $input)
{
$rule = new Rule($maxValue);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[200, ''], // empty string is equal zero
[200, -200],
[200, 0],
[200, 165.0],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[-200, 0],
[0, 0],
[200, 250],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/ContainsTest.php | tests/unit/Validator/Rule/ContainsTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\ContainsRule;
/**
* Class ContainsTest
*
* @package Bluz\Tests\Validator\Rule
*/
class ContainsTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $start
* @param $input
*/
public function testStringsContainingExpectedValueShouldPass($start, $input)
{
$validator = new ContainsRule($start);
self::assertTrue($validator->validate($input));
}
/**
* @dataProvider providerForFail
*
* @param $start
* @param $input
*/
public function testStringsNotContainsExpectedValueShouldFail($start, $input)
{
$validator = new ContainsRule($start);
self::assertFalse($validator->validate($input));
self::assertNotEmpty($validator->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['foo', ['bar', 'foo']],
['foo', 'barfoo'],
['foo', 'barFOO'],
['foo', 'foobazfoo'],
['1', [1, 2, 3]],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['foo', ''],
['foo', 'barf00'],
['foo', ['bar', 'f00']],
['4', [1, 2, 3]],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.