public function testFullMethodsDataEntry() { $entry = new Entry(); $entry->setValue(100)->setPrefix('EUR')->setText('Step 1'); $json = json_encode($entry->toArray()); $this->assertEquals('{"text":"Step 1","value":100,"prefix":"EUR"}', $json); }
/** * @test * @dataProvider widgetProvider */ public function JsonForGreenAndRedData($widgetName) { $widget = new $widgetName(); $widget->setId('29473-d7ae87e3-ac3f-4911-95ce-ec91439a4170'); $redData = new Entry(); $redData->setValue(15)->setText('Errors in the last 5 minutes'); $widget->setRedData($redData); $greenData = new Entry(); $greenData->setValue(15)->setText('Errors in the last 60 minutes'); $widget->setGreenData($greenData); $json = json_encode($widget->getData()); $this->assertEquals('{"item":[{"text":"Errors in the last 5 minutes","value":15},{"text":"Errors in the last 60 minutes","value":15}]}', $json); }
public function testGetData() { $myGeckoMeter = new GeckoMeter(); $entry = new Entry(); $entry->setValue(10); $entry->setPrefix(''); $entry->setText('text'); $myGeckoMeter->setReversed(true); $myGeckoMeter->setValue(10); $myGeckoMeter->setMinData($entry); $myGeckoMeter->setMaxData($entry); $expectedData = array('item' => $myGeckoMeter->getValue(), 'max' => array('text' => $entry->getText(), 'value' => $entry->getValue(), 'prefix' => $entry->getPrefix()), 'min' => array('text' => $entry->getText(), 'value' => $entry->getValue(), 'prefix' => $entry->getPrefix()), 'type' => 'reversed'); $this->assertSame($expectedData, $myGeckoMeter->getData()); }