public function testPersist()
 {
     $mapper = new StatusMapper($this->connection);
     $rows = $this->connection->query('SELECT COUNT(*) FROM STATUSES')->fetch(PDO::FETCH_NUM);
     $this->assertEquals(0, $rows[0]);
     $status = new Status(null, 'picharles', 'message', date('Y-m-d H:i:s'));
     $mapper->persist($status);
     $rows = $this->connection->query('SELECT COUNT(*) FROM STATUSES')->fetch(PDO::FETCH_NUM);
     $this->assertEquals(1, $rows[0]);
 }
Exemplo n.º 2
0
use Model\Finder\StatusFinder;
use Model\Finder\UserFinder;
use Http\JsonResponse;
use Http\Response;
use Http\Request;
use Model\DataBase\DatabaseConnection;
use Model\DataMapper\StatusMapper;
use Model\DataMapper\UserMapper;
use Model\Entity\Status;
use Model\Entity\User;
// Config
$debug = true;
$connection = new DatabaseConnection();
$statusFinder = new StatusFinder($connection);
$userFinder = new UserFinder($connection);
$statusMapper = new StatusMapper($connection);
$userMapper = new UserMapper($connection);
//$finder = new JsonFinder();
/**
 * Index
 */
$app = new \App(new View\TemplateEngine(__DIR__ . '/templates/'), $debug);
// Matches if the HTTP method is GET -> /
$app->get('/', function () use($app) {
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /statuses/
$app->get('/statuses/', function () use($app) {
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /login