123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- class TestModel extends Google_Model
- {
- public function mapTypes($array)
- {
- return parent::mapTypes($array);
- }
- public function isAssociativeArray($array)
- {
- return parent::isAssociativeArray($array);
- }
- }
- class ServiceTest extends PHPUnit_Framework_TestCase
- {
- public function testModel()
- {
- $model = new TestModel();
- $model->mapTypes(
- array(
- 'name' => 'asdf',
- 'gender' => 'z',
- )
- );
- $this->assertEquals('asdf', $model->name);
- $this->assertEquals('z', $model->gender);
- $model->mapTypes(
- array(
- '__infoType' => 'Google_Model',
- '__infoDataType' => 'map',
- 'info' => array (
- 'location' => 'mars',
- 'timezone' => 'mst',
- ),
- 'name' => 'asdf',
- 'gender' => 'z',
- )
- );
- $this->assertEquals('asdf', $model->name);
- $this->assertEquals('z', $model->gender);
- $this->assertEquals(false, $model->isAssociativeArray(""));
- $this->assertEquals(false, $model->isAssociativeArray(false));
- $this->assertEquals(false, $model->isAssociativeArray(null));
- $this->assertEquals(false, $model->isAssociativeArray(array()));
- $this->assertEquals(false, $model->isAssociativeArray(array(1, 2)));
- $this->assertEquals(false, $model->isAssociativeArray(array(1 => 2)));
- $this->assertEquals(true, $model->isAssociativeArray(array('test' => 'a')));
- $this->assertEquals(true, $model->isAssociativeArray(array("a", "b" => 2)));
- }
-
- public function testIncludes($class)
- {
- $this->assertTrue(
- class_exists($class),
- sprintf('Failed asserting class %s exists.', $class)
- );
- }
- public function serviceProvider()
- {
- $classes = array();
- $path = dirname(dirname(dirname(__FILE__))) . '/src/Google/Service';
- foreach (glob($path . "/*.php") as $file) {
- $classes[] = array('Google_Service_' . basename($file, '.php'));
- }
- return $classes;
- }
- public function testStrLen()
- {
- $this->assertEquals(0, Google_Utils::getStrLen(null));
- $this->assertEquals(0, Google_Utils::getStrLen(false));
- $this->assertEquals(0, Google_Utils::getStrLen(""));
- $this->assertEquals(1, Google_Utils::getStrLen(" "));
- $this->assertEquals(2, Google_Utils::getStrLen(" 1"));
- $this->assertEquals(7, Google_Utils::getStrLen("0a\\n\n\r\n"));
- }
- }
|