PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/aurelienRT1/ezpublish
PHP | 68 lines | 41 code | 10 blank | 17 comment | 0 complexity | 386a29a16b1409f4a719408d582ae8c5 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * File containing the eZSiteData class
  4. *
  5. * @copyright Copyright (C) 1999-2010 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. public function setUp()
  13. {
  14. parent::setUp();
  15. }
  16. public function tearDown()
  17. {
  18. parent::tearDown();
  19. }
  20. /**
  21. * Unit test for eZPersistentObject implementation
  22. */
  23. public function testPersistentObjectInterface()
  24. {
  25. $this->assertTrue( is_subclass_of( 'eZSiteData', 'eZPersistentObject' ) );
  26. $this->assertTrue( method_exists( 'eZSiteData', 'definition' ) );
  27. }
  28. /**
  29. * Unit test for good eZPersistentObject (ORM) implementation for ezsite_data table
  30. */
  31. public function testORMImplementation()
  32. {
  33. $def = eZSiteData::definition();
  34. $this->assertEquals( 'eZSiteData', $def['class_name'] );
  35. $this->assertEquals( 'ezsite_data', $def['name'] );
  36. $fields = $def['fields'];
  37. $this->assertArrayHasKey( 'name', $fields );
  38. $this->assertArrayHasKey( 'value', $fields );
  39. }
  40. /**
  41. * Unit test for fetchByName() method
  42. */
  43. public function testFetchByName()
  44. {
  45. $name = 'foo';
  46. $row = array(
  47. 'name' => $name,
  48. 'value' => 'bar'
  49. );
  50. $obj = new eZSiteData( $row );
  51. $obj->store();
  52. unset( $obj );
  53. $res = eZSiteData::fetchByName( $name );
  54. $this->assertType( 'eZSiteData', $res );
  55. $res->remove();
  56. }
  57. }
  58. ?>