Пример #1
0
 /**
  * Test method init()
  */
 public function testInit()
 {
     oxAddClassModule('GenericImportTest_oxUtilsServer', 'oxUtilsServer');
     $oImport = new GenericImport();
     /** @var oxUser|MockObject $oUser */
     $oUser = $this->getMock('oxUser', array('isAdmin'));
     $oUser->expects($this->any())->method('isAdmin')->will($this->returnValue(true));
     $oUser->login(oxADMIN_LOGIN, oxADMIN_PASSWD);
     $oUser->loadAdminUser();
     $this->assertTrue($oImport->init());
 }
Пример #2
0
 public function testInsert()
 {
     $iTime = time();
     oxAddClassModule('modOxUtilsDate', 'oxUtilsDate');
     oxRegistry::get("oxUtilsDate")->UNITSetTime($iTime);
     $this->_oObj->delete();
     // resaving
     $this->_oObj->oxgbentries__oxcreate = new oxField(null, oxField::T_RAW);
     $this->_oObj->save();
     $this->assertEquals(date('Y-m-d H:i:s', $iTime), $this->_oObj->oxgbentries__oxcreate->value);
 }
Пример #3
0
 public function testInsert()
 {
     oxAddClassModule('modOxUtilsDate', 'oxUtilsDate');
     oxRegistry::get("oxUtilsDate")->UNITSetTime(100);
     $oAlarm = oxNew('oxpricealarm');
     $oAlarm->setId('testalarm');
     $oAlarm->save();
     $oAlarm = oxNew('oxpricealarm');
     $oAlarm->load('testalarm');
     $this->assertEquals('1970-01-01 00:00:00', $oAlarm->oxpricealarm__oxinsert->value);
 }
Пример #4
0
 public function testInsert()
 {
     $iNow = time();
     oxAddClassModule('modOxUtilsDate', 'oxUtilsDate');
     oxRegistry::get("oxUtilsDate")->UNITSetTime($iNow);
     $oRemark = oxNew('oxremark');
     $oRemark->load($this->_oRemark->oxremark__oxid->value);
     $oRemark->delete();
     $oRemark = oxNew('oxremark');
     $oRemark->setId($this->_oRemark->oxremark__oxid->value);
     $oRemark->save();
     $this->assertEquals(date('Y-m-d H:i:s', $iNow), $oRemark->oxremark__oxcreate->value);
 }
Пример #5
0
 /**
  * Initialize the fixture.
  *
  * @return null
  */
 protected function setUp()
 {
     parent::setUp();
     oxAddClassModule('Unit\\Application\\Model\\modOxDelivery', 'oxDelivery');
     $this->cleanUpTable('oxdelivery');
     $this->cleanUpTable('oxobject2delivery');
     $this->cleanUpTable('oxarticles');
     $this->aArticleIds = array();
     $oDelivery = oxNew('oxDelivery');
     $oDelivery->setId('_testDeliveryId');
     $oDelivery->oxdelivery__oxtitle = new oxField('test_oxDelivery', oxField::T_RAW);
     $oDelivery->save();
     $this->_sOxId = $oDelivery->getId();
     // insert test articles
     for ($i = 1; $i <= 3; $i++) {
         $oArticle = oxNew("oxArticle");
         $oArticle->setId('_testArticleId' . $i);
         $oArticle->oxarticles__oxtitle = new oxField('testArticle' . $i, oxField::T_RAW);
         $oArticle->oxarticles__oxartnum = new oxField(1000 + $i, oxField::T_RAW);
         $oArticle->oxarticles__oxshortdesc = new oxField('testArticle' . $i . 'Description', oxField::T_RAW);
         $oArticle->oxarticles__oxprice = new oxField('256', oxField::T_RAW);
         $oArticle->oxarticles__oxremindactive = new oxField('1', oxField::T_RAW);
         $oArticle->oxarticles__oxstock = new oxField('9', oxField::T_RAW);
         $oArticle->oxarticles__oxlength = new oxField('2', oxField::T_RAW);
         $oArticle->oxarticles__oxwidth = new oxField('4', oxField::T_RAW);
         $oArticle->oxarticles__oxheight = new oxField('6', oxField::T_RAW);
         $oArticle->oxarticles__oxweight = new oxField('5', oxField::T_RAW);
         $oArticle->save();
         $this->aArticleIds[] = $oArticle->getId();
     }
     // some demo data
     $sQ = 'insert into oxobject2delivery (`OXID`, `OXDELIVERYID`, `OXOBJECTID`, `OXTYPE`) values ';
     $sQ .= '("_testId1", "' . $this->_sOxId . '", "_testArticleId1", "oxarticles" ), ';
     $sQ .= '("_testId2", "' . $this->_sOxId . '", "_testArticleId2", "oxarticles" ), ';
     $sQ .= '("_testId3", "' . $this->_sOxId . '", "_testArticleId3", "oxarticles" )';
     oxDb::getInstance()->getDb()->Execute($sQ);
     $sQ = 'insert into oxobject2delivery (`OXID`, `OXDELIVERYID`, `OXOBJECTID`, `OXTYPE`) values ';
     $sQ .= '("_testId4", "' . $this->_sOxId . '", "category_id1", "oxcategories" ), ';
     $sQ .= '("_testId5", "' . $this->_sOxId . '", "category_id2", "oxcategories" ), ';
     $sQ .= '("_testId6", "' . $this->_sOxId . '", "category_id3", "oxcategories" )';
     oxDb::getInstance()->getDb()->Execute($sQ);
     $this->aCategoryIds = array("category_id1", "category_id2", "category_id3");
     // preparing basket item
     $this->_oBasketItem = $this->getProxyClass("oxbasketitem");
     $this->_oBasketItem->init('_testArticleId1', 2);
     $oPrice = oxNew('oxprice');
     $oPrice->setPrice(256, 0);
     $this->_oBasketItem->setPrice($oPrice);
     oxArticleHelper::cleanup();
     oxDeliveryHelper::cleanup();
 }
