/** * test for setvalue() * expected integer */ public function testAccelerationSetValue() { $value = new Zend_Measure_Acceleration('100', Zend_Measure_Acceleration::STANDARD, 'de'); $value->setValue('200', Zend_Measure_Acceleration::STANDARD, 'de'); $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); $locale = new Zend_Locale('de_AT'); $value->setValue('200', $locale); $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); $value->setValue('200', 'de'); $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); $value->setValue('-200', Zend_Measure_Acceleration::STANDARD, 'de'); $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a negative integer'); $value->setValue('-200,200', Zend_Measure_Acceleration::STANDARD, 'de'); $this->assertEquals(-200.2, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a decimal value'); $value->setValue('-200.200,200', Zend_Measure_Acceleration::STANDARD, 'de'); $this->assertEquals(-200200.2, $value->getValue(), 'Zend_Measure_Acceleration Object not returned'); $value->setValue('otherstring -200.200,200', Zend_Measure_Acceleration::STANDARD, 'de'); $this->assertEquals(-200200.2, $value->getValue(), 'Zend_Measure_Acceleration Object not returned'); $value->setValue('200', Zend_Measure_Acceleration::STANDARD); $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); try { $value->setValue('otherstring -200.200,200', 'Acceleration::UNKNOWN', 'de'); $this->fail('Exception expected because of unknown type'); } catch (Zend_Measure_Exception $e) { // success } try { $value->setValue('novalue', Zend_Measure_Acceleration::STANDARD, 'de'); $this->fail('Exception expected because of empty value'); } catch (Zend_Measure_Exception $e) { // success } try { $value = new Zend_Measure_Acceleration('100', Zend_Measure_Acceleration::STANDARD, 'de'); $value->setValue('200', Zend_Measure_Acceleration::STANDARD, 'nolocale'); $this->fail('Exception expected because of unknown locale'); } catch (Zend_Measure_Exception $e) { // success } }
/** * test for exception unknown locale * expected exception */ public function testAccelerationSetWithNoLocale() { $value = new Zend_Measure_Acceleration('100', Zend_Measure_Acceleration::STANDARD, 'de'); $value->setValue('200', Zend_Measure_Acceleration::STANDARD); $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); }