PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/tests/kernel/classes/ezsitedata_test.php

https://github.com/granitegreg/ezpublish
PHP | 58 lines | 33 code | 8 blank | 17 comment | 0 complexity | 6de6fb803fd933e180ab4a6bed642a6e MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * File containing the eZSiteData class
  4. *
  5. * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
  6. * @license http://ez.no/licenses/gnu_gpl GNU GPLv2
  7. * @author Jerome Vieilledent
  8. * @package tests
  9. */
  10. class eZSiteDataTest extends ezpDatabaseTestCase
  11. {
  12. /**
  13. * Unit test for eZPersistentObject implementation
  14. */
  15. public function testPersistentObjectInterface()
  16. {
  17. $this->assertTrue( is_subclass_of( 'eZSiteData', 'eZPersistentObject' ) );
  18. $this->assertTrue( method_exists( 'eZSiteData', 'definition' ) );
  19. }
  20. /**
  21. * Unit test for good eZPersistentObject (ORM) implementation for ezsite_data table
  22. */
  23. public function testORMImplementation()
  24. {
  25. $def = eZSiteData::definition();
  26. $this->assertEquals( 'eZSiteData', $def['class_name'] );
  27. $this->assertEquals( 'ezsite_data', $def['name'] );
  28. $fields = $def['fields'];
  29. $this->assertArrayHasKey( 'name', $fields );
  30. $this->assertArrayHasKey( 'value', $fields );
  31. }
  32. /**
  33. * Unit test for fetchByName() method
  34. */
  35. public function testFetchByName()
  36. {
  37. $name = 'foo';
  38. $row = array(
  39. 'name' => $name,
  40. 'value' => 'bar'
  41. );
  42. $obj = new eZSiteData( $row );
  43. $obj->store();
  44. unset( $obj );
  45. $res = eZSiteData::fetchByName( $name );
  46. $this->assertType( 'eZSiteData', $res );
  47. $res->remove();
  48. }
  49. }
  50. ?>