Пример #6
0
 /**
  * Initialize the fixture.
  *
  * @return null
  */
 protected function setUp()
 {
     $this->_aBackup['_SERVER'] = $_SERVER;
     $this->_aBackup['_POST'] = $_POST;
     $this->_aBackup['_GET'] = $_GET;
     $this->_aBackup['_SESSION'] = $_SESSION;
     $this->_aBackup['_COOKIE'] = $_COOKIE;
     parent::setUp();
     error_reporting(E_ALL ^ E_NOTICE | E_STRICT);
     ini_set('display_errors', true);
     $this->getConfig();
     $this->getSession();
     $this->setAdminMode(false);
     $this->setShopId(null);
     oxAddClassModule('modOxUtilsDate', 'oxUtilsDate');
     oxRegistry::getUtils()->cleanStaticCache();
     error_reporting(E_ALL ^ E_NOTICE | E_STRICT);
     ini_set('display_errors', true);
 }
Пример #7
0
 /**
  * test if vouhers availability checking was skipped if skip param is on
  *
  * @return null
  */
 public function testAddVoucherSkipChecking()
 {
     oxAddClassModule('oxVoucherHelper', 'oxvoucher');
     oxVoucherHelper::$blCheckWasPerformed = false;
     $sVoucher = key($this->aVouchers);
     $oVoucher = $this->aVouchers[$sVoucher];
     $oPrice = oxNew("oxPrice");
     $oPrice->setPrice(999);
     $oPriceList = oxNew("oxPriceList");
     $oPriceList->addToPriceList($oPrice);
     $oBasket = $this->getProxyClass("oxBasket");
     $oBasket->setNonPublicVar('_oDiscountProductsPriceList', $oPriceList);
     $oBasket->setSkipVouchersChecking(true);
     $oBasket->addVoucher($sVoucher);
     $this->assertFalse(oxVoucherHelper::$blCheckWasPerformed);
 }
Пример #8
0
 /**
  * Testing Payment::ValidatePayment() when we use creditcard payment
  * and do not store CC data, using CC entered data from $_REQUEST, $_POST or $_GET
  *
  * @return null
  */
 public function testValidatePayment_NoStoreCardInfoRequest()
 {
     $oUser = oxNew('oxUser');
     $oUser->load('oxdefaultadmin');
     oxAddClassModule('modOxPayment_payment', 'oxPayment');
     $oBasket = $this->getMock('oxBasket', array('getPriceForPayment'));
     $oBasket->expects($this->any())->method('getPriceForPayment')->will($this->returnValue(100));
     $oBasket->setShipping('currentShipping');
     $oSession = $this->getMock('oxSession', array('getBasket'));
     $oSession->expects($this->any())->method('getBasket')->will($this->returnValue($oBasket));
     $oPayment = $this->getMock('Payment', array('getUser', 'getSession'));
     $oPayment->expects($this->any())->method('getUser')->will($this->returnValue($oUser));
     $oPayment->expects($this->any())->method('getSession')->will($this->returnValue($oSession));
     $this->setRequestParameter("paymentid", 'oxidcreditcard');
     $this->setConfigParam("blStoreCreditCardInfo", 0);
     $sTNumber = "4111111111111111";
     $sTName = "Hans Mustermann";
     $sTMonth = "01";
     $sTYear = "2013";
     $sTProof = "333";
     $sTTtype = "vis";
     $_REQUEST["dynvalue"]["kktype"] = $sTTtype;
     $_REQUEST["dynvalue"]["kknumber"] = $sTNumber;
     $_REQUEST["dynvalue"]["kkname"] = $sTName;
     $_REQUEST["dynvalue"]["kkmonth"] = $sTMonth;
     $_REQUEST["dynvalue"]["kkyear"] = $sTYear;
     $_REQUEST["dynvalue"]["kkpruef"] = $sTProof;
     $_POST["dynvalue"]["kktype"] = $sTTtype;
     $_POST["dynvalue"]["kknumber"] = $sTNumber;
     $_POST["dynvalue"]["kkname"] = $sTName;
     $_POST["dynvalue"]["kkmonth"] = $sTMonth;
     $_POST["dynvalue"]["kkyear"] = $sTYear;
     $_POST["dynvalue"]["kkpruef"] = $sTProof;
     $_GET["dynvalue"]["kktype"] = $sTTtype;
     $_GET["dynvalue"]["kknumber"] = $sTNumber;
     $_GET["dynvalue"]["kkname"] = $sTName;
     $_GET["dynvalue"]["kkmonth"] = $sTMonth;
     $_GET["dynvalue"]["kkyear"] = $sTYear;
     $_GET["dynvalue"]["kkpruef"] = $sTProof;
     $oPayment->init();
     $sRetVal = $oPayment->validatePayment();
     $this->assertEquals(null, $sRetVal);
 }
