19 declare(strict_types=1);
36 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
38 $this->assertInstanceOf(Integrity::class, $integrity);
43 $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
45 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
46 $db->expects(self::once())->method(
'query')->willReturn($statement);
47 $db->expects(self::once())->method(
'fetchAssoc')->with($statement)->willReturn([
'violations' =>
'17']);
49 $field = $this->getMockBuilder(Field::class)->disableOriginalConstructor()->getMock();
50 $field->method(
'fieldName')->willReturn(
'hej');
52 $referenceField = $this->getMockBuilder(Field::class)->disableOriginalConstructor()->getMock();
53 $referenceField->method(
'fieldName')->willReturn(
'ho');
55 $association = $this->getMockBuilder(Association::class)->disableOriginalConstructor()->getMock();
56 $association->method(
'field')->willReturn($field);
57 $association->method(
'referenceField')->willReturn($referenceField);
59 $definition = $this->getMockBuilder(Definition::class)->disableOriginalConstructor()->getMock();
60 $definition->expects(self::once())->method(
'associations')->willReturn([$association]);
61 $definition->expects(self::once())->method(
'tableName')->willReturn(
'table_a');
62 $definition->expects(self::once())->method(
'referenceTableName')->willReturn(
'table_b');
63 $definition->method(
'ignoreValues')->willReturn([
'Some SQL.']);
67 $result = $integrity->check($definition);
68 $this->assertInstanceOf(Result::class, $result);
69 $this->assertEquals(17, $result->violations());