Exemplo n.º 1
0
 public function testFirstAndLast()
 {
     $this->_coll->add('one');
     $this->_coll->add('two');
     $this->assertEquals($this->_coll->first(), 'one');
     $this->assertEquals($this->_coll->last(), 'two');
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getImage()
 {
     if ($this->images->isEmpty()) {
         return $this->getProduct()->getImage();
     }
     return $this->images->first();
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function getImage()
 {
     if ($this->images->isEmpty()) {
         return null;
     }
     return $this->images->first();
 }
Exemplo n.º 4
0
 /**
  * Get filename of the first document signature
  *
  * @return null|string
  */
 public function getFirstDocumentSignatureFilename()
 {
     if ($this->getDocumentSignaturesCount() > 0) {
         /** @var DocumentSignature $signature */
         $signature = $this->documentSignatures->first();
         return $signature->getDocument()->getFilename();
     }
     return null;
 }
 function it_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, Collection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment);
     $order->hasShipments()->willReturn(true);
     $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]);
     $order->getShipments()->willReturn($shipments);
     $itemUnit->getShipment()->willReturn($shipment);
     $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled();
     $shipment->addUnit($itemUnit)->shouldNotBeCalled();
     $this->processOrderShipment($order);
 }
Exemplo n.º 6
0
 /**
  * Gets the last updated shipment of the order
  *
  * @return false|ShipmentInterface
  */
 public function getLastShipment()
 {
     if ($this->shipments->isEmpty()) {
         return false;
     }
     $last = $this->shipments->first();
     foreach ($this->shipments as $shipment) {
         if ($shipment->getUpdatedAt() > $last->getUpdatedAt()) {
             $last = $shipment;
         }
     }
     return $last;
 }
 /**
  * @param Collection|TaxonomyTermInterface[] $collection
  * @return TaxonomyTermInterface|null
  */
 public function findBranch(Collection $collection)
 {
     if (empty($collection)) {
         return null;
     }
     $maxDepth = 9999;
     $item = $collection->first();
     foreach ($collection as $term) {
         $depth = $this->iterBranch($term, $maxDepth);
         if ($depth < $maxDepth) {
             $maxDepth = $depth;
             $item = $term;
         }
     }
     return $item;
 }
Exemplo n.º 8
0
 /**
  * Generates the cells.
  *
  * @param TableView $view
  */
 private function generateCells(TableView $view)
 {
     $sortDirs = [ColumnSort::ASC, ColumnSort::DESC];
     $columns = $this->config->getColumns();
     foreach ($columns as &$columnOptions) {
         $key = $columnOptions['full_name'] . '_sort';
         $sortDir = $this->requestHelper->getVar($key, ColumnSort::NONE);
         $columnOptions['sorted'] = in_array($sortDir, $sortDirs);
     }
     unset($columnOptions);
     $this->data->first();
     while ($this->data->current()) {
         $row = new Row($this->getCurrentRowData('id'));
         // TODO getCurrentRowKey() ?
         foreach ($columns as $columnOptions) {
             $cell = new Cell();
             $type = $this->factory->getColumnType($columnOptions['type']);
             $type->buildViewCell($cell, $this, $columnOptions);
             $row->cells[] = $cell;
         }
         $view->rows[] = $row;
         $this->data->next();
     }
 }
Exemplo n.º 9
0
 /**
  * @dataProvider provideCollection
  */
 public function testContains(Collection $coll, array $elements)
 {
     $this->assertTrue($coll->contains($coll->first()));
     $this->assertFalse($coll->contains(new \stdClass()));
 }
 /**
  * {@inheritdoc}
  */
 public function first()
 {
     return $this->inner->first();
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function getFirstChild()
 {
     return $this->children->first();
 }
 /** {@inheritdoc} */
 public function first()
 {
     $this->initialize();
     return $this->coll->first();
 }
Exemplo n.º 13
0
 /**
  * {@inheritDoc}
  */
 public function first()
 {
     return $this->collection->first();
 }
Exemplo n.º 14
0
 /**
  * @dataProvider provideCollection
  */
 public function testFirst(Collection $coll, array $elements)
 {
     $this->assertSame(reset($elements), $coll->first());
 }
Exemplo n.º 15
0
 /**
  * @return bool
  */
 public function hasOfferVariants()
 {
     if (count($this->quoteProductOffers) > 1) {
         return true;
     }
     /** @var QuoteProductOffer $firstItem */
     $firstItem = $this->quoteProductOffers->first();
     return $firstItem && $firstItem->isAllowIncrements();
 }
Exemplo n.º 16
0
 /**
  * Sets the internal iterator to the first element in the collection and returns this element.
  *
  * @return mixed
  */
 function first()
 {
     $this->initialize();
     $first = $this->collection->first();
     return $first->getTerm();
 }
Exemplo n.º 17
0
 /**
  * @param Collection $orderedByIndex
  * @return bool
  */
 protected function isIncreasing(Collection $orderedByIndex)
 {
     return is_null($orderedByIndex->first()->getMinValue()) && is_null($orderedByIndex->last()->getMaxValue());
 }
Exemplo n.º 18
0
 public function getCity()
 {
     if ($this->lessons->count() > 0) {
         return $this->lessons->first()->getCity();
     }
 }
 public function rewind()
 {
     $this->_data->first();
 }