Пример #9
0
 /**
  * Test if method for validating payment uses basket price
  * getted from oxBasket::getPriceForPayment()
  *
  * @return null
  */
 public function testGetPayment_userBasketPriceForPayment()
 {
     $oUser = oxNew('oxuser');
     $oUser->load('oxdefaultadmin');
     $oBasket = $this->getMock('oxBasket', array('getPriceForPayment', 'getPaymentId'));
     $oBasket->expects($this->once())->method('getPriceForPayment')->will($this->returnValue(100));
     $oBasket->expects($this->once())->method('getPaymentId')->will($this->returnValue('oxidinvoice'));
     oxAddClassModule('modOxPaymentIsValid_order', 'oxPayment');
     $oOrder = $this->getMock('Order', array('getBasket'));
     $oOrder->expects($this->once())->method('getBasket')->will($this->returnValue($oBasket));
     $oOrder->getPayment();
     $this->assertEquals(100, modOxPaymentIsValid_order::$dBasketPrice);
 }
Пример #10
0
 /**
  * Initialize the fixture.
  */
 protected function setUp()
 {
     parent::setUp();
     // set to load full deliveries list
     $this->getConfig()->setConfigParam('bl_perfLoadDelivery', true);
     oxAddClassModule('Unit\\Application\\Model\\oxDeliveryListTestClass', 'oxDeliveryList');
     // inserting some demo data
     //set default user
     $this->_oUser = oxNew("oxUser");
     $this->_oUser->setId('_testUserId');
     $this->_oUser->oxuser__oxactive = new oxField('1', oxField::T_RAW);
     $this->_oUser->save();
     //add user address
     $oAdress = oxNew('oxBase');
     $oAdress->init('oxaddress');
     $oAdress->setId('_testAddressId');
     $oAdress->oxaddress__oxuserid = new oxField($this->_oUser->getId(), oxField::T_RAW);
     $oAdress->oxaddress__oxaddressuserid = new oxField($this->_oUser->getId(), oxField::T_RAW);
     $oAdress->oxaddress__oxcountryid = new oxField('a7c40f6323c4bfb36.59919433', oxField::T_RAW);
     //italien
     $oAdress->save();
     $this->getSession()->setVariable('deladrid', '_testAddressId');
     //add user to group
     $oO2Group = oxNew('oxBase');
     $oO2Group->init('oxobject2group');
     $oO2Group->setId('_testO2GId');
     $oO2Group->oxobject2group__oxobjectid = new oxField('_testUserId', oxField::T_RAW);
     $oO2Group->oxobject2group__oxgroupsid = new oxField('oxidadmin', oxField::T_RAW);
     $oO2Group->save();
     // delivery set
     $oDelSet = oxNew('oxDeliverySet');
     $oDelSet->setId('_testDeliverySetId');
     $oDelSet->oxdeliveryset__oxactive = new oxField(1, oxField::T_RAW);
     $oDelSet->save();
     $this->_aDeliverySets[] = $oDelSet;
     // 1. creating category for test
     $oCategory = oxNew('oxCategory');
     $oCategory->setId('_testCategoryId');
     $oCategory->oxcategories__oxtitle = new oxField('_testCategoryTitle', oxField::T_RAW);
     $oCategory->oxcategories__oxactive = new oxField(1, oxField::T_RAW);
     $oCategory->oxcategories__oxshopid = new oxField($this->getConfig()->getBaseShopId(), oxField::T_RAW);
     $oCategory->oxcategories__oxhidden = new oxField(0, oxField::T_RAW);
     $oCategory->oxcategories__oxdefsortmode = new oxField(0, oxField::T_RAW);
     $oCategory->oxcategories__oxparentid = new oxField('oxrootid', oxField::T_RAW);
     $oCategory->save();
     $this->_aCategories[] = $oCategory;
     //3. insert test articles
     for ($i = 1; $i <= 3; $i++) {
         $oArticle = oxNew("oxArticle");
         $oArticle->setId('_testArticleId' . $i);
         $oArticle->oxarticles__oxtitle = new oxField('testArticle' . $i, oxField::T_RAW);
         $oArticle->oxarticles__oxartnum = new oxField(1000 + $i, oxField::T_RAW);
         $oArticle->oxarticles__oxshortdesc = new oxField('testArticle' . $i . 'Description', oxField::T_RAW);
         $oArticle->oxarticles__oxprice = new oxField('256', oxField::T_RAW);
         $oArticle->oxarticles__oxstock = new oxField('9', oxField::T_RAW);
         $oArticle->oxarticles__oxshopid = new oxField(1, oxField::T_RAW);
         $oArticle->save();
         $this->_aTestProducts[] = $oArticle;
         // 2.1 assigning products to category
         $oO2Cat = oxNew('oxobject2category');
         $oO2Cat->setId('_testO2CatId' . $i);
         $oO2Cat->oxobject2category__oxobjectid = new oxField($oArticle->getId(), oxField::T_RAW);
         $oO2Cat->oxobject2category__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
         $oO2Cat->oxobject2category__oxcatnid = new oxField($oCategory->getId(), oxField::T_RAW);
         $oO2Cat->save();
     }
     // some deliveries
     for ($i = 1; $i <= 3; $i++) {
         $oDelivery = oxNew('oxDelivery');
         $oDelivery->setId('_testDeliveryId' . $i);
         $oDelivery->oxdelivery__oxtitle = new oxField('_testDelivertTitle' . $i, oxField::T_RAW);
         $oDelivery->oxdelivery__oxactive = new oxField(1, oxField::T_RAW);
         $oDelivery->oxdelivery__oxdeltype = new oxField('p', oxField::T_RAW);
         $oDelivery->oxdelivery__oxparam = new oxField(0, oxField::T_RAW);
         $oDelivery->oxdelivery__oxparamend = new oxField(999999, oxField::T_RAW);
         $oDelivery->oxdelivery__oxaddsum = new oxField(100, oxField::T_RAW);
         $oDelivery->oxdelivery__oxfixed = new oxField(0, oxField::T_RAW);
         $oDelivery->oxdelivery__oxsort = new oxField(3 - $i, oxField::T_RAW);
         $oDelivery->oxdelivery__oxfinalize = new oxField(0, oxField::T_RAW);
         //$oDelivery->blForCat = true;
         $oDelivery->save();
         $this->_aDeliveries[] = $oDelivery;
         $oDel2Delset = oxNew('oxBase');
         $oDel2Delset->init('oxdel2delset');
         $oDel2Delset->setId('_testDel2DelSetId' . $i);
         $oDel2Delset->oxdel2delset__oxdelid = new oxField($oDelivery->getId(), oxField::T_RAW);
         $oDel2Delset->oxdel2delset__oxdelsetid = new oxField($oDelSet->getId(), oxField::T_RAW);
         $oDel2Delset->save();
     }
     oxArticleHelper::cleanup();
 }
