コード例 #1
0
ファイル: MediatorTest.php プロジェクト: idr0id/mediator
 public function testException()
 {
     // arrange
     $mediator = new Mediator();
     // act
     $this->setExpectedException('Mediator\\MediatorException', 'Handlers were not found for command <Mediator\\Tests\\Fixture\\Ping>');
     $mediator->handle(new Ping());
 }
コード例 #2
0
ファイル: index.php プロジェクト: sava90/pattern
<?php

require_once __DIR__ . '/vendor/autoload.php';
ini_set('display_errors', 'On');
error_reporting(E_ALL);
use DataMapper\UserEntity;
use DataMapper\UserMapper;
use DBAL\DBAL;
use Mediator\Mediator;
use Controller\UserController;
use Service\UserService;
use Registry\Registry;
$mediator = new Mediator();
$userEntity = new UserEntity();
$userEntity->setUserName('name');
$userEntity->setEmail('*****@*****.**');
$userMapper = new UserMapper(new DBAL('localhost', 'writing_test', 'root', 'password123'));
$userMapper->save($userEntity);
$userController = new UserController($mediator);
$mediator->set(new UserService(), 'login');
$userController->login();
$registry = new Registry();
$registry::set('key', 'value');
$registry::set('key2', 'value2');
echo $registry::get('key2');