Skip to content

Commit

Permalink
feat: make custom fields protected to allow overrides in custom baske…
Browse files Browse the repository at this point in the history
…t items
  • Loading branch information
skuhnow committed Nov 5, 2024
1 parent 5691215 commit 747fb09
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Mathielen/SapOci/Model/OciBaseBasketItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ class OciBaseBasketItem implements OciBasketItemInterface

private ?string $sldSysName = null;

private ?string $custField1 = null;
protected ?string $custField1 = null;

private ?string $custField2 = null;
protected ?string $custField2 = null;

private ?string $custField3 = null;
protected ?string $custField3 = null;

private ?string $custField4 = null;
protected ?string $custField4 = null;

private ?string $custField5 = null;
protected ?string $custField5 = null;

public static function create(): self
{
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/Mathielen/SapOci/Model/OciExtendedBasketItemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Mathielen\SapOci\Model;

use PHPUnit\Framework\TestCase;

class OciExtendedBasketItemTest extends TestCase
{

public function testSetOverriddenCustomField(): void
{
$sut = new OciExtendedBasketItem();
$testString21Chars = \str_repeat('x', 21);
$sut->setCustField4($testString21Chars);
$this->assertEquals($testString21Chars, $sut->getCustField4());
}
}

class OciExtendedBasketItem extends OciBaseBasketItem
{
public function setCustField4(?string $custField4 = null): OciBaseBasketItem
{
$this->custField4 = $custField4;

return $this;
}
}

0 comments on commit 747fb09

Please sign in to comment.