/**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool shippingPriceInclTax
  * @param array $expectedValue
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $itemMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterface');
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $this->address->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $this->address->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($baseShippingAmount);
         } else {
             $this->address->expects($this->never())->method('getBaseShippingDiscountAmount');
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($shippingAmount);
         }
     }
     foreach ($addressData as $key => $value) {
         $this->address->setData($key, $value);
     }
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setType')->willReturnSelf();
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setValue')->with($shippingTaxClass)->willReturnSelf();
     $this->quoteDetailsItemBuilderMock->expects($this->once())->method('create')->willReturn($itemMock);
     $this->assertEquals($itemMock, $this->commonTaxCollector->getShippingDataObject($this->address, $useBaseCurrency));
 }
Ejemplo n.º 2
0
 public function testParse()
 {
     $expectedResult = [['phrase' => 'phrase1', 'file' => 'file1', 'line' => 15, 'quote' => '']];
     $this->_phraseCollectorMock->expects($this->once())->method('parse')->with('file1');
     $this->_phraseCollectorMock->expects($this->once())->method('getPhrases')->will($this->returnValue([['phrase' => 'phrase1', 'file' => 'file1', 'line' => 15]]));
     $this->_adapter->parse('file1');
     $this->assertEquals($expectedResult, $this->_adapter->getPhrases());
 }
 /**
  * @param array $options
  * @param ItemStub $actualContext
  * @param ItemStub $expectedContext
  * @param array $expectedData
  * @dataProvider optionsDataProvider
  */
 public function testExecute(array $options, ItemStub $actualContext, ItemStub $expectedContext, array $expectedData = array())
 {
     $expectedWorkflowName = $expectedContext->workflowName;
     $expectedEntity = !empty($options['entity']) ? $expectedContext->entityValue : null;
     $expectedTransition = !empty($options['transition']) ? $expectedContext->startTransition : null;
     $expectedWorkflowItem = $expectedContext->workflowItem;
     $this->workflowManager->expects($this->once())->method('startWorkflow')->with($expectedWorkflowName, $expectedEntity, $expectedTransition, $expectedData)->will($this->returnValue($expectedWorkflowItem));
     $this->action->initialize($options);
     $this->action->execute($actualContext);
     $this->assertEquals($expectedContext->getData(), $actualContext->getData());
 }
Ejemplo n.º 4
0
 /**
  * Set up
  */
 protected function setUp()
 {
     $this->resultPage = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Page', ['setActiveMenu', 'getConfig', 'getTitle', 'prepend', 'addBreadcrumb'], [], '', false);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getTitle')->willReturnSelf();
     $this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getResultFactory'], [], '', false);
     $this->context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->indexController = $this->objectManagerHelper->getObject('Magento\\ImportExport\\Controller\\Adminhtml\\History\\Index', ['context' => $this->context]);
 }
Ejemplo n.º 5
0
 public function should_parse_variable_contains_operators()
 {
     expects($this->parse('org'))->should_be(array(':org'));
     expects($this->parse('dand'))->should_be(array(':dand'));
     expects($this->parse('xor'))->should_be(array(':xor'));
     expects($this->parse('notd'))->should_be(array(':notd'));
 }
