public function testCreaNuovoEvento() { $data = array('titolo' => 'nuovo titolo swift', 'descrizione' => 'bla bla bla', 'data_inizio' => '15-10-2010', 'data_fine' => '18-10-2010'); $es = new EventoService(); $es->creaNuovoEvento($data, $this->pdo); $mail = file_get_contents('/var/www/phpday2010/test/mail/admin@example.com.1'); $this->assertRegExp('/From: webmaster@example.com/', $mail); $this->assertRegExp('/To: admin@example.com/', $mail); $this->assertRegExp('/Subject: nuovo evento: nuovo titolo swift/', $mail); $this->assertRegExp('/stato pubblicato un nuovo evento/', $mail); }
<?php require_once '../lib/EventoService.php'; require_once '../lib/ConnectionManager.php'; if (!isset($_POST['crea_evento'])) { header('Location: http://localhost/phpday2010/web/nuovoevento.php'); } $evento_s = new EventoService(); $evento_s->creaNuovoEvento($_POST, ConnectionManager::getConnection()); header('Location: http://localhost/phpday2010/web/nuovoevento.php?message=' . urlencode("Evento creato con successo!"));