ODMGeneratorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ __toString() 0 4 1
A testODMGenerator() 0 10 1
A testWithValueObjectStringable() 0 18 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\MediaBundle\Tests\Generator;
15
16
use PHPUnit\Framework\TestCase;
17
use Sonata\MediaBundle\Generator\ODMGenerator;
18
use Sonata\MediaBundle\Tests\Entity\Media;
19
20
/**
21
 * @group legacy
22
 */
23
class ODMGeneratorTest extends TestCase
24
{
25
    public function testODMGenerator(): void
26
    {
27
        $generator = new ODMGenerator();
0 ignored issues
show
Deprecated Code introduced by
The class Sonata\MediaBundle\Generator\ODMGenerator has been deprecated with message: 3.4 Use Sonata\MediaBundle\Generator\UuidGenerator

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
29
        $media = new Media();
30
        $media->setContext('user');
31
32
        $media->setId('550e8400-e29b-41d4-a716-446655440000');
33
        $this->assertSame('user/550e/84', $generator->generatePath($media));
34
    }
35
36
    public function testWithValueObjectStringable(): void
37
    {
38
        $generator = new ODMGenerator();
0 ignored issues
show
Deprecated Code introduced by
The class Sonata\MediaBundle\Generator\ODMGenerator has been deprecated with message: 3.4 Use Sonata\MediaBundle\Generator\UuidGenerator

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
39
40
        $media = new Media();
41
        $media->setContext('user');
42
43
        // Dummy Value Object representing UUID
44
        $vo = new class() {
45
            public function __toString()
46
            {
47
                return '550e8400-e29b-41d4-a716-446655440000';
48
            }
49
        };
50
        $media->setId($vo);
51
52
        $this->assertSame('user/550e/84', $generator->generatePath($media));
53
    }
54
}
55