Пример #11
0
 public function testExecuteNewActionSslIsAdmin()
 {
     $this->getSession()->setId('SID');
     oxAddClassModule("oxUtilsHelper", "oxutils");
     $config = $this->getMock('oxconfig', array('isSsl', 'getSslShopUrl', 'getShopUrl'));
     $config->expects($this->once())->method('isSsl')->will($this->returnValue(true));
     $config->expects($this->once())->method('getSslShopUrl')->will($this->returnValue('SSLshopurl/'));
     $config->expects($this->never())->method('getShopUrl');
     $config->setConfigParam('sAdminDir', 'admin');
     $oView = $this->getMock('oxview', array('getConfig', 'isAdmin'));
     $oView->expects($this->once())->method('getConfig')->will($this->returnValue($config));
     $oView->expects($this->once())->method('isAdmin')->will($this->returnValue(true));
     $oView->UNITexecuteNewAction("details?fnc=somefnc&anid=someanid");
     $this->assertEquals('SSLshopurl/admin/index.php?cl=details&fnc=somefnc&anid=someanid&' . $this->getSession()->sid(), oxUtilsHelper::$sRedirectUrl);
 }
Пример #12
0
 public function testAssignParseLongDescInList()
 {
     oxAddClassModule('oxcategoryTest_oxUtilsView', 'oxUtilsView');
     $this->getConfig()->setConfigParam('bl_perfParseLongDescinSmarty', true);
     $this->_oCategory->oxcategories__oxlongdesc = new oxField('aa[{* smarty comment *}]zz', oxField::T_RAW);
     $this->_oCategory->setId('test33');
     $this->_oCategory->save();
     $oObj3 = oxNew("oxCategory");
     $oObj3->setInList();
     $oObj3->load($this->_oCategory->getId());
     //NOT parsed
     $this->assertEquals('aa[{* smarty comment *}]zz', $oObj3->oxcategories__oxlongdesc->value);
 }