Ejemplo n.º 6
0
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $paymentTokenMock = $this->getMock(PaymentTokenInterface::class);
     $extensionAttributes = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderPaymentExtensionInterface')->disableOriginalConstructor()->setMethods(['setVaultPaymentToken'])->getMock();
     $ccDetails = ['cc_type' => 'VI', 'cc_number' => '1111'];
     $this->responseMock->setData('result_code', Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->setData('origresult', 0);
     $this->responseMock->setData('pnref', 'test-pnref');
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->paymentMock->expects($this->once())->method('getCcExpYear')->willReturn('2017');
     $this->paymentMock->expects($this->once())->method('getCcExpMonth')->willReturn('12');
     $this->paymentMock->expects(static::any())->method('getAdditionalInformation')->willReturnMap([[Transparent::CC_DETAILS, $ccDetails], [Transparent::PNREF, 'test-pnref']]);
     $this->paymentTokenFactory->expects(static::once())->method('create')->willReturn($paymentTokenMock);
     $paymentTokenMock->expects(static::once())->method('setGatewayToken')->with('test-pnref');
     $paymentTokenMock->expects(static::once())->method('setTokenDetails')->with(json_encode($ccDetails));
     $paymentTokenMock->expects(static::once())->method('setExpiresAt')->with('2018-01-01 00:00:00');
     $this->paymentMock->expects(static::once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
     $extensionAttributes->expects(static::once())->method('setVaultPaymentToken')->with($paymentTokenMock);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
Ejemplo n.º 7
0
 function should_parse_variable_contains_operators()
 {
     expects($this->parse("org"))->should_be(array(':org', 'expression_end'));
     expects($this->parse("dand"))->should_be(array(':dand', 'expression_end'));
     expects($this->parse("xor"))->should_be(array(':xor', 'expression_end'));
     expects($this->parse("notd"))->should_be(array(':notd', 'expression_end'));
 }
 /**
  * @test should accept only REQ sockets
  */
 public function testShouldAcceptOnlyREQSockets()
 {
     $this->socket = $this->getMockBuilder('\\ZMQSocket')->disableOriginalConstructor()->getMock();
     $this->socket->expects($this->any())->method('getSocketType')->will($this->returnValue(\ZMQ::SOCKET_PUSH));
     $this->setExpectedException('\\InvalidArgumentException', 'Invalid socket type');
     new ZeroMQClientTransport($this->socket);
 }
 protected function setUp()
 {
     parent::setUp();
     \Locale::setDefault('en');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $this->requestStack = new RequestStack();
     /* @var Request $request */
     $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->requestStack->push($request);
     $this->router->expects($this->any())->method('generate')->will($this->returnCallback(function ($param) {
         return '/' . $param;
     }));
     $this->factory = Forms::createFormFactoryBuilder()->addExtensions($this->getExtensions())->addTypeExtension(new ChoiceSelect2TypeExtension($this->dispatcher, $this->requestStack, $this->router, $this->getExtensionTypeName(), 10))->getFormFactory();
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
 }
Ejemplo n.º 10
0
 public function should_be_able_to_include_in_nested_fashion()
 {
     $h2o = new H2o('page.html', $this->option);
     $result = $h2o->render();
     expects($result)->should_match('/layout text/');
     expects($result)->should_match('/Page footer/');
     expects($result)->should_match('/page menu/');
 }
Ejemplo n.º 11
0
 public function testExecute()
 {
     $context = new StubStorage(array('array' => array('key_1' => 'value_1', 'key_2' => 'value_2'), 'key' => null, 'value' => null, 'new_array' => array()));
     $options = array(Traverse::OPTION_KEY_ARRAY => new PropertyPath('array'), Traverse::OPTION_KEY_KEY => new PropertyPath('key'), Traverse::OPTION_KEY_VALUE => new PropertyPath('value'), Traverse::OPTION_KEY_ACTIONS => array('actions', 'configuration'));
     $this->configurableAction->expects($this->once())->method('initialize')->with($options[Traverse::OPTION_KEY_ACTIONS]);
     $this->configurableAction->expects($this->any())->method('execute')->with($context)->will($this->returnCallback(function (StubStorage $context) {
         $key = $context['key'];
         $value = $context['value'];
         $newArray = $context['new_array'];
         $newArray[$key] = $value;
         $context['new_array'] = $newArray;
     }));
     $this->action->initialize($options);
     $this->action->execute($context);
     $this->assertNull($context['key']);
     $this->assertNull($context['value']);
     $this->assertEquals($context['array'], $context['new_array']);
 }
 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->address = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->getMock();
     $this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $methods = ['create'];
     $this->quoteDetailsItemDataObject = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Quote\\ItemDetails');
     $this->taxClassKeyDataObject = $objectManager->getObject('Magento\\Tax\\Model\\TaxClass\\Key');
     $this->quoteDetailsItemDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterfaceFactory', $methods, [], '', false);
     $this->quoteDetailsItemDataObjectFactoryMock->expects($this->any())->method('create')->willReturn($this->quoteDetailsItemDataObject);
     $this->taxClassKeyDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\TaxClassKeyInterfaceFactory', $methods, [], '', false);
     $this->taxClassKeyDataObjectFactoryMock->expects($this->any())->method('create')->willReturn($this->taxClassKeyDataObject);
     $this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig, 'quoteDetailsItemDataObjectFactory' => $this->quoteDetailsItemDataObjectFactoryMock, 'taxClassKeyDataObjectFactory' => $this->taxClassKeyDataObjectFactoryMock]);
 }
