function testGetBSONDocument() { $d = new Dummy(); $d->dum = 'dum-dum'; $d->username = '******'; $doc = $d->getBSONDocument(); $this->assertTrue(array_key_exists('username', bson_decode($doc))); $this->assertTrue(array_key_exists('dum', bson_decode($doc))); }
public function testGetHeadersFromLastResponse() { $dummy = new Dummy(); $this->assertNull($dummy->getHeadersFromLastResponse()); $dummy->setLastHeaders($this->getTestHeaders()); $headers = $dummy->getHeadersFromLastResponse(); $this->assertCount(7, $headers); $this->assertCount(2, $headers['x-li-format']); $this->assertEquals('Foo', $headers['Server'][0]); }
function testArrayUnsetNull() { $arr = array(1, 2, 3, 4); $doc = new Dummy(); $doc->arr = $arr; $doc->save(); unset($arr[1], $arr[3]); $doc->arr = $arr; $doc->save(); $this->assertEquals($arr, $doc->arr); }
/** * Test configuration. */ public function testConfigure() { $object = new Dummy(); $object->configure(array('foo' => 'foo')); $this->assertEquals('foo', $object->foo); try { $object->configure(array('bar' => 'bar')); $this->assertNull($object->bar); } catch (\Paytrail\Exception\PropertyDoesNotExist $e) { // this is the expected outcome. } }
/** * @test * @expectedException \Exception */ public function it_should_throw_an_exception_if_included_in_a_non_eloquent_model() { /** * * Set * */ \Dummy::getProxy(); }
/** * Check in the payment processor after the payment is complete. * @return mixed For external payment methods: * The integer order ID, if known, upon success * For internal payment methods: * Boolean true, in order to make these skip the order * status update, as this has already been done. * If the order ID is unknown or upon failure: * Boolean false */ static function checkIn() { //DBG::log("PaymentProcessing::checkIn(): Entered"); //DBG::log("POST: ".var_export($_POST, true)); //DBG::log("GET: ".var_export($_GET, true)); $result = NULL; if (isset($_GET['result'])) { $result = abs(intval($_GET['result'])); if ($result == 0 || $result == 2) { return false; } } if (empty($_REQUEST['handler'])) { return false; } switch ($_REQUEST['handler']) { case 'paymill_cc': case 'paymill_elv': case 'paymill_iban': $arrShopOrder = array('order_id' => $_SESSION['shop']['order_id'], 'amount' => intval(bcmul($_SESSION['shop']['grand_total_price'], 100, 0)), 'currency' => Currency::getActiveCurrencyCode(), 'note' => $_SESSION['shop']['note']); $response = \PaymillHandler::processRequest($_REQUEST['paymillToken'], $arrShopOrder); \DBG::log(var_export($response, true)); if ($response['status'] === 'success') { return true; } else { \DBG::log("PaymentProcessing::checkIn(): WARNING: paymill: Payment verification failed; errors: " . var_export($response, true)); return false; } case 'saferpay': $arrShopOrder = array('ACCOUNTID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_id', 'Shop')); $id = \Saferpay::payConfirm(); if (\Cx\Core\Setting\Controller\Setting::getValue('saferpay_finalize_payment', 'Shop')) { $arrShopOrder['ID'] = $id; $id = \Saferpay::payComplete($arrShopOrder); } //DBG::log("Transaction: ".var_export($transaction, true)); return (bool) $id; case 'paypal': if (empty($_POST['custom'])) { //DBG::log("PaymentProcessing::checkIn(): No custom parameter, returning NULL"); return NULL; } $order_id = \PayPal::getOrderId(); // if (!$order_id) { // $order_id = (isset($_SESSION['shop']['order_id']) // ? $_SESSION['shop']['order_id'] // : (isset ($_SESSION['shop']['order_id_checkin']) // ? $_SESSION['shop']['order_id_checkin'] // : NULL)); // } $order = Order::getById($order_id); $amount = $currency_id = $customer_email = NULL; if ($order) { $amount = $order->sum(); $currency_id = $order->currency_id(); $customer_id = $order->customer_id(); $customer = Customer::getById($customer_id); if ($customer) { $customer_email = $customer->email(); } } $currency_code = Currency::getCodeById($currency_id); return \PayPal::ipnCheck($amount, $currency_code, $order_id, $customer_email, \Cx\Core\Setting\Controller\Setting::getValue('paypal_account_email', 'Shop')); case 'yellowpay': $passphrase = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_hash_signature_out', 'Shop'); return \Yellowpay::checkIn($passphrase); // if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) { // global $_ARRAYLANG; // echo('<font color="red"><b>'. // $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY']. // '</b><br />'. // 'Errors:<br />'. // join('<br />', \Yellowpay::$arrError). // 'Warnings:<br />'. // join('<br />', \Yellowpay::$arrWarning). // '</font>'); // } // if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) { // global $_ARRAYLANG; // echo('<font color="red"><b>'. // $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY']. // '</b><br />'. // 'Errors:<br />'. // join('<br />', \Yellowpay::$arrError). // 'Warnings:<br />'. // join('<br />', \Yellowpay::$arrWarning). // '</font>'); // } case 'payrexx': return \PayrexxProcessor::checkIn(); // Added 20100222 -- Reto Kohli // Added 20100222 -- Reto Kohli case 'mobilesolutions': // A return value of null means: Do not change the order status if (empty($_POST['state'])) { return null; } $result = \PostfinanceMobile::validateSign(); if ($result) { //DBG::log("PaymentProcessing::checkIn(): mobilesolutions: Payment verification successful!"); } else { DBG::log("PaymentProcessing::checkIn(): WARNING: mobilesolutions: Payment verification failed; errors: " . var_export(\PostfinanceMobile::getErrors(), true)); } return $result; // Added 20081117 -- Reto Kohli // Added 20081117 -- Reto Kohli case 'datatrans': return \Datatrans::validateReturn() && \Datatrans::getPaymentResult() == 1; // For the remaining types, there's no need to check in, so we // return true and jump over the validation of the order ID // directly to success! // Note: A backup of the order ID is kept in the session // for payment methods that do not return it. This is used // to cancel orders in all cases where false is returned. // For the remaining types, there's no need to check in, so we // return true and jump over the validation of the order ID // directly to success! // Note: A backup of the order ID is kept in the session // for payment methods that do not return it. This is used // to cancel orders in all cases where false is returned. case 'internal': case 'internal_creditcard': case 'internal_debit': case 'internal_lsv': return true; // Dummy payment. // Dummy payment. case 'dummy': $result = ''; if (isset($_REQUEST['result'])) { $result = $_REQUEST['result']; } // Returns the order ID on success, false otherwise return \Dummy::commit($result); default: break; } // Anything else is wrong. return false; }
/** * @test * @expectedException \Exception */ public function it_should_boot_callback_trait_and_throw_exception() { \Dummy::bootCallableTrait(); }
<?php // create a dummy class. (requires write access to // current working directory) $class = <<<EOF <?php class Dummy { function hello() { echo __CLASS__,' was autoloaded', PHP_EOL; } } EOF; file_put_contents('Dummy.php', $class); // require Jm_Autoloader require_once 'Jm/Autoloader.php'; $d = new Dummy(); $d->hello(); unlink('Dummy.php');
public function testDummy() { $dummy = new Dummy(); $this->assertTrue($dummy->getTrue()); }
function testDrop() { $c = new Dummy(); $c['foo'] = 'bar'; $c->save(); $this->assertFalse(ActiveMongo::drop()); $this->assertTrue(Dummy::drop()); try { $this->assertFalse(Dummy::drop()); } catch (ActiveMongo_Exception $e) { $this->assertTrue(TRUE); } }
/** * Test that storeState() returns dummy instance * * @covers Mixpanel\DataStorage\Dummy::storeState */ public function testStoreStateReturnsDummy() { $this->assertSame($this->dummy, $this->dummy->storeState()); }
/** * @dataProvider providerReverseStringWithoutVowels */ public function testReverseStringWithoutVowels($expected, $actual) {
public function testError() { $I = $this->codeGuy; $model = new Dummy(); $model->addError('text', 'Error text'); $html = TbHtml::error($model, 'text', array('class' => 'error')); $span = $I->createNode($html, 'span.help-inline'); $I->seeNodeCssClass($span, 'error'); $I->seeNodeText($span, 'Error text'); }
<?php try { if (php_sapi_name() != 'cli') { throw new Exception('Script must be run in the command line'); } if ($argc != 2) { throw new Exception('Wrong data'); } require 'Dummy.php'; echo Dummy::reverseStringWithoutVowels($argv[1]); } catch (Exception $e) { echo $e->getMessage(); }
echo "[Users ". $this->_xline[3] . "]\n"; $i = 0; foreach ($this->getNickList($this->_xline[3]) as $nick) { if ($i > 4) { echo "\n"; $i = 0; } else { echo "[ " . str_pad($nick, 10) . " ] "; $i++; } } echo "\n"; } } $dummy = new Dummy; $dummy->setDebug(false); $dummy->setUser($USER, 'dummy', 'Yet Another PHP IRC Library', '+i'); $dummy->setServer($SERVER); echo "starting yapircl test\n"; $dummy->connect(); echo "connected to $SERVER\n"; $dummy->run(); ?>
public function handleRequest(Request $request, Response $response) { //$this->printParams($request); // Execute command switch ($request->getParameter("command")) { case "changePassword": $command = new ChangePassword(); $command->setPortal($this->portal); break; case "resetPassword": $command = new ResetPassword(); break; case "lockUnlockUser": $command = new LockUnlockUser(); break; case "trashRestoreUser": $command = new TrashRestoreUser(); break; case "createEmployee": $command = new CreateEmployee(); break; case "modifyEmployee": $command = new ModifyEmployee(); break; case "deleteEmployee": $command = new DeleteEmployee(); break; case "deleteEmployeeAJAX": $command = new DeleteEmployeeAJAX(); break; case "deleteMultipleEmployees": $command = new DeleteMultipleEmployees(); break; case "importCSVFile": $command = new ImportExcelFile(); break; case "deleteHistory": $command = new DeleteHistory(); break; case "exportEmployees": $command = new ExportEmployees(); break; case "createBranch": $command = new CreateBranch(); break; case "modifyBranch": $command = new ModifyBranch(); break; case "deleteBranch": $command = new DeleteBranch(); break; case "createCustomer": $command = new CreateCustomer(); break; case "modifyCustomer": $command = new ModifyCustomer(); break; case "deleteCustomer": $command = new DeleteCustomer(); break; case "assignEmployeeToCourse": $command = new AddParticipantToCourse(); break; case "assignEmployeesToCourseByCSV": $command = new AddParticipantsToCourseByCSV(); break; case "removeEmployeeFromCourse": $command = new RemoveParticipantFromCourse(); break; case "activateCourse": $command = new ActivateCourse(); break; case "deactivateCourse": $command = new DeactivateCourse(); break; case "changeCourseQuota": $command = new ChangeCourseQuota(); break; case "changeAdminPerspective": $command = new ChangeAdminPerspective(); break; case "getParticipants": $command = new GetParticipants(); break; case "showCourseDialog": $command = new ShowCourseDialog(); break; case "generateLicense": $command = new GenerateLicense(); break; case "getEncryptKey": $command = new GetEncryptKey(); break; case "setEncryptKey": $command = new SetEncryptKey(); break; case "installLicense": $command = new InstallLicense(); break; case "createCourse": $command = new CreateCourse(); break; case "toggleCustomerAdmin": $command = new ToggleCustomerAdmin(); break; case "toggleSystemAdmin": $command = new ToggleSystemAdmin(); break; case "changeCourseRole": $command = new ChangeCourseRole(); break; default: $command = new Dummy(); } try { $result = $command->execute($request, $response); if (is_array($result)) { return json_encode($result); } else { $this->portal->set_confirmation($result); } } catch (UsermanagementException $exception) { $this->portal->set_problem_description($exception->getProblem(), $exception->getHint()); } }
/** データベース 動作テスト */ public function sqlites_test() { echo 'DBtest'; $dummy = new Dummy(); $dummy_logs = array('heartbeat' => $dummy->heartbeat(), 'calories' => $dummy->calories(), 'elevation' => $dummy->elevation(), 'blood' => $dummy->blood(), 'speed' => $dummy->speed()); //var_dump($dummy_logs); echo json_encode($dummy_logs); $this->load->model('dummy_log_model', 'DummyLog', TRUE); // 書き込み $this->DummyLog->insert_dummy_data($dummy_logs); // 表示 $data = $this->DummyLog->get_all_data(); var_dump($data); }
public static function notImplemented($uriParts, $parameters) { $d = new Dummy(); $response = $d->buildResponse("fail", 503, "Federated Sharing is not active on this server"); $d->sendResponse($response, $d->getFormat($parameters)); }