Пример #13
0
 public function testGetArticleTestingIfGetterWorksFine()
 {
     oxAddClassModule('modOxArticle_oxUserBasketItem', 'oxArticle');
     $sProductId = "2000";
     $oBasketItem = oxNew('oxuserbasketitem');
     $oBasketItem->setVariantParentBuyable(true);
     $oBasketItem->oxuserbasketitems__oxartid = new oxField($sProductId, oxField::T_RAW);
     $oArticle = $oBasketItem->getArticle("123");
     $this->assertTrue($oArticle instanceof oxarticle);
     $this->assertEquals($oArticle->getItemKey(), "123");
     // if thi line one day will faile, probebly becaus these parameters are not public any more :)
     // removed due to #4178
     //$this->assertFalse( $oArticle->getClassVar('_blLoadVariants') );
 }
Пример #14
0
 /**
  * Testing if after user basket create oxcreate field contains date
  * of creation (M:1710)
  */
 public function testInsert_creationTime()
 {
     $iTime = 999991;
     oxAddClassModule('modOxUtilsDate', 'oxUtilsDate');
     oxRegistry::get("oxUtilsDate")->UNITSetTime($iTime);
     $oBasket = oxNew('oxUserBasket');
     $oBasket->setId("_testUserBasketId");
     $oBasket->save();
     $this->assertEquals($iTime, $oBasket->oxuserbaskets__oxupdate->value);
 }
Пример #15
0
 /**
  * Testing if method throws an exception if article is not visible (M:1286)
  *
  * @return null
  */
 public function testGetArticle_notVisibleArticle()
 {
     oxAddClassModule('modOxArticle_notVisible_oxbasketItem', 'oxArticle');
     $article = $this->createArticle();
     $oBasketItem = oxNew('oxBasketItem');
     try {
         $oBasketItem->getArticle(true, $article->getId());
     } catch (oxNoArticleException $oEx) {
         oxRemClassModule('modOxArticle_notVisible_oxbasketItem');
         return;
     }
     oxRemClassModule('modOxArticle_notVisible_oxbasketItem');
     $this->fail('Execption was not thrown when article is not visible');
 }
Пример #16
0
 /**
  * oxUser::login() and oxUser::logout() test for demo shop
  */
 public function testLogin_Logout_AdminDemoShop()
 {
     $oConfig = $this->getConfig();
     oxAddClassModule('Unit\\Application\\Model\\UserTest_oxUtilsServerHelper', 'oxutilsserver');
     $oConfig->setConfigParam('blDemoShop', 1);
     $oConfig->setAdminMode(true);
     $oUser = oxNew('oxUser');
     // demo shop login data: admin/admin here
     $oUser->login("admin", "admin");
     $this->assertNotNull($this->getSessionParam('auth'));
     // 'usr' var should not be set here in admin
     $this->assertNull($this->getSessionParam('usr'));
     $oUser = $oUser->getUser();
     $this->assertNotNull($oUser);
     $this->assertNotNull($oUser->getId());
     $oUser->logout();
     $this->assertNull($this->getSessionParam('usr'));
     $this->assertNull($this->getSessionParam('auth'));
     $this->assertFalse($oUser->getUser());
 }
 /**
  * Test adding SEO links to Manufacturer object
  */
 public function testSEOsetManufacturerData()
 {
     oxAddClassModule('modUtils_oxManufacturerlist', 'oxutils');
     $oManufacturerlist = $this->getProxyClass("oxManufacturerlist");
     $oManufacturerlist->loadManufacturerList();
     $oManufacturerlist->UNITSeosetManufacturerData();
     //check if SEO link was added for each Manufacturer item
     foreach ($oManufacturerlist as $sVndId => $value) {
         $sManufacturerLink = $oManufacturerlist[$sVndId]->link;
         if (!$sManufacturerLink || strstr($sManufacturerLink, 'index.php') !== false) {
             $this->fail("SEO link was not added to Manufacturer object ({$sManufacturerLink})");
         }
     }
 }
Пример #18
0
 /**
  * Initialize the fixture.
  */
 protected function setUp()
 {
     parent::setUp();
     oxAddClassModule('oxUtils_Extended', 'oxUtils');
     oxAddClassModule('oxOutput_Extended', 'oxOutput');
 }
