/** * Test for \Henhed\Piwik\Observer\CheckoutSuccessObserver::execute where * tracking is disabled. * * @return void */ public function testExecuteWithTrackingDisabled() { $this->_dataHelperMock->expects($this->once())->method('isTrackingEnabled')->willReturn(false); $this->_eventMock->expects($this->any())->method('getOrderIds')->willReturn([1]); $this->_orderCollectionMock->expects($this->never())->method('getIterator'); $this->assertSame($this->_testSubject, $this->_testSubject->execute($this->_eventObserverMock)); $this->assertEquals([], $this->_tracker->toArray()); }
/** * Test for \Henhed\Piwik\Helper\Tracker::addQuote * * Also covers `addQuoteItem' and `addQuoteTotal' * * @param array $items * @param float $total * @dataProvider addQuoteDataProvider */ public function testAddQuote($items, $total) { // Build expected tracker result from $items and $total $expectedResult = []; foreach ($items as $item) { list($sku, $name, $price, $qty) = $item; $expectedResult[] = ['addEcommerceItem', $sku, $name, false, (double) $price, (double) $qty]; } $expectedResult[] = ['trackEcommerceCartUpdate', (double) $total]; // Test `addQuote' with mock quote created from $items and $total $this->_helper->addQuote($this->_getQuoteMock($items, $total), $this->_tracker); $this->assertSame($expectedResult, $this->_tracker->toArray()); }
/** * Test magic tracker action push * * Covers Tracker::__call and Tracker::toArray * * @param string $name * @param array $args * @dataProvider trackerActionDataProvider */ public function testMagicPush($name, $args) { $this->_actionFactory->expects($this->once())->method('create')->with(['name' => $name, 'args' => $args])->will($this->returnValue(new Tracker\Action($name, $args))); call_user_func_array(array($this->_tracker, $name), $args); $this->assertEquals([array_merge([$name], $args)], $this->_tracker->toArray()); }