Ejemplo n.º 13
0
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $this->responseMock->expects($this->any())->method('getResultCode')->willReturn(Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->expects($this->any())->method('getOrigresult')->willReturn(0);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->responseMock->expects($this->once())->method('getPnref')->willReturn('test-pnref');
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
 public function testGetSearchCriteriaAnd()
 {
     // Test ((A > 1) and (B > 1))
     $fieldA = 'A';
     $fieldB = 'B';
     $value = 1;
     $sortOrder = $this->sortOrderBuilder->setField('name')->setDirection(SortOrder::SORT_ASC)->create();
     /** @var SearchCriteria $expectedSearchCriteria */
     $expectedSearchCriteria = $this->searchCriteriaBuilder->setCurrentPage(1)->setPageSize(0)->addSortOrder($sortOrder)->addFilters([$this->filterBuilder->setField($fieldA)->setConditionType('gt')->setValue($value)->create()])->addFilters([$this->filterBuilder->setField($fieldB)->setConditionType('gt')->setValue($value)->create()])->create();
     // Verifies that the search criteria Data Object created by the serviceCollection matches expected
     $this->groupRepositoryMock->expects($this->once())->method('getList')->with($this->equalTo($expectedSearchCriteria))->will($this->returnValue($this->searchResults));
     // Now call service collection to load the data.  This causes it to create the search criteria Data Object
     $this->serviceCollection->addFieldToFilter($fieldA, ['gt' => $value]);
     $this->serviceCollection->addFieldToFilter($fieldB, ['gt' => $value]);
     $this->serviceCollection->setOrder('name', ServiceCollection::SORT_ORDER_ASC);
     $this->serviceCollection->loadData();
 }
Ejemplo n.º 15
0
 /**
  * Set up
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setUp()
 {
     parent::setUp();
     //connection and sql query results
     $this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->connectionMock->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->connectionMock->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('delete')->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('quoteInto')->willReturn('');
     //constructor arguments:
     // 1. $attrSetColFac
     $this->attrSetColFacMock = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->attrSetColMock = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColMock->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     // 2. $prodAttrColFac
     $this->prodAttrColFacMock = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFacMock->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     // 3. $resource
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->connectionMock));
     $this->resourceMock->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     // 4. $params
     $this->entityModelMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', ['addMessageTemplate', 'getEntityTypeId', 'getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getParameters', 'addRowError'], [], '', false);
     $this->entityModelMock->expects($this->any())->method('addMessageTemplate')->will($this->returnSelf());
     $this->entityModelMock->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(5));
     $this->entityModelMock->expects($this->any())->method('getParameters')->will($this->returnValue([]));
     $this->paramsArray = [$this->entityModelMock, 'downloadable'];
     $this->uploaderMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Uploader', ['move'], [], '', false);
     // 6. $filesystem
     $this->directoryWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     // 7. $fileHelper
     $this->uploaderHelper = $this->getMock('\\Magento\\DownloadableImportExport\\Helper\\Uploader', ['getUploader'], [], '', false);
     $this->uploaderHelper->expects($this->any())->method('getUploader')->willReturn($this->uploaderMock);
     $this->downloadableHelper = $this->getMock('\\Magento\\DownloadableImportExport\\Helper\\Data', ['prepareDataForSave'], [], '', false);
     $this->downloadableHelper->expects($this->any())->method('prepareDataForSave')->willReturn([]);
 }
Ejemplo n.º 16
0
 function should_correctly_parse_expressions()
 {
     $pi = 3;
     $result = h2o('{{ (pi+1)/2+10 }}')->render(compact('pi'));
     expects($result)->should_be('12');
     $except = false;
     try {
         $res = h2o('{{ ()pi+1)/2+10 }}')->render(compact('pi'));
     } catch (Exception $e) {
         $except = true;
     }
     expects($except)->should_be(true);
     $except = false;
     try {
         $res = h2o('{{ +1 }}')->render(compact('pi'));
     } catch (Exception $e) {
         $except = true;
     }
     expects($except)->should_be(true);
 }
Ejemplo n.º 17
0
 function should_provide_variable_loop_in_for_block()
 {
     $context = array('items' => array(1, 2, 3, 4, 5));
     $rs = h2o('{% for e in items %}{{ loop.counter }}{%endfor%}')->render($context);
     expects($rs)->should_be('12345');
     $rs = h2o('{% for e in items %}{{ loop.counter0 }}{%endfor%}')->render($context);
     expects($rs)->should_be('01234');
     $rs = h2o('{% for e in items %}{{ loop.revcounter }}{%endfor%}')->render($context);
     expects($rs)->should_be('54321');
     $rs = h2o('{% for e in items %}{{ loop.revcounter0 }}{%endfor%}')->render($context);
     expects($rs)->should_be('43210');
     $rs = h2o('{% for e in items %}{% if loop.first %}first{% else %}{{ e }}{% endif %}{%endfor%}')->render($context);
     expects($rs)->should_be('first2345');
     $rs = h2o('{% for e in items %}{% if loop.last %}last{% else %}{{ e }}{% endif %}{%endfor%}')->render($context);
     expects($rs)->should_be('1234last');
     $rs = h2o('{% for e in items %}{% if loop.even%}even{% else %}{{ e }}{% endif %}{%endfor%}')->render($context);
     expects($rs)->should_be('1even3even5');
     $rs = h2o('{% for e in items %}{% if loop.odd%}odd{% else %}{{ e }}{% endif %}{%endfor%}')->render($context);
     expects($rs)->should_be('odd2odd4odd');
 }
Ejemplo n.º 18
0
<?php

require_once "lib/init.php";
$report = Report::get();
expects(array("section" => "int?"));
class ReportPDF extends TCPDF
{
    public function _setup()
    {
        $this->setPrintHeader(false);
        $this->setPrintFooter(true);
        $this->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $this->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        $this->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        $this->SetMargins(PDF_MARGIN_LEFT, 0, PDF_MARGIN_RIGHT);
        $this->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        $this->setImageScale(1.4);
        $this->setFontSubsetting(true);
        $this->SetFont('helvetica', '', 14, '', true);
    }
    public function Footer()
    {
        global $report;
        // Position at 15 mm from bottom
        $this->SetY(-15);
        $content3 = $report->find_contents(3);
        if ($content3 !== NULL) {
            $client_ref = $content3->data['client_ref'];
        }
        // Page number
        $this->writeHTMLCell(0, 0, '', '', "\n\t\t\t<hr /><br /><table width=100% style='font-size:16pt'><tr><td align=left>REPORT REFERENCE: " . htmlspecialchars($client_ref) . "</td><td width='50%' align='right'><p align=right>PAGE " . $this->getAliasNumPage() . " OF " . $this->getAliasNbPages() . "</p></td></tr></table>\n\t\t", 0, 1, 0, true, '', true);
Ejemplo n.º 19
0
 function should_apply_filter_if_available()
 {
     $name = 'taylor luk';
     $result = h2o('{{ name|capitalize }}')->render(compact('name'));
     expects($result)->should_be('Taylor Luk');
 }
Ejemplo n.º 20
0
<?php

if (!isset($_SESSION['pass']) || $_SESSION['pass'] !== $config['login']['pass']) {
    expects(array("user" => "string?", "pass" => "string?"));
    if ($params["user"] !== NULL || $params["pass"] !== NULL) {
        if ($params["user"] === $config["login"]["user"] && $params["pass"] === $config["login"]["pass"]) {
            $_SESSION["pass"] = $config["login"]["pass"];
            redirect($_SERVER['REQUEST_URI']);
        } else {
            view("login", array("error" => true), false);
        }
    } else {
        view("login", array(), false);
    }
}
Ejemplo n.º 21
0
 public function should_resolve_overloaded_attributes()
 {
     $c = create_context(array('person' => $p = new Person()));
     expects($c->resolve(':person.name'))->should_be('The king');
     expects($c->resolve(':person.age'))->should_be(19);
 }
Ejemplo n.º 22
0
 function should_read_sub_template_in_include_tag()
 {
     $this->h2o->loadTemplate('index.html');
     expects($this->h2o->render())->should_match('/page menu/');
 }
Ejemplo n.º 23
0
        }
    }
} elseif (in_array($params['section'], ReportContents::$data_crud)) {
    expects(array("date" => "string?"));
    if (isset($params['date'])) {
        $date = date_parse($params['date']);
        $report->created_at = mktime($date['hour'], $date['minute'], $date['second'], $date['month'], $date['day'], $date['year']);
        $report->save();
    }
    $data = $report->find_contents($params['section']);
    if ($data === NULL) {
        $data = ReportContents::create(array("report_id" => $report->id, "type" => $params['section'], "data" => array()));
    }
    $viewdata['data'] = $data->data;
    if ($params['prev'] || $params['next'] || $params['quit'] || $params['goto']) {
        expects(array("data" => "array", "other_data" => "array?"));
        foreach ($params['data'] as $k => $v) {
            $data->data[$k] = $v;
        }
        foreach ($_FILES as $k => $v) {
            $f = File::upload($k);
            if ($f !== NULL) {
                $data->data[$k] = $f->id;
            }
        }
        $data->save();
        if (is_array($params['other_data'])) {
            foreach ($params['other_data'] as $cid => $d) {
                if ($cid == 1) {
                    foreach ($d as $k => $v) {
                        $report->{$k} = $v;
Ejemplo n.º 24
0
 public function should_return_nested_items()
 {
     $context = array('granfather' => array('father' => array('child' => 'mike')));
     $rs = h2o('{% with granfather.father.child as child %}{{ child }}{% endwith %}')->render($context);
     expects($rs)->should_be('mike');
 }
Ejemplo n.º 25
0
 public function setUp()
 {
     $this->mockBuildStore = $this->getMock('PHPCI\\Store\\BuildStore');
     $this->mockBuildStore->expects($this->any())->method('save')->will($this->returnArgument(0));
     $this->testedService = new BuildService($this->mockBuildStore);
 }
Ejemplo n.º 26
0
 public function should_be_able_to_output_parent_template_using_blog_super()
 {
     $h2o = new h2o('home', $this->option);
     expects($h2o->render())->should_be('depth: 2- parent content, depth: 1- child content');
 }
Ejemplo n.º 27
0
 public function should_be_able_to_register_a_filter_collection()
 {
     h2o::addFilter('SampleFilters');
     $result = h2o('{{ person | hello }}')->render(array('person' => 'peter'));
     expects($result)->should_be('says hello to peter');
 }
Ejemplo n.º 28
0
 public static function get($param = NULL)
 {
     global $params;
     if ($param == NULL) {
         $param = self::table_name() . "_id";
     }
     expects(array($param => "int"));
     return self::find($params[$param]);
 }
<?php

require_once "lib/init.php";
ensure("post");
expects(array("name" => "string", "description" => "string", "price" => "int"));
json(RecommendedItem::create($params));
Ejemplo n.º 30
0
<?php

require_once "lib/init.php";
expects(array("page" => "int?", "goto" => "int?"));
if (!$params["page"]) {
    if ($params["goto"]) {
        redirect("settings.php", array("page" => $params["goto"]));
    } else {
        view("settings");
    }
} elseif (isset(Report::$contents_ids[$params["page"]])) {
    expects(array("data" => "array?"));
    $def = _Default::find_by_section($params["page"]);
    if ($def === NULL) {
        $def = _Default::create(array("section" => $params["page"], "data" => array()));
    }
    $data = $def->data !== NULL ? $def->data : array();
    if (is_array($params["data"])) {
        foreach ($params["data"] as $k => $v) {
            $def->data[$k] = $v;
        }
        $data = $def->data;
        $def->save();
    }
    if ($params["goto"]) {
        redirect("settings.php", array("page" => $params["goto"]));
    } else {
        view("settings", array("page" => $params["page"], "data" => $data));
    }
} else {
    redirect("settings.php");