Пример #19
0
 /**
  * Test case for oxInputValidator::checkEmail()
  * 2. checking is email validation is executed
  *
  * @return null
  */
 public function testCheckEmailEmailValidation()
 {
     oxAddClassModule('Unit_oxInputValidatorTest_oxutils', 'oxUtils');
     $oUser = oxNew('oxuser');
     $oUser->setId("testlalaa_");
     $oValidator = $this->getMock('oxinputvalidator', array('_addValidationError'));
     $oValidator->expects($this->once())->method('_addValidationError')->with($this->equalTo('oxuser__oxusername'), $this->logicalAnd($this->isInstanceOf('oxInputException'), $this->attributeEqualTo('message', oxRegistry::getLang()->translateString('ERROR_MESSAGE_INPUT_NOVALIDEMAIL'))));
     $oValidator->checkEmail($oUser, 'a@a.a', 1);
 }
Пример #20
0
 function testSetSessionIdForced()
 {
     oxAddClassModule('Unit_oxsessionTest_oxUtilsServer', 'oxUtilsServer');
     $this->getConfig()->setConfigParam('blForceSessionStart', 1);
     $oSession = $this->getMock('testSession', array("_getNewSessionId"));
     $oSession->expects($this->any())->method('_getNewSessionId')->will($this->returnValue("newSessionId"));
     $this->assertFalse($oSession->isNewSession());
     $oSession->start();
     $this->assertEquals($oSession->getName(), 'sid');
     $oSession->UNITsetSessionId('testSid');
     $this->assertEquals($oSession->getId(), 'testSid');
     $this->assertTrue($oSession->isNewSession());
     $this->assertEquals(oxRegistry::get("oxUtilsServer")->getOxCookie($oSession->getName()), 'testSid');
     //reset session
     $oSession->InitNewSession();
     $this->assertNotEquals('testSid', $oSession->getId());
 }
Пример #21
0
 /**
  * Test add artiicle with wrong ammount.
  *
  * @return null
  */
 public function testAddThisArticleWrongAmount()
 {
     oxAddClassModule('modOxOrder_orderArticle', 'oxorder');
     $this->setRequestParameter('sArtNum', '2000');
     $this->setRequestParameter('am', 'test');
     $this->setRequestParameter('oxid', '_testOrderId1');
     $oOrderArticle = oxNew('order_article');
     $oOrderArticle->addThisArticle();
     $oOrder = oxNew("oxOrder");
     $oOrder->load('_testOrderId1');
     $this->assertEquals(0, $oOrder->oxorder__oxtotalbrutsum->value);
 }
Пример #22
0
 /**
  * Test if method for validating payment uses basket price
  * getted from oxBasket::getPriceForPayment()
  *
  * @return null
  */
 public function testGetPayment_userBasketPriceForPayment()
 {
     $oUser = oxNew('oxUser');
     $oUser->load('oxdefaultadmin');
     $oBasket = $this->getMock('oxBasket', array('getPriceForPayment', 'getPaymentId'));
     $oBasket->expects($this->once())->method('getPriceForPayment')->will($this->returnValue(100));
     $oBasket->expects($this->once())->method('getPaymentId')->will($this->returnValue('oxidinvoice'));
     PaymentHelper::$dBasketPrice = null;
     oxAddClassModule('Unit\\Application\\Controller\\PaymentHelper', 'oxPayment');
     $oOrder = $this->getMock('Order', array('getBasket'));
     $oOrder->expects($this->once())->method('getBasket')->will($this->returnValue($oBasket));
     $oOrder->getPayment();
     $this->assertEquals(100, PaymentHelper::$dBasketPrice);
 }
Пример #23
0
 /**
  * Test list post processing, adding content categories to tree with content categories.
  *
  * @return null
  */
 public function test_ppAddContentCategories_sim()
 {
     $this->_oList->setVar('sShopID', null);
     $this->_oList->setVar('sActCat', $this->_sActCat);
     $this->_oList->setVar('blHideEmpty', false);
     $this->_oList->setVar('blForceFull', false);
     $this->_oList->setVar('iForceLevel', 0);
     $moduleName = $this->getTestConfig()->getShopEdition() === 'EE' ? 'modContentListEE_oxcategorylist' : 'modContentListCE_oxcategorylist';
     oxAddClassModule($moduleName, 'oxcontentlist');
     $this->_oList->load();
     $this->_oList->UNITppAddContentCategories();
     $aContent = $this->_oList[$this->_sActCat]->getContentCats();
     $this->assertEquals(2, count($aContent));
 }
Пример #24
0
 public function testSendMailAndFail()
 {
     oxAddClassModule('modEmailOxNewsLetter', 'oxEmail');
     $oTestNews = oxNew("oxNewsLetter");
     if (!$oTestNews->load('oxidnewsletter')) {
         $this->fail('can not load news');
     }
     $oTestNews->UNITsetUser('oxdefaultadmin');
     $blMailWasSent = $oTestNews->send();
     $this->assertFalse($blMailWasSent);
 }
