1111use Keboola \StagingProvider \Staging \File \FileStagingInterface ;
1212use Keboola \StagingProvider \Staging \StagingProvider ;
1313use Keboola \StagingProvider \Staging \StagingType ;
14- use Keboola \StagingProvider \Staging \Workspace \WorkspaceStagingInterface ;
1514use Keboola \StorageApi \Client ;
1615use Keboola \StorageApi \ClientException ;
1716use Keboola \StorageApi \Options \ListFilesOptions ;
@@ -169,39 +168,26 @@ protected function getWorkspaceStagingFactory(
169168 ?LoggerInterface $ logger = null ,
170169 StagingType $ stagingType = StagingType::WorkspaceSnowflake,
171170 ): StrategyFactory {
172- $ workspaceStaging = $ this ->createMock (WorkspaceStagingInterface::class);
173- $ workspaceStaging ->method ('getWorkspaceId ' )->willReturnCallback (
174- function () use ($ stagingType , $ clientWrapper ) {
175- if (!$ this ->workspaceId ) {
176- $ workspaces = new Workspaces ($ clientWrapper ->getBranchClient ());
177- $ workspace = $ workspaces ->createWorkspace (['backend ' => match ($ stagingType ) {
178- StagingType::WorkspaceSnowflake => 'snowflake ' ,
179- StagingType::WorkspaceBigquery => 'bigquery ' ,
180- default => throw new InvalidArgumentException (sprintf (
181- 'Unknown staging %s ' ,
182- $ stagingType ->value ,
183- )),
184- }], true );
185- $ this ->workspaceId = (string ) $ workspace ['id ' ];
186- $ this ->workspaceCredentials = $ workspace ['connection ' ];
187- $ this ->workspaceClient = $ workspaces ;
188- }
189- return $ this ->workspaceId ;
190- },
191- );
192-
193- $ fileStaging = $ this ->createMock (FileStagingInterface::class);
194- $ fileStaging ->method ('getPath ' )->willReturnCallback (
195- function () {
196- return $ this ->temp ->getTmpFolder ();
197- },
198- );
171+ if (!$ this ->workspaceId ) {
172+ $ workspaces = new Workspaces ($ clientWrapper ->getBranchClient ());
173+ $ workspace = $ workspaces ->createWorkspace (['backend ' => match ($ stagingType ) {
174+ StagingType::WorkspaceSnowflake => 'snowflake ' ,
175+ StagingType::WorkspaceBigquery => 'bigquery ' ,
176+ default => throw new InvalidArgumentException (sprintf (
177+ 'Unknown staging %s ' ,
178+ $ stagingType ->value ,
179+ )),
180+ }], true );
181+ $ this ->workspaceId = (string ) $ workspace ['id ' ];
182+ $ this ->workspaceCredentials = $ workspace ['connection ' ];
183+ $ this ->workspaceClient = $ workspaces ;
184+ }
199185
200186 return new StrategyFactory (
201187 new StagingProvider (
202- $ stagingType ,
203- $ workspaceStaging ,
204- $ fileStaging ,
188+ stagingType: $ stagingType ,
189+ localStagingPath: $ this -> temp -> getTmpFolder () ,
190+ stagingWorkspaceId: $ this -> workspaceId ,
205191 ),
206192 $ clientWrapper ,
207193 $ logger ?: new NullLogger (),
@@ -225,8 +211,8 @@ function () {
225211 return new StrategyFactory (
226212 new StagingProvider (
227213 stagingType: $ stagingType ,
228- workspaceStaging: null ,
229- localStaging: $ fileStaging ,
214+ localStagingPath: $ this -> temp -> getTmpFolder () ,
215+ stagingWorkspaceId: null ,
230216 ),
231217 $ clientWrapper ,
232218 $ logger ?: new NullLogger (),
0 commit comments