No Description

ServiceTest.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. class Google_Service_ServiceTest extends PHPUnit_Framework_TestCase
  21. {
  22. public function setUp()
  23. {
  24. // ensure dependent classes exist
  25. $this->getMock('Google_Service');
  26. $this->getMock('Google_Model');
  27. $this->getMock('Google_Collection');
  28. $this->getMock('Google_Service_Resource');
  29. }
  30. /**
  31. * @dataProvider serviceProvider
  32. */
  33. public function testIncludes($class)
  34. {
  35. $this->assertTrue(
  36. class_exists($class),
  37. sprintf('Failed asserting class %s exists.', $class)
  38. );
  39. }
  40. public function testCaseConflicts()
  41. {
  42. $apis = $this->apiProvider();
  43. $classes = array_unique(array_map('strtolower', $apis));
  44. $this->assertCount(count($apis), $classes);
  45. }
  46. public function serviceProvider()
  47. {
  48. $classes = array();
  49. $path = __DIR__ . '/../src/Google/Service/';
  50. foreach (glob($path . "*.php") as $file) {
  51. $service = basename($file, '.php');
  52. $classes[] = array('Google_Service_' . $service);
  53. foreach (glob($path . "{$service}/*.php") as $file) {
  54. $classes[] = array("Google_Service_{$service}_" . basename($file, '.php'));
  55. }
  56. foreach (glob($path . "{$service}/Resource/*.php") as $file) {
  57. $classes[] = array("Google_Service_{$service}_Resource_" . basename($file, '.php'));
  58. }
  59. }
  60. return $classes;
  61. }
  62. public function apiProvider()
  63. {
  64. $classes = array();
  65. $path = __DIR__ . '/../src/Google/Service/*';
  66. return array_filter(glob($path), 'is_dir');
  67. }
  68. }