50 : void
51 {
52 $collection = $this->repo->blank($this->rcid_generator->getUniqueResourceCollectionIdentification());
53 $this->assertSame(0, $collection->count());
54
55 $rid_one = 'rid_one';
56 $collection->add(new ResourceIdentification($rid_one));
57 $rid_two = 'rid_two';
58 $collection->add(new ResourceIdentification($rid_two));
59
60 $rids_given = [$rid_one, $rid_two];
61 $this->db_mock->expects($this->once())
62 ->method('in')
63 ->with('rid', $rids_given, true, 'text')
64 ->willReturn('rid NOT IN("rid_one", "rid_one")');
65
66 $this->db_mock->expects($this->once())
67 ->method('manipulateF')
68 ->with('DELETE FROM il_resource_rca WHERE rcid = %s AND rid NOT IN("rid_one", "rid_one")');
69
70 $this->db_mock->expects($this->once())
71 ->method('manipulateF')
72 ->with('DELETE FROM il_resource_rca WHERE rcid = %s AND rid NOT IN("rid_one", "rid_one")');
73
74 $called_table_names = [
75 'il_resource_rca',
76 'il_resource_rca',
77 'il_resource_rc',
78 ];
79
80 $this->db_mock->expects($this->exactly(3))
81 ->method('insert')
82 ->willReturnCallback(
83 function ($table_name) use (&$called_table_names): int {
84 $expected_table_name = array_shift($called_table_names);
85 TestCase::assertSame($expected_table_name, $table_name);
86 return 1;
87 }
88 );
89
90 $event_data_container = new DataContainer();
91 $this->repo->update($collection, $event_data_container);
92 $this->assertCount(2, $event_data_container->get());
93 foreach ($event_data_container->get() as $event_data) {
94 $this->assertInstanceOf(CollectionData::class, $event_data);
95 $this->assertContains($event_data->getRid(), $rids_given);
96 $this->assertSame(self::TEST_RCID, $event_data->getRcid());
97 }
98 }