2525use OpenCensus \Trace \Tracer \ContextTracer ;
2626use OpenCensus \Trace \Span as OCSpan ;
2727use Prophecy \Argument ;
28+ use Google \Cloud \Core \Batch \BatchRunner ;
2829use Google \Cloud \Trace \Trace ;
2930use Google \Cloud \Trace \Span ;
3031use Google \Cloud \Trace \TraceClient ;
@@ -63,15 +64,20 @@ public function setUp()
6364
6465 public function testReportWithAnExceptionErrorLog ()
6566 {
66- $ this ->client ->insert (Argument::any ())->willThrow (
67- new \Exception ('error_log test ' )
68- );
6967 $ trace = $ this ->prophesize (Trace::class);
7068 $ trace ->setSpans (Argument::any ())->shouldBeCalled ();
7169 $ this ->client ->trace (Argument::any ())->willReturn ($ trace ->reveal ());
72- $ exporter = new StackdriverExporter (
73- ['client ' => $ this ->client ->reveal ()]
74- );
70+
71+ $ batchRunner = $ this ->prophesize (BatchRunner::class);
72+ $ batchRunner ->registerJob (Argument::any (), Argument::any (), Argument::any ())->shouldBeCalled ();
73+ $ batchRunner ->submitItem (Argument::any (), Argument::any ())->willThrow (
74+ new \Exception ('error_log test ' )
75+ )->shouldBeCalled ();
76+
77+ $ exporter = new StackdriverExporter ([
78+ 'client ' => $ this ->client ->reveal (),
79+ 'batchRunner ' => $ batchRunner ->reveal ()
80+ ]);
7581 $ this ->expectOutputString (
7682 'Reporting the Trace data failed: error_log test '
7783 );
@@ -95,16 +101,22 @@ public function testReportsVersionAttribute()
95101 return true ;
96102 }))->shouldBeCalled ();
97103 $ this ->client ->trace ('aaa ' )->willReturn ($ trace ->reveal ());
98- $ this ->client ->insert (Argument::type (Trace::class))
99- ->willReturn (true )->shouldBeCalled ();
100104
101105 $ span = new OCSpan ([
102106 'traceId ' => 'aaa '
103107 ]);
104108 $ span ->setStartTime ();
105109 $ span ->setEndTime ();
106110
107- $ exporter = new StackdriverExporter (['client ' => $ this ->client ->reveal ()]);
111+ $ batchRunner = $ this ->prophesize (BatchRunner::class);
112+ $ batchRunner ->registerJob (Argument::any (), Argument::any (), Argument::any ())->shouldBeCalled ();
113+ $ batchRunner ->submitItem (Argument::any (), Argument::any ())
114+ ->willReturn (true )
115+ ->shouldBeCalled ();
116+ $ exporter = new StackdriverExporter ([
117+ 'client ' => $ this ->client ->reveal (),
118+ 'batchRunner ' => $ batchRunner ->reveal ()
119+ ]);
108120 $ this ->assertTrue ($ exporter ->export ([$ span ->spanData ()]));
109121 }
110122}
0 commit comments