/** * Test CRUD methods for partials. * * @see WP_Customize_Selective_Refresh::get_partial() * @see WP_Customize_Selective_Refresh::add_partial() * @see WP_Customize_Selective_Refresh::remove_partial() */ function test_crud_partial() { $partial = $this->selective_refresh->add_partial('foo'); $this->assertEquals($this->selective_refresh, $partial->component); $this->assertInstanceOf('WP_Customize_Partial', $partial); $this->assertEquals($partial, $this->selective_refresh->get_partial($partial->id)); $this->assertArrayHasKey($partial->id, $this->selective_refresh->partials()); $this->selective_refresh->remove_partial($partial->id); $this->assertEmpty($this->selective_refresh->get_partial($partial->id)); $this->assertArrayNotHasKey($partial->id, $this->selective_refresh->partials()); $partial = new WP_Customize_Partial($this->selective_refresh, 'bar'); $this->assertEquals($partial, $this->selective_refresh->add_partial($partial)); $this->assertEquals($partial, $this->selective_refresh->get_partial('bar')); $this->assertEqualSets(array('bar'), array_keys($this->selective_refresh->partials())); add_filter('customize_dynamic_partial_args', array($this, 'filter_customize_dynamic_partial_args'), 10, 2); add_filter('customize_dynamic_partial_class', array($this, 'filter_customize_dynamic_partial_class'), 10, 3); $partial = $this->selective_refresh->add_partial('recognized-class'); $this->assertInstanceOf('Tested_Custom_Partial', $partial); $this->assertEquals('.recognized', $partial->selector); }
/** * Test CRUD methods for partials. * * @see WP_Customize_Selective_Refresh::get_partial() * @see WP_Customize_Selective_Refresh::add_partial() * @see WP_Customize_Selective_Refresh::remove_partial() */ function test_crud_partial() { $partial = $this->selective_refresh->add_partial('foo'); $this->assertInstanceOf('WP_Customize_Partial', $partial); $this->assertEquals($partial, $this->selective_refresh->get_partial($partial->id)); $this->assertArrayHasKey($partial->id, $this->selective_refresh->partials()); $this->selective_refresh->remove_partial($partial->id); $this->assertEmpty($this->selective_refresh->get_partial($partial->id)); $this->assertArrayNotHasKey($partial->id, $this->selective_refresh->partials()); // @todo Test applying of customize_dynamic_partial_args filter. // @todo Test applying of customize_dynamic_partial_class filter. }