Code Duplication    Length = 25-25 lines in 3 locations

tests/unit/Arguments/RequestFileArgumentTest.php 3 locations

@@ 55-79 (lines=25) @@
52
    /**
53
     * @test
54
     */
55
    public function shouldResolveRequestFileArgumentToOriginalname()
56
    {
57
        /** @var UploadedFile $file */
58
        $file = $this->createMock(UploadedFile::class);
59
        $file->method('getPathname')->willReturn("data://,some-data-in-file");
60
        $file->method('getClientOriginalName')->willReturn("some-original-name");
61
62
        /** @var Request $request */
63
        $request = $this->createMock(Request::class);
64
        $request->files = $this->createMock(FileBag::class);
65
        $request->files->expects($this->once())->method('get')->with(
66
            $this->equalTo("some-key")
67
        )->willReturn($file);
68
69
        /** @var RequestStack $requestStack */
70
        $requestStack = $this->createMock(RequestStack::class);
71
        $requestStack->method("getCurrentRequest")->willReturn($request);
72
73
        $argument = new RequestFileArgument($requestStack, "some-key", "originalname");
74
75
        /** @var mixed $actualResult */
76
        $actualResult = $argument->resolve();
77
78
        $this->assertEquals("some-original-name", $actualResult);
79
    }
80
81
    /**
82
     * @test
@@ 84-108 (lines=25) @@
81
    /**
82
     * @test
83
     */
84
    public function shouldResolveRequestFileArgumentToFilename()
85
    {
86
        /** @var UploadedFile $file */
87
        $file = $this->createMock(UploadedFile::class);
88
        $file->method('getPathname')->willReturn("data://,some-data-in-file");
89
        $file->method('getFilename')->willReturn("some-file-name");
90
91
        /** @var Request $request */
92
        $request = $this->createMock(Request::class);
93
        $request->files = $this->createMock(FileBag::class);
94
        $request->files->expects($this->once())->method('get')->with(
95
            $this->equalTo("some-key")
96
        )->willReturn($file);
97
98
        /** @var RequestStack $requestStack */
99
        $requestStack = $this->createMock(RequestStack::class);
100
        $requestStack->method("getCurrentRequest")->willReturn($request);
101
102
        $argument = new RequestFileArgument($requestStack, "some-key", "filename");
103
104
        /** @var mixed $actualResult */
105
        $actualResult = $argument->resolve();
106
107
        $this->assertEquals("some-file-name", $actualResult);
108
    }
109
110
    /**
111
     * @test
@@ 141-165 (lines=25) @@
138
    /**
139
     * @test
140
     */
141
    public function shouldResolveRequestFileArgumentToMimeType()
142
    {
143
        /** @var UploadedFile $file */
144
        $file = $this->createMock(UploadedFile::class);
145
        $file->method('getPathname')->willReturn("data://,some-data-in-file");
146
        $file->method('getMimeType')->willReturn("text/some-mime-type");
147
148
        /** @var Request $request */
149
        $request = $this->createMock(Request::class);
150
        $request->files = $this->createMock(FileBag::class);
151
        $request->files->expects($this->once())->method('get')->with(
152
            $this->equalTo("some-key")
153
        )->willReturn($file);
154
155
        /** @var RequestStack $requestStack */
156
        $requestStack = $this->createMock(RequestStack::class);
157
        $requestStack->method("getCurrentRequest")->willReturn($request);
158
159
        $argument = new RequestFileArgument($requestStack, "some-key", "mimetype");
160
161
        /** @var mixed $actualResult */
162
        $actualResult = $argument->resolve();
163
164
        $this->assertEquals("text/some-mime-type", $actualResult);
165
    }
166
167
    /**
168
     * @test