public function testMainCallsFind() { $userClass = \idfly\Moka::stubClass(null, ['::find' => 'USER']); $controller = new UsersController($userClass); $controller->find(1000); // check that `find` was called with 100 $this->assertEquals([1000], $userClass::$moka->report('find')[0]); }
$userId = $_SESSION['userId']; if ($_SERVER['REQUEST_METHOD'] == 'POST' || $_SERVER['REQUEST_METHOD'] == 'post') { /* get all the post data from */ $poiName = decodeInput($_POST['poiName']); $poiAddress = decodeInput($_POST['poiAddress']); $poiCategory = decodeInput($_POST['poiCategory']); $poiPhone = decodeInput($_POST['poiPhone']); $poiEmail = decodeInput($_POST['poiEmail']); $poiWebsite = decodeInput($_POST['poiWebsite']); $poiLatitude = decodeInput($_POST['poiLat']); $poiLongitude = decodeInput($_POST['poiLong']); $poiPosition = $poiLatitude . "," . $poiLongitude; $poiContribution = decodeInput($_POST['poiContribution']); $userController = new UsersController(); $poiController = new PoiController(); $categoryController = new CategoryController(); $contributionController = new ContributionController(); /* since we are letting the validation of the data on the client side, we will skip the validation here and just go on with insertion */ /* so first create the poi object, also the required objects to initialize the poi */ $poi = new POI(); $poi->init($poiName, $poiAddress, $poiPosition, $categoryController->find($poiCategory), $poiPhone, $poiEmail, $poiWebsite, "", $userController->find($user->getId())); if ($poiContribution != 0) { if (is_numeric($poiContribution)) { if ($contribution = $contributionController->find($poiContribution)) { $poi->setContribution($contribution); } } } $poiController->add($poi); }
<?php /** * Created by Yogesh on 12/2/2015. * */ session_start(); require_once "../config/Route.php"; require_once "../model/UsersController.php"; require_once "../model/ContributionController.php"; if (array_key_exists('userId', $_SESSION)) { $contributionController = new ContributionController(); $userController = new UsersController(); $userId = $_SESSION['userId']; $user = $userController->find($userId); if ($user) { if (array_key_exists('post', $_GET) && array_key_exists('s', $_GET)) { $id = test_input($_GET['post']); $poi = $contributionController->find($id); if ($poi) { $action = test_input($_GET['s']); switch ($action) { case "a": $poi->setStatus("A"); $contributionController->update($poi); Route::redirect($_SERVER['HTTP_REFERER']); break; case "r": $poi->setStatus("R"); $contributionController->update($poi); Route::redirect($_SERVER['HTTP_REFERER']);
*/ include_once "../model/objects/POI.php"; include_once "../model/CategoryController.php"; include_once "../model/PoiController.php"; include_once "../model/ContributionController.php"; include_once "../model/UsersController.php"; $userId = $_SESSION['userId']; if ($_SERVER['REQUEST_METHOD'] == 'POST' || $_SERVER['REQUEST_METHOD'] == 'post') { /* get all the post data from */ $id = decodeInput($_POST['id']); $poiName = decodeInput($_POST['poiName']); $poiAddress = decodeInput($_POST['poiAddress']); $poiCategory = decodeInput($_POST['poiCategory']); $poiPhone = decodeInput($_POST['poiPhone']); $poiEmail = decodeInput($_POST['poiEmail']); $poiWebsite = decodeInput($_POST['poiWebsite']); $poiLatitude = decodeInput($_POST['poiLat']); $poiLongitude = decodeInput($_POST['poiLong']); $poiPosition = $poiLatitude . "," . $poiLongitude; $poiContribution = decodeInput($_POST['poiContribution']); $userController = new UsersController(); $poiController = new PoiController(); $categoryController = new CategoryController(); $contributionController = new ContributionController(); /* since we are letting the validation of the data on the client side, we will skip the validation here and just go on with insertion */ /* so first create the poi object, also the required objects to initialize the poi */ $poi = new POI(); $poi->initWithId($id, $poiName, $poiAddress, $poiPosition, $categoryController->find($poiCategory), $poiPhone, $poiEmail, $poiWebsite, "", "", new Contribution(), $userController->find($user->getId())); $poiController->update($poi); }