Пример #25
0
 public function testSendOrderByEmailWhenMailingFails()
 {
     oxEmailHelper::$blRetValue = false;
     oxAddClassModule('oxEmailHelper', 'oxemail');
     $oOrder = $this->getProxyClass("oxOrder");
     $iRes = $oOrder->UNITsendOrderByEmail(null, null, null);
     $this->assertEquals(0, $iRes);
 }
Пример #26
0
 /**
  * Test adding SEO links to vendor object
  */
 public function test_SEOsetVendorData()
 {
     oxUtilsHelper::$sSeoIsActive = true;
     oxAddClassModule('oxUtilsHelper', 'oxutils');
     $oVendorlist = $this->getProxyClass("oxvendorlist");
     $oVendorlist->loadVendorList();
     $oVendorlist->UNITSeosetVendorData();
     //check if SEO link was added for each vendor item
     foreach ($oVendorlist as $sVndId => $value) {
         $sVendorLink = $oVendorlist[$sVndId]->getLink();
         if (!$sVendorLink || strstr($sVendorLink, 'index.php') !== false) {
             $this->fail("SEO link was not added to vendor object ({$sVendorLink})");
         }
     }
 }
Пример #27
0
 /**
  * Test if method for getting payments list uses basket price without payment costs
  */
 public function testGetDeliverySetData_usesBasketPriceWithoutPayment()
 {
     $iActShop = $this->getConfig()->getBaseShopId();
     // Deliverycost 1
     $oDel1 = oxNew('oxDelivery');
     $oDel1->setId('_testdelivery1');
     $oDel1->oxdelivery__oxactive = new oxField(1, oxField::T_RAW);
     $oDel1->oxdelivery__oxshopid = new oxField($iActShop, oxField::T_RAW);
     $oDel1->save();
     // Deliveryset 1
     $oDelSet1 = oxNew('oxDeliverySet');
     $oDelSet1->setId('_testdeliveryset1');
     $oDelSet1->oxdeliveryset__oxactive = new oxField(1, oxField::T_RAW);
     $oDelSet1->oxdeliveryset__oxshopid = new oxField($iActShop, oxField::T_RAW);
     $oDelSet1->save();
     // Article 1 => Deliverycost 1
     $oO2D1 = oxNew('oxbase');
     $oO2D1->init('oxobject2delivery');
     $oO2D1->setId('_testoxobject2delivery1');
     $oO2D1->oxobject2delivery__oxdeliveryid = new oxField($oDel1->getId(), oxField::T_RAW);
     $oO2D1->oxobject2delivery__oxobjectid = new oxField('1126', oxField::T_RAW);
     $oO2D1->oxobject2delivery__oxtype = new oxField('oxarticles', oxField::T_RAW);
     $oO2D1->save();
     // Deliverycost 1 => Deliveryset 1
     $oD2DelSet1 = oxNew('oxbase');
     $oD2DelSet1->init('oxdel2delset');
     $oD2DelSet1->setId('_testoxdel2delset1');
     $oD2DelSet1->oxdel2delset__oxdelid = new oxField($oDel1->getId(), oxField::T_RAW);
     $oD2DelSet1->oxdel2delset__oxdelsetid = new oxField($oDelSet1->getId(), oxField::T_RAW);
     $oD2DelSet1->save();
     // payment => Deliveryset 1
     $oP2DelSet1 = oxNew('oxbase');
     $oP2DelSet1->init('oxobject2payment');
     $oP2DelSet1->oxobject2payment__oxpaymentid = new oxField('oxidcashondel', oxField::T_RAW);
     $oP2DelSet1->oxobject2payment__oxobjectid = new oxField($oDelSet1->getId(), oxField::T_RAW);
     $oP2DelSet1->oxobject2payment__oxtype = new oxField("oxdelset", oxField::T_RAW);
     $oP2DelSet1->save();
     $oUser = oxNew('oxuser');
     $oUser->load('oxdefaultadmin');
     $this->setRequestParameter('deladrid', null);
     $oBasket = $this->getMock('oxBasket', array('getPriceForPayment'));
     $oBasket->expects($this->once())->method('getPriceForPayment')->will($this->returnValue(100));
     oxAddClassModule('Unit\\Application\\Model\\modOxDeliverySetList_paymentList', 'oxPaymentList');
     $oDeliverySetList = oxNew('oxDeliverySetList');
     $oDeliverySetList->getDeliverySetData(null, $oUser, $oBasket);
     $this->assertEquals(100, modOxDeliverySetList_paymentList::$dBasketPrice);
 }
