20250424
[Д] [ObjectArray->Add] Функция добавляет объект в массив объектов, хранящийся в данном классе (аналогично добавлению элемента в массив с помощью []). [Д] [ObjectArray->AddRange] Функция добавляет массив объектов (или объекты, заданные с помощью array) в массив объектов, хранящийся в данном классе. [И] [ObjectArray->Update] Добавление с помощью foreach заменено на AddRange. [Д] [IDuplicated] Добавлен интерфейс реализации дублирования классов. [Д] [IStoredAtSQL] Добавлен интерфейс поддержки моделей и классов, реализующих хранение свойств в SQL базе данных.
This commit is contained in:
		| @@ -43,6 +43,7 @@ class ObjectArrayTest extends TestCase | ||||
|         require_once __DIR__ . '/../../sources/traits/ObjectArray/ObjectArrayConstantsTrait.php'; | ||||
|         require_once __DIR__ . '/../../sources/traits/ObjectArray/ObjectArrayLINQTrait.php'; | ||||
|         require_once __DIR__ . '/../../sources/traits/ObjectArray/ObjectArraySearchAndSortTrait.php'; | ||||
|         require_once __DIR__ . '/../../sources/traits/ObjectArray/ObjectArraySpecialTrait.php'; | ||||
|         require_once __DIR__ . '/../../sources/classes/ObjectArray.php'; | ||||
|     } | ||||
|  | ||||
| @@ -430,4 +431,53 @@ class ObjectArrayTest extends TestCase | ||||
|         $this->assertEquals(3, $b_Array->First()->b); | ||||
|         $this->assertEquals(5, $b_Array->Last()->b); | ||||
|     } | ||||
|  | ||||
|     public function testAdd () | ||||
|     { | ||||
|         $this->PrepareForTest(); | ||||
|  | ||||
|         $obj = new A("a", 3, true); | ||||
|  | ||||
|         $a_Array = new ObjectArray([]); | ||||
|  | ||||
|         $a_Array->Add($obj); | ||||
|  | ||||
|         $b_Array = $a_Array->GetRow(fn (A $a) => $a->a == "a"); | ||||
|  | ||||
|         $this->assertEquals(3, $b_Array->b); | ||||
|     } | ||||
|  | ||||
|     public function testAddRange () | ||||
|     { | ||||
|         $this->PrepareForTest(); | ||||
|  | ||||
|         $array = [ | ||||
|             new A("a", 3, true), | ||||
|             new A("c", 2, false), | ||||
|             new A("b", 1, true), | ||||
|             new A("d", 5, true), | ||||
|             new A("e", 4, true), | ||||
|             new A("f", 6, false) | ||||
|         ]; | ||||
|  | ||||
|         $a_Array = new ObjectArray(); | ||||
|         $a_Array->AddRange($array); | ||||
|  | ||||
|         $this->assertEquals(6, $a_Array->Count()); | ||||
|  | ||||
|         $array2 = [ | ||||
|             new A("g", 3, true), | ||||
|             new A("h", 2, false), | ||||
|             new A("i", 1, true), | ||||
|             new A("k", 5, true), | ||||
|             new A("l", 4, true), | ||||
|             new A("m", 6, false) | ||||
|         ]; | ||||
|  | ||||
|         $objectArray = new ObjectArray($array2); | ||||
|  | ||||
|         $a_Array->AddRange($objectArray); | ||||
|  | ||||
|         $this->assertEquals(12, $a_Array->Count()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user