appwrite/tests/unit/General/CollectionsTest.php

33 lines
880 B
PHP
Raw Normal View History

2021-02-22 12:44:47 +00:00
<?php
2022-08-01 10:22:04 +00:00
namespace Tests\Unit\General;
2021-02-22 12:44:47 +00:00
use PHPUnit\Framework\TestCase;
class CollectionsTest extends TestCase
{
2022-08-01 10:22:04 +00:00
protected array $collections;
2021-02-22 12:44:47 +00:00
public function setUp(): void
{
$this->collections = require('app/config/collections.php');
}
2022-08-01 10:22:04 +00:00
public function testDuplicateRules(): void
2021-02-22 12:44:47 +00:00
{
2021-04-14 14:39:04 +00:00
foreach ($this->collections as $key => $collection) {
2021-12-01 11:48:23 +00:00
if (array_key_exists('attributes', $collection)) {
foreach ($collection['attributes'] as $check) {
2021-10-12 18:22:41 +00:00
$occurrences = 0;
2021-12-01 11:48:23 +00:00
foreach ($collection['attributes'] as $attribute) {
if ($attribute['$id'] == $check['$id']) {
2021-10-12 18:22:41 +00:00
$occurrences++;
2021-02-22 12:44:47 +00:00
}
}
2021-10-12 18:22:41 +00:00
$this->assertEquals(1, $occurrences);
2021-02-22 12:44:47 +00:00
}
}
}
}
}