7 changed files with 99 additions and 10 deletions
@ -0,0 +1,9 @@
|
||||
<?php |
||||
|
||||
namespace Friendica\Test\Util; |
||||
|
||||
use Friendica\BaseCollection; |
||||
|
||||
class CollectionDouble extends BaseCollection |
||||
{ |
||||
} |
@ -0,0 +1,26 @@
|
||||
<?php |
||||
|
||||
namespace Friendica\Test\Util; |
||||
|
||||
use Friendica\BaseEntity; |
||||
|
||||
/** |
||||
* @property-read string $protString |
||||
* @property-read int $protInt |
||||
* @property-read \DateTime $protDateTime |
||||
*/ |
||||
class EntityDouble extends BaseEntity |
||||
{ |
||||
protected $protString; |
||||
protected $protInt; |
||||
protected $protDateTime; |
||||
private $privString; |
||||
|
||||
public function __construct(string $protString, int $protInt, \DateTime $protDateTime, string $privString) |
||||
{ |
||||
$this->protString = $protString; |
||||
$this->protInt = $protInt; |
||||
$this->protDateTime = $protDateTime; |
||||
$this->privString = $privString; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
<?php |
||||
|
||||
namespace Friendica\Test\src; |
||||
|
||||
use Friendica\Test\MockedTest; |
||||
use Friendica\Test\Util\CollectionDouble; |
||||
use Friendica\Test\Util\EntityDouble; |
||||
|
||||
class CollectionTest extends MockedTest |
||||
{ |
||||
/** |
||||
* Test if the BaseCollection::column() works as expected |
||||
*/ |
||||
public function testGetArrayCopy() |
||||
{ |
||||
$collection = new CollectionDouble(); |
||||
$collection->append(new EntityDouble('test', 23, new \DateTime('now', new \DateTimeZone('UTC')), 'privTest')); |
||||
$collection->append(new EntityDouble('test2', 25, new \DateTime('now', new \DateTimeZone('UTC')), 'privTest23')); |
||||
|
||||
self::assertEquals(['test', 'test2'], $collection->column('protString')); |
||||
self::assertEmpty($collection->column('privString')); |
||||
self::assertEquals([23,25], $collection->column('protInt')); |
||||
} |
||||
} |
Loading…
Reference in new issue