1. Go to this page and download the library: Download phalcon/talon library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phalcon / talon example snippets
// tests/bootstrap.php
tings;
use Phalcon\Talon\Talon;
Talon::boot(Settings::fromEnv());
use Phalcon\Talon\Bootstrap\Runner;
use Phalcon\Talon\Bootstrap\Stage;
use Phalcon\Talon\Settings;
Runner::for(Settings::fromArray(['root' => __DIR__ . '/..']))
->before(Stage::Environment, fn () => ini_set('memory_limit', '512M'))
->after(Stage::Directories, fn ($settings) => mkdir($settings->outputPath('screens'), 0777, true))
->boot();
use Phalcon\Talon\PHPUnit\AbstractUnitTestCase;
final class CalculatorTest extends AbstractUnitTestCase
{
public function testInternal(): void
{
$this->assertSame(5, $this->callProtectedMethod(new Calculator(), 'add', 2, 3));
}
}
use Phalcon\Talon\PHPUnit\AbstractDatabaseTestCase;
final class UserTest extends AbstractDatabaseTestCase
{
public function testSeeded(): void
{
$this->assertInDatabase('users', ['email' => '[email protected]']);
}
}
use Phalcon\Talon\Database\Schema\AbstractSchema;
final class WidgetSchema extends AbstractSchema
{
protected string $table = 'widgets';
public function insert(int $id, string $label): int
{
return $this->execute(
'INSERT INTO widgets (id, label) VALUES (:id, :label)',
[':id' => $id, ':label' => $label]
);
}
protected function getStatementsMysql(): array
{
return ['CREATE TABLE widgets (id INT PRIMARY KEY, label VARCHAR(64));'];
}
protected function getStatementsPgsql(): array
{
return ['CREATE TABLE widgets (id INTEGER PRIMARY KEY, label VARCHAR(64));'];
}
protected function getStatementsSqlite(): array
{
return ['CREATE TABLE widgets (id INTEGER PRIMARY KEY, label TEXT);'];
}
}
$this->addTable('users');
use Phalcon\Talon\PHPUnit\AbstractFunctionalTestCase;
final class HomeTest extends AbstractFunctionalTestCase
{
protected function appFactory(): callable
{
return fn () =>
use Phalcon\Talon\PHPUnit\AbstractBrowserTestCase;
final class LoginTest extends AbstractBrowserTestCase
{
protected function appFactory(): callable
{
return fn () => password', 'password1');
$this->pressButton('Log In');
$this->assertPageContainsText('Search users');
}
}
use Phalcon\Talon\PHPUnit\AbstractServicesTestCase;
final class CacheTest extends AbstractServicesTestCase
{
public function testRedis(): void
{
$this->setRedisKey('key', 'value');
$this->assertSame('value', $this->getRedisKey('key'));
}
}
use Phalcon\Talon\Traits\ResultSetTrait;
final class ReportTest extends \PHPUnit\Framework\TestCase
{
use ResultSetTrait;
public function testReport(): void
{
$resultset = $this->mockResultSet([$modelA, $modelB]);
$this->assertCount(2, $resultset);
}
}