Пример #28
0
 /**
  * addFunction adds module and creates function in it
  *
  * @param mixed $class target class
  * @param mixed $fncName target function
  * @param mixed $func function - if it is '{...}' then it is function code ($aA is arguments array), else it is taken as param to call_user_func_array
  *
  * @static
  * @access public
  * @return string
  */
 public static function addFunction($class, $fncName, $func)
 {
     $class = strtolower($class);
     $name = self::_getNextName($class);
     if ($cnt = count(self::$_addedmods[$class])) {
         $last = self::$_addedmods[$class][$cnt - 1];
     } else {
         $last = $class;
     }
     $sCode = '';
     if (preg_match('/^{.*}$/ms', $func)) {
         $sCode = "\$aA = func_get_args(); " . trim($func, '{}');
     } else {
         if (preg_match('/^[a-z0-9_-]*$/i', trim($func))) {
             $func = "'{$func}'";
         }
         $sCode = " \$arg = func_get_args(); return call_user_func_array({$func}, \$arg);";
     }
     $iErrorReportinc = error_reporting(E_ALL ^ E_NOTICE);
     $aFncParams = array();
     if (strpos($fncName, '(') !== false) {
         $aMatches = null;
         preg_match("@(.*?)\\((.*?)\\)@", $fncName, $aMatches);
         $fncName = trim($aMatches[1]);
         if (trim($aMatches[2])) {
             $aFncParams = explode(',', $aMatches[2]);
         } else {
             $aFncParams = array();
         }
     }
     if (method_exists($last, $fncName)) {
         $oReflection = new ReflectionClass($last);
         $aMethodParams = $oReflection->getMethod($fncName)->getParameters();
         $fncName .= '(';
         $blFirst = true;
         foreach ($aMethodParams as $iKey => $oParam) {
             if (!$blFirst) {
                 $fncName .= ', ';
             } else {
                 $blFirst = false;
             }
             if (isset($aFncParams[$iKey])) {
                 $fncName .= $aFncParams[$iKey];
                 if (strpos($aFncParams[$iKey], '=') === false && $oParam->isDefaultValueAvailable()) {
                     $fncName .= ' = ' . var_export($oParam->getDefaultValue(), true);
                 }
                 continue;
             }
             if ($oParam->getClass()) {
                 $fncName .= $oParam->getClass()->getName() . ' ';
             }
             $fncName .= '$' . $oParam->getName();
             if ($oParam->isDefaultValueAvailable()) {
                 $fncName .= ' = ' . var_export($oParam->getDefaultValue(), true);
             }
         }
         $fncName .= ')';
     } else {
         if (empty($aFncParams)) {
             $fncName .= '($p1=null, $p2=null, $p3=null, $p4=null, $p5=null, $p6=null, $p7=null, $p8=null, $p9=null, $p10=null)';
         } else {
             $fncName .= '(' . implode(', ', $aFncParams) . ')';
         }
     }
     eval("class {$name} extends {$last} { function {$fncName} { {$sCode} }}");
     oxAddClassModule($name, $class);
     error_reporting($iErrorReportinc);
     self::$_addedmods[$class][] = $name;
     return $name;
 }
Пример #29
0
 public function testMarkAsUsedExistingMarking()
 {
     oxAddClassModule('modOxUtilsDate', 'oxUtilsDate');
     oxRegistry::get("oxUtilsDate")->UNITSetTime(0);
     $sVoucherSerie = current($this->_aSerieOxid);
     $oSerie = oxNew('oxvoucherserie');
     $oSerie->load($sVoucherSerie);
     $sVoucher = current($this->_aVoucherOxid[$sVoucherSerie]);
     $oVoucher = oxNew('oxvoucher');
     $oVoucher->load($sVoucher);
     $oVoucher->markAsUsed('xxx', 'yyy', $oSerie->oxvoucherseries__oxdiscount->value);
     $this->assertEquals('xxx', $oVoucher->oxvouchers__oxorderid->value);
     $this->assertEquals('yyy', $oVoucher->oxvouchers__oxuserid->value);
     $this->assertEquals('1970-01-01', $oVoucher->oxvouchers__oxdateused->value);
     $this->assertEquals($oSerie->oxvoucherseries__oxdiscount->value, $oVoucher->oxvouchers__oxdiscount->value);
 }
Пример #30
0
 /**
  * Test list post processing, adding content categories to tree with content categories.
  */
 public function test_ppAddContentCategories_sim()
 {
     $this->_oList->setVar('sShopID', null);
     $this->_oList->setVar('sActCat', $this->_sActCat);
     $this->_oList->setVar('blHideEmpty', false);
     $this->_oList->setVar('blForceFull', false);
     $this->_oList->setVar('iForceLevel', 0);
     $moduleName = $this->getTestConfig()->getShopEdition() === 'EE' ? 'Unit\\Application\\Model\\oxCategoryListHelperLoadCategoryMenusEE' : 'Unit\\Application\\Model\\oxCategoryListHelperLoadCategoryMenusPE';
     oxAddClassModule($moduleName, 'oxcontentlist');
     $this->_oList->load();
     $this->_oList->UNITppAddContentCategories();
     $aContent = $this->_oList[$this->_sActCat]->getContentCats();
     $this->assertEquals(2, count($aContent));
 }