Level 58
Yes, it is possible to mock a dependency injected class on a package. You can use the Mockery package to create a mock object of the class you want to inject. Here is an example of how you can do this:
// Create a mock object of the class you want to inject
$mock = Mockery::mock('PackageY\Request');
// Set the expected behavior of the mock object
$mock->shouldReceive('get')->andReturn('foo');
// Inject the mock object into the constructor of Package X
$packageX = new PackageX($mock);
You can then use the mock object in your tests to verify that the expected behavior is being executed.